@e-llm-studio/instant-learning 0.0.67 → 0.0.69

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 (46) hide show
  1. package/dist/index.esm.js +1 -1
  2. package/dist/index.js +2 -2
  3. package/dist/src/features/DataSelector/components/subcomponents/DataSetElement/DataSetElement.d.ts.map +1 -1
  4. package/dist/src/features/DataSelector/components/subcomponents/Pagination/Pagination.d.ts.map +1 -1
  5. package/dist/src/features/InstantLearning/_components/_svg/ArrowDown.d.ts.map +1 -1
  6. package/dist/src/features/InstantLearning/_components/_svg/ArrowIconBlue.d.ts.map +1 -1
  7. package/dist/src/features/InstantLearning/_components/_svg/CompleteIconGreen.d.ts.map +1 -1
  8. package/dist/src/features/InstantLearning/_components/_svg/NewChatIcon.d.ts.map +1 -1
  9. package/dist/src/features/UploadData/Components/SelectDataFromGoogleDrive/SelectDataFromGoogleDrive.d.ts.map +1 -1
  10. package/dist/src/features/UploadData/Components/SelectDataFromGoogleDrive/SelectDataFromGoogleDriveButton.d.ts.map +1 -1
  11. package/dist/src/features/UploadData/Components/SelectDataFromLocalSystem/SelectDataFromLocalSystem.d.ts.map +1 -1
  12. package/dist/src/features/UploadData/Components/SelectDataFromLocalSystem/SelectDataFromLocalSystemButton.d.ts.map +1 -1
  13. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/Dataset-collection.d.ts.map +1 -1
  14. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/DatasetCollectionInfo.d.ts.map +1 -1
  15. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/ProjectTaskSelect.d.ts.map +1 -1
  16. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/Tooltip.d.ts.map +1 -1
  17. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/dataset-collectionFilterColumnMenuComponents/ConfidenceScoreColumnMenu.d.ts.map +1 -1
  18. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/dataset-collectionFilterColumnMenuComponents/FilterHandlerUtility.d.ts.map +1 -1
  19. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/dataset-collectionFilterColumnMenuComponents/LabelColumnMenu.d.ts.map +1 -1
  20. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/dataset-collectionFilterColumnMenuComponents/TableColumnResetFilterButton.d.ts.map +1 -1
  21. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/dataset-collectionFilterColumnMenuComponents/TagColumnMenu.d.ts.map +1 -1
  22. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/dropdown-with-radio.d.ts.map +1 -1
  23. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/Components/input-label-with-info.d.ts.map +1 -1
  24. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/RELFInterfaces.d.ts.map +1 -1
  25. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/SelectDataFromRLEF.d.ts.map +1 -1
  26. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/SelectDataFromRLEFButton.d.ts.map +1 -1
  27. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/collections.d.ts.map +1 -1
  28. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/common.d.ts.map +1 -1
  29. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/data.d.ts.map +1 -1
  30. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/modelGroup.type.d.ts.map +1 -1
  31. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/models.d.ts.map +1 -1
  32. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/projects.d.ts.map +1 -1
  33. package/dist/src/features/UploadData/Components/SelectDataFromRLEF/interfaces/tags.d.ts.map +1 -1
  34. package/dist/src/features/UploadData/Components/SelectDataFromSavedDataSet/SelectDataFromSavedDataSet.d.ts.map +1 -1
  35. package/dist/src/features/UploadData/Components/SelectDataFromSavedDataSet/SelectDataFromSavedDataSetButton.d.ts.map +1 -1
  36. package/dist/src/features/WtaWnta/WtaWnta.d.ts +7 -0
  37. package/dist/src/features/WtaWnta/WtaWnta.d.ts.map +1 -1
  38. package/dist/src/features/WtaWnta/_components/AgentDetailsForm.d.ts +2 -0
  39. package/dist/src/features/WtaWnta/_components/AgentDetailsForm.d.ts.map +1 -1
  40. package/dist/src/features/WtaWnta/_components/SimilarConflictingCard.d.ts +1 -0
  41. package/dist/src/features/WtaWnta/_components/SimilarConflictingCard.d.ts.map +1 -1
  42. package/dist/src/features/WtaWnta/_components/ValidationCard.d.ts +1 -0
  43. package/dist/src/features/WtaWnta/_components/ValidationCard.d.ts.map +1 -1
  44. package/package.json +1 -1
  45. package/dist/assets/NewChatIcon-fd245fa6ad1d0368.svg +0 -9
  46. package/dist/assets/ThinkingBulbIcon-6fbbe065ef78c384.gif +0 -0
package/dist/index.esm.js CHANGED
@@ -340,7 +340,7 @@ const l7=Z8("volume-2",[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.
340
340
  * This source code is licensed under the ISC license.
341
341
  * See the LICENSE file in the root directory of this source tree.
342
342
  */
343
- const h7=Z8("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),d7=Z8("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);Z8("youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);Z8("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);Z8("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);Z8("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);Z8("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var u7=function(t){var r=t.amplitude,a=t.variant,o=t.isActive,l=t.className,h=void 0===l?"":l,d=t.onClick,u=t.disabled,m=void 0!==u&&u,p=t.isConnecting,v=c(Array(40).fill(4)),f=v[0],z=v[1],g=i(null),y=function(){var e=Math.min(Math.max(r,0),1),t=Math.max(e,.2),n=Array(40).fill(0).map((function(e,n){var r=Math.sin(n+Date.now()/100)+.5*Math.random();return 5+9*Math.abs(r)*t}));z(n),g.current=requestAnimationFrame(y)};s((function(){return o?g.current=requestAnimationFrame(y):(z(Array(40).fill(4)),g.current&&cancelAnimationFrame(g.current)),function(){g.current&&cancelAnimationFrame(g.current)}}),[o,r]);var E=o?"#364152":"#D0D4DB",b="microphone"===a?o||p?o7:a7:o?l7:s7;return e("div",M({className:h,style:{position:"relative",height:"3rem",zIndex:50,width:"100%",overflow:"hidden",display:"flex",alignItems:"center"}},{children:[n("div",M({style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",height:"2rem",gap:"0.25rem"}},{children:f.map((function(e,t){return n("div",{style:{flexShrink:0,width:"4px",borderRadius:"9999px",transition:"all 100ms",backgroundColor:E,height:"".concat(e,"px"),opacity:o?1:.4}},t)}))})),n("button",M({onClick:d,disabled:m,"aria-label":"".concat(a," button"),style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"2rem",height:"2rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 200ms",backgroundColor:"white",border:"1px solid ".concat(E),cursor:m?"not-allowed":"pointer"}},{children:n(b,{color:E,className:p?"animate-spin":"",style:{width:"1.25rem",height:"1.25rem"}})}))]}))};C(".welcome-message{align-items:flex-start;animation:fadeSlideIn 1.2s ease-out forwards;border-radius:.5rem;color:#333;display:fixed;font-size:1rem;line-height:1.75rem;max-width:100%;opacity:0;overflow-wrap:break-word;padding:1rem;transform:translateY(10px);white-space:pre-wrap;word-break:break-word}@keyframes fadeSlideIn{to{opacity:1;transform:translateY(0)}}");var m7=function(t){var r=t.label,a=t.onToggle,o=c(!1),l=o[0],h=o[1],d=i(null);return s((function(){var e=d.current;e&&l&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[l]),e("span",M({ref:d,onClick:function(){var e=!l;console.log("newstate: ",e),h(e),a(r,e)},style:{cursor:"pointer",backgroundColor:l?"#E8F5E9":"#fff",color:l?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){l||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){l||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[n("span",M({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:l?"scale(1.2)":"scale(1)",opacity:l?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:l?"✓":"+"})),n("span",{children:r})]}))};function p7(e){return"string"==typeof e?e:Array.isArray(e)?e.map(p7).join(""):"object"==typeof e&&null!==e&&"props"in e?p7(e.props.children):""}var v7=function(t){var r=t.label,a=t.onToggle,o=t.isSelected,l=void 0!==o&&o,h=c(l),d=h[0],u=h[1],m=i(null);s((function(){u(l)}),[l]);return s((function(){var e=m.current;e&&d&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[d]),e("span",M({ref:m,onClick:function(){var e=!d;console.log("newstate: ",e),u(e),a(p7(r),e)},style:{cursor:"pointer",backgroundColor:d?"#E8F5E9":"#fff",color:d?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){d||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){d||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[n("span",M({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:d?"scale(1.2)":"scale(1)",opacity:d?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:d?"✓":"+"})),n("span",{children:r})]}))},f7=function(r){var o=r.index,d=r.content,u=r.messages,m=r.handleStream,p=r.scrollToBottom,v=c([]),f=v[0],z=v[1],g=c(!1),y=g[0],b=g[1],H=c(!1),C=H[0],L=H[1],w=c([]),k=w[0],x=w[1],S=c(!1),T=S[0],O=S[1],A=c(!1),R=A[0],N=A[1],_=c({}),D=_[0],P=_[1],F=c([]),I=F[0],B=F[1],j=c([]),U=j[0],W=j[1],$=c(d),q=$[0],G=$[1];s((function(){C||G(d)}),[d,C]);var Y=l((function(e,t){var n=Array.isArray(e)?e[0]:e;b(!0),z((function(e){return t?e.includes(n)?e:V(V([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}),[]),K=l((function(e,t){var n=Array.isArray(e)?e[0]:e;O(!0),x((function(e){return t?e.includes(n)?e:V(V([],e,!0),[n],!1):e.filter((function(e){return e!==n}))})),null==p||p()}),[p]),X=l((function(e,t,n){var r=Array.isArray(t)?t[0]:t;P((function(t){var a,o=t[e]||{selected:[],showSelected:!1,submitted:!1};return M(M({},t),((a={})[e]=M(M({},o),{showSelected:!0,selected:n?o.selected.includes(r)?o.selected:V(V([],o.selected,!0),[r],!1):o.selected.filter((function(e){return e!==r}))}),a))})),null==p||p()}),[p]),Q=l((function(e){return D[e]||{selected:[],showSelected:!1,submitted:!1}}),[D]),J=l((function(e,t){P((function(n){var r;return M(M({},n),((r={})[e]=M(M({},n[e]||{selected:[],showSelected:!1,submitted:!1}),t),r))}))}),[]),Z={deletesimilarlearning:{group:"similarLearning",action:"delete",displayName:"Delete similar learning"},mergesimilarlearning:{group:"similarLearning",action:"merge",displayName:"Merge similar learning"},editsimilarlearning:{group:"similarLearning",action:"edit",displayName:"Edit similar learning"},deletesimilarlearnings:{group:"similarLearnings",action:"delete",displayName:"Delete similar learnings"},mergesimilarlearnings:{group:"similarLearnings",action:"merge",displayName:"Merge similar learnings"},editsimilarlearnings:{group:"similarLearnings",action:"edit",displayName:"Edit similar learnings"},deleteconflictinglearning:{group:"conflictingLearning",action:"delete",displayName:"Delete conflicting learning"},editconflictinglearning:{group:"conflictingLearning",action:"edit",displayName:"Edit conflicting learning"},deleteconflictinglearnings:{group:"conflictingLearnings",action:"delete",displayName:"Delete conflicting learnings"},editconflictinglearnings:{group:"conflictingLearnings",action:"edit",displayName:"Edit conflicting learnings"}},ee=l((function(t){return function(r){r.node;var a=E(r,["node"]),o=a.label||a.children||"Unknown label",c=Array.isArray(o)?o[0]:o,i=Q(t),l=Z[t],s=Object.keys(Z).filter((function(e){return Z[e].group===l.group})),h=s.some((function(e){return e!==t&&Q(e).submitted}));return i.submitted?i.selected.includes(c)?e("span",M({style:{backgroundColor:"#E8F5E9",color:"#2E7D32",padding:"4px 8px",borderRadius:"4px",fontWeight:"500",display:"inline-block",margin:"2px"}},{children:["✓ ",o]})):null:h?null:n(v7,{label:o,isSelected:i.selected.includes(c),onToggle:function(e,n){X(t,e,n)}})}}),[Q,X]),te=l((function(e){return a.Children.toArray(e).filter((function(e){if(!e||"object"!=typeof e)return!0;for(var t=p7(e),n=function(e,n){if(t.includes(n.displayName)){var r=Object.keys(Z).filter((function(e){return Z[e].group===n.group}));if(r.some((function(t){return t!==e&&Q(t).submitted})))return{value:!1}}},r=0,a=Object.entries(Z);r<a.length;r++){var o=a[r],c=n(o[0],o[1]);if("object"==typeof c)return c.value}return!0}))}),[Q]),ne=i(d);s((function(){ne.current!==d&&(P({}),ne.current=d)}),[d]);var re=h((function(){return{img:function(e){e.node;var t=E(e,["node"]);return n("img",M({},t,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==t?void 0:t.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var t=E(e,["node"]);return n("p",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==t?void 0:t.children}))},code:function(e){e.node;var t=E(e,["node"]);return n("span",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==t?void 0:t.children}))},ol:function(e){e.node;var t=E(e,["node"]),r=te(null==t?void 0:t.children);return n("ol",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:r}))},ul:function(e){e.node;var t=E(e,["node"]),r=te(null==t?void 0:t.children);return n("ul",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:r}))},wta:function(t){t.node;var r=E(t,["node"]);r.key||r["data-key"];var a=r.label||r.children||"Unknown label",o=Array.isArray(a)?a[0]:a;return C?f.includes(o)?e("span",M({style:{backgroundColor:"#E8F5E9",color:"#2E7D32",padding:"4px 8px",borderRadius:"4px",fontWeight:"500",display:"inline-block",margin:"2px"}},{children:["✓ ",a]})):null:n(m7,{label:a,onToggle:function(e,t){Y(e,t)}})},editwta:function(t){t.node;var r=E(t,["node"]);r.key||r["data-key"];var a=r.label||r.children||"Unknown label",o=Array.isArray(a)?a[0]:a;return R?k.includes(o)?e("span",M({style:{backgroundColor:"#E8F5E9",color:"#2E7D32",padding:"4px 8px",borderRadius:"4px",fontWeight:"500",display:"inline-block",margin:"2px"}},{children:["✓ ",a]})):null:n(v7,{label:a,onToggle:function(e,t){K(e,t)}})},deletesimilarlearning:ee("deletesimilarlearning"),mergesimilarlearning:ee("mergesimilarlearning"),editsimilarlearning:ee("editsimilarlearning"),deletesimilarlearnings:ee("deletesimilarlearnings"),mergesimilarlearnings:ee("mergesimilarlearnings"),editsimilarlearnings:ee("editsimilarlearnings"),deleteconflictinglearning:ee("deleteconflictinglearning"),editconflictinglearning:ee("editconflictinglearning"),deleteconflictinglearnings:ee("deleteconflictinglearnings"),editconflictinglearnings:ee("editconflictinglearnings")}}),[d,u,U,D,te,ee]);!function(e,t){s((function(){for(var n,r=0,a=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];r<a.length;r++){for(var o=a[r],c=(null==o?void 0:o.responsedata)||"",i=/<wta>([\s\S]*?)<\/wta>/gi,l=[],s=void 0;null!==(s=i.exec(c));)console.log("match wta suggestion",s),l.push(s[1]);l.length&&t(l)}}),[e,t])}(u,B);!function(e){s((function(){for(var t,n=0,r=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];n<r.length;n++){for(var a=r[n],o=(null==a?void 0:a.responsedata)||"",c=/<editwta>([\s\S]*?)<\/editwta>/gi,i=[],l=void 0;null!==(l=c.exec(o));)console.log("match wta suggestion",l),i.push(l[1]);i.length&&W(i)}}),[e,W])}(u);var ae=h((function(){if(!Array.isArray(f)||!Array.isArray(I))return"";var e=f.map((function(e){return I.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[f,I]),oe=h((function(){if(!Array.isArray(k)||!Array.isArray(U))return"";var e=k.map((function(e){var t;return null===(t=U.map((function(e){return null==e?void 0:e.replaceAll("**","")})))||void 0===t?void 0:t.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[k,U]);return e(t,{children:[n(vM,M({components:re,rehypePlugins:[sC]},{children:q}),o),n("div",M({style:{display:"flex",maxWidth:"100%"}},{children:n("div",M({style:{width:"100%"}},{children:(null==f?void 0:f.length)>0&&y?e("span",{children:["It looks like you've chosen ",f.length>1?"suggestions":"suggestion"," ",ae,". Would you like me to proceed with them?",n("p",{children:n("button",M({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t,n=f.map((function(e){return"<wta>".concat(e,"</wta>")})).join(" "),r=q.replace(/<wta>[\s\S]*?<\/wta>(?:\s*(?:or\s*)?<wta>[\s\S]*?<\/wta>)*/g,n);G(r),L(!0),b(!1),m(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Add when to apply conditions ".concat(null===(t=f.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,"")))}},{children:"Yes"}))})]}):n("span",{})}))})),n("div",M({style:{display:"flex",maxWidth:"100%"}},{children:n("div",M({style:{width:"100%"}},{children:(null==k?void 0:k.length)>0&&T?e("span",{children:["It looks like you've chosen ",k.length>1?"options":"option"," ",oe,". Would you like me to proceed with them?",n("p",{children:n("button",M({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t;m(new KeyboardEvent("keydown",{key:"Enter"}),!1,"".concat(null===(t=k.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,""))),O(!1),N(!0)}},{children:"Yes"}))})]}):n("span",{})}))})),function(){var t=Object.entries(D).filter((function(e){e[0];var t=e[1];return t.selected.length>0&&t.showSelected}));if(0===t.length)return null;var r=t[0],a=r[0],o=r[1],c=Z[a];return n("div",M({style:{display:"flex",maxWidth:"100%"}},{children:n("div",M({style:{width:"100%"}},{children:e("span",{children:["It looks like you've chosen ",o.selected.length>1?"options":"option"," for ",c.displayName,". Would you like me to proceed with them?",n("p",{children:n("button",M({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t;m(new KeyboardEvent("keydown",{key:"Enter"}),!1,"".concat(null===(t=o.selected.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,""))),J(a,{showSelected:!1,submitted:!0})}},{children:"Yes"}))})]})}))}))}()]})};function z7(e){return e.replace(/\bFalse\b/g,"false").replace(/\bTrue\b/g,"true").replace(/([{,]\s*)'([^']+?)'\s*:/g,'$1"$2":').replace(/:\s*'([^']*?)'/g,(function(e,t){var n=t.replace(/"/g,'\\"');return': "'.concat(n,'"')})).replace(/\bNone\b/g,"null")}function g7(e){var t=e.baseUrl,n=e.organizationName,r=e.payload,a=e.additionalHeaders,o="".concat(t,"/api/chatbot/publishAgenticFeedbackForVariantIngestion?name=ilnewtest&organizationName=").concat(encodeURIComponent(n));return fetch(o,{method:"POST",headers:M({"Content-Type":"application/json"},null!=a?a:{}),credentials:"include",body:"string"==typeof r?r:JSON.stringify(r)}).catch((function(e){throw console.error("[InstantLearningService] Fetch error:",e),e}))}var y7,M7,E7=function(){return n("svg",M({width:"20px",height:"20px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M9.91158 12H7.45579H4L2.02268 4.13539C2.0111 4.0893 2.00193 4.04246 2.00046 3.99497C1.97811 3.27397 2.77209 2.77366 3.46029 3.10388L22 12L3.46029 20.8961C2.77983 21.2226 1.99597 20.7372 2.00002 20.0293C2.00038 19.9658 2.01455 19.9032 2.03296 19.8425L3.5 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},b7=function(t){var r=t.resetChatHistory,a=t.isStreamEnd;return e("div",M({className:j8,style:{width:"100%",padding:"0.75rem 0rem",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff",borderBottom:"1px solid #e5e7eb",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.04)"}},{children:[e("span",M({style:{fontSize:"1.25rem",fontWeight:700,color:"#1f2937",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[n("span",M({style:{color:"#5928ED"}},{children:"InstantLearning.AI"}))," Chat"]})),n(LJ,M({title:"New chat",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n("div",M({onClick:function(){console.log(B8,"hello"),a&&r()},style:{height:"1.8rem",width:"1.8rem",marginLeft:"1rem",marginRight:"0.5rem",cursor:a?"pointer":"not-allowed",backgroundColor:"transparent",transition:"transform 0.2s ease-in-out, opacity 0.2s",opacity:a?.8:.4,pointerEvents:a?"auto":"none"},onMouseOver:function(e){a&&(e.currentTarget.style.opacity="1")},onMouseOut:function(e){a&&(e.currentTarget.style.opacity="0.8")}},{children:n(B8,{})}))}))]}))},H7=function(e,t,n,r){return b(void 0,void 0,void 0,(function(){var a,o,c,i,l,s,h,d,u,m;return H(this,(function(p){switch(p.label){case 0:a=e.delete_current_learning,o=e.deleted_similar_learning_ids,c=e.deleted_conflicting_learning_ids,console.log("Processing delete tool call:",e),i=V(V([],o||[],!0),c||[],!0),l=0,s=i,p.label=1;case 1:if(!(l<s.length))return[3,6];h=s[l],p.label=2;case 2:return p.trys.push([2,4,,5]),d={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:h,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(h),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},console.log("Deleting learning with ID: ".concat(h)),[4,g7({baseUrl:t,organizationName:n,chatAssistantName:r,payload:d})];case 3:return(u=p.sent()).ok?console.log("Successfully deleted learning ".concat(h)):console.error("Failed to delete learning ".concat(h,":"),u.status,u.statusText),[3,5];case 4:return m=p.sent(),console.error("Error deleting learning ".concat(h,":"),m),[3,5];case 5:return l++,[3,1];case 6:return a&&console.log("Delete current learning flag is true - this will be handled later"),[2]}}))}))},V7=function(t){var r=t.label,a=t.onToggle,o=c(!1),l=o[0],h=o[1],d=i(null);return s((function(){var e=d.current;e&&l&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[l]),e("span",M({ref:d,onClick:function(){var e=!l;h(e),a(r,e)},style:{cursor:"pointer",backgroundColor:l?"#E8F5E9":"#fbfaff",color:l?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){l||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){l||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[n("span",M({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:l?"scale(1.2)":"scale(1)",opacity:l?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:l?"✓":"+"})),n("span",{children:r})]}))},C7=function(r){r.chatAssistantLogoUrl;var a=r.chatAssistantName,o=r.organizationName,d=r.baseUrl,u=r.setInstantLearningSuggestions,m=r.formDataState,p=r.setFormDataState;r.hasUserFilledForm;var v=r.setHasUserFilledForm,f=r.baseWebsocketUrl,z=r.setIsNewChatClicked;r.selectedText,r.ChatIconComponent,r.ggcAssistantName;var g=r.ThinkingBulbIconComponent;r.hasUserWrittenModification;var y=r.setExtractedModification,C=r.setSave,L=r.setExtractedTooltip,w=r.setIsSaveLoading;r.isSaveLoading,r.save,r.instantLearningSuggestions,r.template;var k=r.setShouldTriggerSave,x=r.validationWtaResponse,S=r.setValidationWtaResponse,T=r.learningWtaResponse,O=r.setLearningWtaResponse,A=r.isFormSaveClicked,R=r.setIsFormSavedClicked,N=r.onDeleteLearning,_=r.deleteLearningTrigger,D=r.setDeleteLearningTrigger;r.onMergeLearning;var P=r.mergeLearningTrigger,F=r.setMergeLearningTrigger,I=r.onResetLearningData,B=r.setEditConflictingLearningTrigger,j=r.setEditSimilarLearningTrigger,U=r.sendMessageInChat,W=r.setSendMessageInChat,$=r.setIsMergeLoading,q=a,G=i("".concat(q,"-").concat(o,"-").concat(N8())),Y=i("".concat(N8())),K=d,X=i(null),Q=i(null),J=c([]),Z=J[0],ee=J[1],te=c(!1);te[0];var ne=te[1],re=c(""),ae=re[0],oe=re[1],ce=c(""),ie=ce[0],le=ce[1],se=c([]),he=se[0],de=se[1],ue=c(!1),me=ue[0],pe=ue[1],ve=c(!1);ve[0];var fe=ve[1],ze=c(!0),ge=ze[0],ye=ze[1],Me=c(!0),Ee=Me[0],be=Me[1],He=c("");He[0];var Ve=He[1],Ce=c(""),Le=Ce[0],we=Ce[1],ke=c(!1),xe=ke[0],Se=ke[1],Te=c(!1),Oe=Te[0],Ae=Te[1],Re=c(!1),Ne=Re[0],_e=Re[1],De=c([]);De[0];var Pe=De[1],Fe=c(new Set),Ie=Fe[0],Be=Fe[1],je=c(new Set),Ue=je[0],We=je[1],$e=i(""),qe=i(""),Ge=i(new Set),Ye=h((function(){return""===(null==ae?void 0:ae.trim())||xe}),[ae,xe]),Ke=i(null),Xe=c("100%"),Qe=Xe[0],Je=Xe[1];h((function(){var e,t,n;return!(""===(null===(e=null==m?void 0:m.original)||void 0===e?void 0:e.trim())||(null==m?void 0:m.isTooltipEnabled)&&""===(null===(t=null==m?void 0:m.tooltip)||void 0===t?void 0:t.trim())||(null==m?void 0:m.isModificationEnabled)&&""===(null===(n=null==m?void 0:m.modification)||void 0===n?void 0:n.trim()))}),[m]),s((function(){var e='Please tell me how I should correct "'.concat((null==m?void 0:m.original)||"",'"? ');le(e)}),[m]),s((function(){var e=X.current,t=function(){var e=X.current;if(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;_e(!(n-(t+r)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[Ne,ge,he]);var Ze=l((function(e){return b(void 0,void 0,void 0,(function(){var t,n,r,a,c,i,l;return H(this,(function(s){switch(s.label){case 0:if(t=JSON.stringify({deleted_similar_learning_ids:e.deleted_similar_learning_ids||[],deleted_conflicting_learning_ids:e.deleted_conflicting_learning_ids||[],delete_current_learning:e.delete_current_learning||!1}),Ge.current.has(t))return console.log("Delete operation already processed, skipping callback execution:",t),[2];Ge.current.add(t),console.log("Processing new delete operation:",t),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,H7(e,d,o,q)];case 2:return s.sent(),n=e.deleted_similar_learning_ids,r=void 0===n?[]:n,a=e.deleted_conflicting_learning_ids,c=void 0===a?[]:a,i=V(V([],r||[],!0),c||[],!0),Be((function(e){var t=new Set(e);return i.forEach((function(e){return t.add(e)})),console.log("Added deleted learning IDs to tracking set:",Array.from(t)),t})),console.log("UI state updated after deletion of learnings:",i),[3,4];case 3:throw l=s.sent(),Ge.current.delete(t),console.error("Error processing delete operation:",l),l;case 4:return[2]}}))}))}),[d,o,q,Be]),et=l((function(e){return b(void 0,void 0,void 0,(function(){var t,n,r,a,c,i,l,s,h,u,v,f;return H(this,(function(z){switch(z.label){case 0:$(!0),console.log("🔴 MERGE CALLBACK - Processing merge tool call:",e),z.label=1;case 1:if(z.trys.push([1,6,7,8]),t=e.merge_learnings,n=e.similar_learnings,r=e.conditions_whentoapply,a=e.conditions_whennottoapply,console.log("🔴 MERGE CALLBACK - Extracted data:"),console.log("merge_learnings:",t),console.log("similar_learnings:",n),console.log("conditions_whentoapply:",r),console.log("conditions_whennottoapply:",a),!t||!n||!Array.isArray(n))return console.log("Invalid merge tool data, skipping"),[2];console.log(" MERGE CALLBACK - Current formDataState before replacement:",m),console.log(" MERGE CALLBACK - Current whenToApply:",null==m?void 0:m.whenToApply),console.log(" MERGE CALLBACK - Current whenNotToApply:",null==m?void 0:m.whenNotToApply),r&&Array.isArray(r)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenToApply conditions:",r),c=r.join(" OR "),console.log(" MERGE CALLBACK - New whenToApply string:",c),p((function(e){console.log(" MERGE CALLBACK - Previous formDataState:",e);var t=M(M({},e),{whenToApply:c,_mergeUpdate:!0,_mergeWTA:r});return console.log("MERGE CALLBACK - New formDataState:",t),t}))),a&&Array.isArray(a)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenNotToApply conditions:",a),i=a.join(" OR "),console.log(" MERGE CALLBACK - New whenNotToApply string:",i),p((function(e){console.log(" MERGE CALLBACK - Previous formDataState for WNTA:",e);var t=M(M({},e),{whenNotToApply:i,_mergeUpdate:!0,_mergeWNTA:a});return console.log(" MERGE CALLBACK - New formDataState for WNTA:",t),t}))),We((function(e){var t=new Set(e);return n.forEach((function(e){return t.add(e)})),console.log("Added merged learning IDs to tracking set:",Array.from(t)),t})),l=0,s=n,z.label=2;case 2:return l<s.length?(h=s[l],console.log("Sending delete request for merged learning ID: ".concat(h)),u={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:h,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(h),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},[4,g7({baseUrl:d,organizationName:o,chatAssistantName:q,payload:u})]):[3,5];case 3:(v=z.sent()).ok?console.log("Successfully deleted merged learning ID ".concat(h)):console.error("Failed to delete merged learning ID ".concat(h,":"),v.statusText),z.label=4;case 4:return l++,[3,2];case 5:return[3,8];case 6:return f=z.sent(),console.error("Error processing merge operation:",f),[3,8];case 7:return console.log("switched off"),$(!1),[7];case 8:return[2]}}))}))}),[N,We,p,$]),tt=function(e,t,n){return h((function(){for(var r,a=[],o=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,c=/['"]is_valid['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflictingConditions['"]\s*:\s*\[\s*(?:\{[\s\S]*?['"]conflictType['"]\s*:\s*['"][^'"]+['"][\s\S]*?\}\s*,?\s*)*\]\s*,\s*['"]save['"]\s*:\s*(true|false|True|False)/,i=/['"]is_valid_db['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflicting_learnings['"]\s*:\s*\{[\s\S]*?\}\s*,\s*['"]similar_learnings['"]\s*:\s*\{[\s\S]*?\}\s*,\s*["']save["']\s*:\s*(true|false|True|False)/,l=/['"]delete_current_learning['"]\s*:\s*(true|false|True|False)\s*,\s*['"]deleted_similar_learning_ids['"]\s*:\s*\[[\s\S]*?\]\s*,\s*['"]deleted_conflicting_learning_ids['"]\s*:\s*\[[\s\S]*?\]/,s=/{\s*['"]merge_learnings['"]\s*:\s*(?:True|true)[\s\S]+?}/,h=/({[\s\S]*}|\[[\s\S]*\])/,d=0,u=(null===(r=e[e.length-1])||void 0===r?void 0:r.orchestratorAndAgentsMessages)||[];d<u.length;d++){var m=u[d],p=(null==m?void 0:m.responsedata)||"";console.log("🔍 RESPONSE DATA:",String(p)),String(p).includes("merge_learnings")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(p))),String(p).includes("'merge_learnings'")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(p)));var v=p.match(o);if(v)try{var f=q8.parse("{".concat(v[0],"}"));a.push(f)}catch(e){console.error("Failed to parse JSON:",e)}var z=p.match(c);if(console.log("validationObj before cond "),z)try{var g=z7(z[0]||""),y=q8.parse("{".concat(g,"}"));console.log("validationObj before set ",y),S(y),console.log("validationObj after set in chat",x)}catch(e){console.error("Failed to parse validation JSON:",e)}try{var M=z7(p||""),E=q8.parse(M);if(E&&"object"==typeof E&&"is_valid_db"in E&&"conflicting_learnings"in E&&"similar_learnings"in E)console.log("Found validation data in response:",E),O(E),console.log("dbVal after set in chat",T);else if(V=p.match(i)){var b=z7(V[0]||""),H=q8.parse("{".concat(b,"}"));O(H),console.log("dbVal after set in chat (regex fallback)",T)}}catch(e){var V;if(console.log("JSON parsing failed, trying regex fallback for validation data"),V=p.match(i))try{b=z7(V[0]||""),H=q8.parse("{".concat(b,"}"));O(H),console.log("dbVal after set in chat (regex fallback)",T)}catch(e){console.error("Failed to parse validation JSON with regex fallback:",e)}}var C=p.match(l);if(C)try{var L=z7(C[0]||""),w=q8.parse("{".concat(L,"}"));console.log("Delete tool detected:",w),t&&t(w)}catch(e){console.error("Failed to parse delete tool JSON:",e)}console.log("🔍 Testing merge tool regex on response data...");var k=p.match(s);if(console.log("🔍 Merge tool regex match result:",k),k){console.log("🔍 MERGE TOOL REGEX MATCHED!");try{var A=z7(k[0]),R=q8.parse(A);console.log("✅ Correctly parsed merge tool object:",R),n&&n(R)}catch(e){console.error("Failed to parse merge tool JSON:",e)}}var N=p.match(h);if(N&&p.includes("edit_actions"))try{console.log("Edit tool match found:",N[0]);A=z7(N[0]);var _=q8.parse(A);console.log("Edit tool detected and parsed successfully:",_),_.conflicting_learnings&&(B(_.conflicting_learnings),console.log("Setting edit conflicting learning trigger:",_.conflicting_learnings)),_.similar_learnings&&(j(_.similar_learnings),console.log("Setting edit similar learning trigger:",_.similar_learnings))}catch(e){console.error("Failed to parse edit tool JSON:",e)}}return a}),[e,t])}(he,Ze,et);s((function(){var e=(null==tt?void 0:tt[(null==tt?void 0:tt.length)-1])||null;e&&(u(e),console.log("Parsed suggestions:",tt))}),[tt]),s((function(){if(T&&0!==Ie.size){var e=T.conflicting_learnings&&Object.values(T.conflicting_learnings).some((function(e){return Ie.has(e.id)})),t=T.similar_learnings&&Object.values(T.similar_learnings).some((function(e){return Ie.has(e.id)}));if(e||t){var n=JSON.stringify({deletedIds:Array.from(Ie).sort()});if($e.current!==n){var r=M({},T);if(r.conflicting_learnings){var a=Object.values(r.conflicting_learnings).filter((function(e){return!Ie.has(e.id)}));console.log("[ChatComponent] Re-keying conflicting learnings:",{originalKeys:Object.keys(r.conflicting_learnings),remainingCount:a.length,remainingLearnings:a.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var o={};a.forEach((function(e,t){var n=String.fromCharCode(65+t);o[n]=e,console.log("[ChatComponent] Conflicting learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),r.conflicting_learnings=o,console.log("[ChatComponent] Final conflicting learnings keys:",Object.keys(o))}if(r.similar_learnings){var c=Object.values(r.similar_learnings).filter((function(e){return!Ie.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings:",{originalKeys:Object.keys(r.similar_learnings),remainingCount:c.length,remainingLearnings:c.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var i={};c.forEach((function(e,t){var n=String.fromCharCode(65+t);i[n]=e,console.log("[ChatComponent] Similar learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),r.similar_learnings=i,console.log("[ChatComponent] Final similar learnings keys:",Object.keys(i))}$e.current=n,console.log("Filtered learningWtaResponse after deletion:",r),O(r)}}}}),[Ie,T,O]),s((function(){if(T&&0!==Ue.size&&(T.similar_learnings&&Object.values(T.similar_learnings).some((function(e){return Ue.has(e.id)})))){var e=JSON.stringify({mergedIds:Array.from(Ue).sort()});if(qe.current!==e){var t=M({},T);if(t.similar_learnings){var n=Object.values(t.similar_learnings).filter((function(e){return!Ue.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings after merge:",{originalKeys:Object.keys(t.similar_learnings),remainingCount:n.length,remainingLearnings:n.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var r={};n.forEach((function(e,t){var n=String.fromCharCode(65+t);r[n]=e,console.log("[ChatComponent] Similar learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),t.similar_learnings=r,console.log("[ChatComponent] Final similar learnings keys after merge:",Object.keys(r))}qe.current=e,console.log("Filtered learningWtaResponse after merge:",t),O(t)}}}),[Ue,T,O]);var nt=function(e){return h((function(){for(var t,n=[],r=/['"](\w+)['"]\s*:\s*['"](.*?)['"]/g,a=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];a<o.length;a++){var c=o[a],i=((null==c?void 0:c.responsedata)||"").match(r);if(i)try{var l=q8.parse("{".concat(i[0],"}"));n.push(l)}catch(e){console.error("Failed to parse JSON for header message:",e)}}return n}),[e])}(he);s((function(){var e=(null==nt?void 0:nt[(null==nt?void 0:nt.length)-1])||null;e&&y(e.modification)}),[nt]);!function(e,t){s((function(){for(var n,r=0,a=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];r<a.length;r++){for(var o=a[r],c=(null==o?void 0:o.responsedata)||"",i=/<wta>([\s\S]*?)<\/wta>/gi,l=[],s=void 0;null!==(s=i.exec(c));)console.log("match wta suggestion",s),l.push(s[1]);l.length&&t(l)}}),[e,t])}(he,Pe);var rt=function(e){return h((function(){for(var t,n=[],r=/^\{\s*(['"])(\w+)\1\s*:\s*(['"])(.*?)\3\s*\}$/,a=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];a<o.length;a++){var c=o[a],i=((null==c?void 0:c.responsedata)||"").match(r);if(i){console.log("match: ",i[0]);try{var l=q8.parse(i[0]);n.push(l)}catch(e){console.error("Failed to parse JSON:",e)}}}return n}),[e])}(he);s((function(){var e=(null==rt?void 0:rt[(null==rt?void 0:rt.length)-1])||null;e&&(console.log("latestParseTooltip: ",e),L(null==e?void 0:e.tooltip))}),[rt]);var at=function(e){var t=c([]),n=t[0],r=t[1];return s((function(){for(var t,n=[],a=/\{\s*['"]save['"]\s*:\s*(True|False|true|false)\s*\}/,o=0,c=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];o<c.length;o++){var i=c[o],l=((null==i?void 0:i.responsedata)||"").match(a);if(l)try{var s=l[0].replace(/\bTrue\b/,"true").replace(/\bFalse\b/,"false").replace(/'/g,'"');console.log("corrected:",s);var h=q8.parse(s);!0===h.save&&k(!0),n.push(h)}catch(e){console.error("Failed to parse JSON:",e)}}r(n)}),[e]),n}(he);s((function(){var e=(null==at?void 0:at[(null==at?void 0:at.length)-1])||null;if(e&&"boolean"==typeof e.save){w(!0);var t=setTimeout((function(){w(!1),C(e.save)}),200);return function(){clearTimeout(t)}}}),[at]),s((function(){A&&(ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save it"),R(!1))}),[A]),s((function(){if(_&&N){var e="Delete learning ".concat(_);ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,e),D&&D(null)}}),[_,N,D]),s((function(){U&&(ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,U),W(""))}),[U]),s((function(){ct(),it();var e=function(){var e,t=(null===(e=null==Ke?void 0:Ke.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px");Je(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var ot=l((function(){var e=X.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),_e(!1)}),100)}),[]);s((function(){(null==Z?void 0:Z.length)>0&&ot()}),[Z]);var ct=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(K,"/api/chatbot/getChatSettings?name=").concat(q,"&organizationName=").concat(o),headers:{}};Sk.request(e).then((function(e){var t,n,r;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(r=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===r?void 0:r.chatInitialMessage)&&be(!0)})).catch((function(e){console.error(e)}))},it=function(){return b(void 0,void 0,void 0,(function(){var e,t;return H(this,(function(n){e="".concat(K,"/api/chat/history?name=").concat(q,"&organizationName=").concat(o);try{t={method:"GET",params:{guestSessionId:G.current},withCredentials:!0},Sk.get(e,t).then((function(e){var t=e.data;t.length>0?(de(t),ot()):be(!0)})).catch((function(e){console.error(e)}))}catch(e){pe(!1),console.error(e)}return[2]}))}))};function lt(e){var t=null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,(function(e){return null==e?void 0:e.replace(/\*/g,"&ast;")}));return t}var st=function(e,t,n,r,a,o){var c,i,l,s,h,d,u,m,p,v,f,z,g,y,E,b,H,C;console.log("userInput: ",a);var L={role:"assistant",content:"",id:N8()};if(null===(s=null===(l=null===(i=null===(c=null==e?void 0:e.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===i?void 0:i.message)||void 0===l?void 0:l.content)||void 0===s?void 0:s.includes("WaitMessage: "))pe(!1),fe(!0),L.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var r=e.substring(n+13);return null==r?void 0:r.replaceAll("WaitMessage: ","")}return""}((null===(u=null===(d=null===(h=null==e?void 0:e.chatStream)||void 0===h?void 0:h.continueChatResult)||void 0===d?void 0:d.message)||void 0===u?void 0:u.content)+"\n\n"),de(V(V([],he,!0),[{role:"user",content:a,time:r,isFirstQuestionSent:o||!1,id:(null===(p=null===(m=null==e?void 0:e.chatStream)||void 0===m?void 0:m.continueChatResult)||void 0===p?void 0:p.requestId)||"",reply:""},L],!1));else{pe(!1),fe(!1),L.content=null===(g=lt(null===(z=null===(f=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===f?void 0:f.message)||void 0===z?void 0:z.content))||void 0===g?void 0:g.replaceAll("WaitMessage: ","");var w=function(e,t,n){var r,a,o,c,i,l,s,h,d,u,m,p,v,f,z,g,y,E,b,H,C,L,w,k,x,S,T,O,A,R,N,_,D,P,F,I,B,j,U,W,$,q,G,Y,K,X,Q,J,Z,ee,te,ne,re,ae,oe,ce,ie,le,se,he,de,ue,me,pe,ve,fe,ze,ge,ye,Me,Ee,be,He,Ve,Ce,Le,we,ke,xe,Se,Te,Oe,Ae,Re,Ne,_e,De,Pe,Fe,Ie,Be,je,Ue,We,$e,qe,Ge,Ye,Ke,Xe,Qe,Je,Ze,et,tt,nt,rt,at,ot,ct,it,st,ht,dt,ut,mt,pt,vt,ft,zt,gt,yt,Mt,Et,bt,Ht,Vt,Ct,Lt,wt,kt,xt,St,Tt,Ot,At,Rt,Nt,_t,Dt,Pt,Ft,It,Bt,jt,Ut,Wt,$t,qt,Gt,Yt,Kt,Xt,Qt,Jt,Zt,en,tn,nn,rn,an,on,cn,ln,sn,hn,dn,un,mn,pn;console.log("event",e,Object.keys(e)),console.log("content: ",null==e?void 0:e.data);var vn={role:"assistant",content:"",id:N8()};if(!1===(null===(o=null===(a=null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.chatStream)||void 0===a?void 0:a.continueChatResult)||void 0===o?void 0:o.thinking_break)&&!0===(null===(l=null===(i=null===(c=null==e?void 0:e.data)||void 0===c?void 0:c.chatStream)||void 0===i?void 0:i.continueChatResult)||void 0===l?void 0:l.is_orchestrator)&&!1===(null===(d=null===(h=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.chatStream)||void 0===h?void 0:h.continueChatResult)||void 0===d?void 0:d.isEnd)&&(vn.content=null===(f=lt(null===(v=null===(p=null===(m=null===(u=null==e?void 0:e.data)||void 0===u?void 0:u.chatStream)||void 0===m?void 0:m.continueChatResult)||void 0===p?void 0:p.message)||void 0===v?void 0:v.content))||void 0===f?void 0:f.replaceAll("WaitMessage: ","")),!0===(null===(y=null===(g=null===(z=null==e?void 0:e.data)||void 0===z?void 0:z.chatStream)||void 0===g?void 0:g.continueChatResult)||void 0===y?void 0:y.thinking_break)&&!0===(null===(H=null===(b=null===(E=null==e?void 0:e.data)||void 0===E?void 0:E.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===H?void 0:H.is_orchestrator)&&!1===(null===(w=null===(L=null===(C=null==e?void 0:e.data)||void 0===C?void 0:C.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===w?void 0:w.isEnd)&&(vn.content="",t.push({responsedata:null===(T=null===(S=null===(x=null===(k=null==e?void 0:e.data)||void 0===k?void 0:k.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===S?void 0:S.message)||void 0===T?void 0:T.content,responseFrom:null===(R=null===(A=null===(O=null==e?void 0:e.data)||void 0===O?void 0:O.chatStream)||void 0===A?void 0:A.continueChatResult)||void 0===R?void 0:R.responded_by,header_message:null===(D=null===(_=null===(N=null==e?void 0:e.data)||void 0===N?void 0:N.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===D?void 0:D.header_message,finalResponseStatus:!1,explainability_id:null!==(B=null===(I=null===(F=null===(P=null==e?void 0:e.data)||void 0===P?void 0:P.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===I?void 0:I.explainability_id)&&void 0!==B?B:"",isParallelToolResponse:!1})),!1===(null===(W=null===(U=null===(j=null==e?void 0:e.data)||void 0===j?void 0:j.chatStream)||void 0===U?void 0:U.continueChatResult)||void 0===W?void 0:W.thinking_break)&&!0===(null===(G=null===(q=null===($=null==e?void 0:e.data)||void 0===$?void 0:$.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===G?void 0:G.is_orchestrator)&&!0===(null===(X=null===(K=null===(Y=null==e?void 0:e.data)||void 0===Y?void 0:Y.chatStream)||void 0===K?void 0:K.continueChatResult)||void 0===X?void 0:X.isEnd)&&(vn.content=null===(te=lt(null===(ee=null===(Z=null===(J=null===(Q=null==e?void 0:e.data)||void 0===Q?void 0:Q.chatStream)||void 0===J?void 0:J.continueChatResult)||void 0===Z?void 0:Z.message)||void 0===ee?void 0:ee.content))||void 0===te?void 0:te.replaceAll("WaitMessage: ","")),!1===(null===(ae=null===(re=null===(ne=null==e?void 0:e.data)||void 0===ne?void 0:ne.chatStream)||void 0===re?void 0:re.continueChatResult)||void 0===ae?void 0:ae.thinking_break)&&!1===(null===(ie=null===(ce=null===(oe=null==e?void 0:e.data)||void 0===oe?void 0:oe.chatStream)||void 0===ce?void 0:ce.continueChatResult)||void 0===ie?void 0:ie.is_orchestrator)&&!1===(null===(he=null===(se=null===(le=null==e?void 0:e.data)||void 0===le?void 0:le.chatStream)||void 0===se?void 0:se.continueChatResult)||void 0===he?void 0:he.isEnd)){if((gn=null===(ue=null===(de=null==e?void 0:e.data)||void 0===de?void 0:de.chatStream)||void 0===ue?void 0:ue.continueChatResult).explainability_id&&gn.responded_by){var fn=gn.explainability_id,zn=gn.responded_by;n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})}n.has(null===(pe=null===(me=null==e?void 0:e.data)||void 0===me?void 0:me.chatStream)||void 0===pe?void 0:pe.continueChatResult.explainability_id)?t[Hn=null==(yn=n.get(null===(ze=null===(fe=null===(ve=null==e?void 0:e.data)||void 0===ve?void 0:ve.chatStream)||void 0===fe?void 0:fe.continueChatResult)||void 0===ze?void 0:ze.explainability_id))?void 0:yn.index]={responsedata:null===(Ee=null===(Me=null===(ye=null===(ge=null==e?void 0:e.data)||void 0===ge?void 0:ge.chatStream)||void 0===ye?void 0:ye.continueChatResult)||void 0===Me?void 0:Me.message)||void 0===Ee?void 0:Ee.content,responseFrom:null===(Ve=null===(He=null===(be=null==e?void 0:e.data)||void 0===be?void 0:be.chatStream)||void 0===He?void 0:He.continueChatResult)||void 0===Ve?void 0:Ve.responded_by,header_message:null===(we=null===(Le=null===(Ce=null==e?void 0:e.data)||void 0===Ce?void 0:Ce.chatStream)||void 0===Le?void 0:Le.continueChatResult)||void 0===we?void 0:we.header_message,finalResponseStatus:!0,explainability_id:null!==(Te=null===(Se=null===(xe=null===(ke=null==e?void 0:e.data)||void 0===ke?void 0:ke.chatStream)||void 0===xe?void 0:xe.continueChatResult)||void 0===Se?void 0:Se.explainability_id)&&void 0!==Te?Te:"",isParallelToolResponse:!0}:t=V(V([],t,!0),[{responsedata:null===(Ne=null===(Re=null===(Ae=null===(Oe=null==e?void 0:e.data)||void 0===Oe?void 0:Oe.chatStream)||void 0===Ae?void 0:Ae.continueChatResult)||void 0===Re?void 0:Re.message)||void 0===Ne?void 0:Ne.content,responseFrom:null===(Pe=null===(De=null===(_e=null==e?void 0:e.data)||void 0===_e?void 0:_e.chatStream)||void 0===De?void 0:De.continueChatResult)||void 0===Pe?void 0:Pe.responded_by,header_message:null===(Be=null===(Ie=null===(Fe=null==e?void 0:e.data)||void 0===Fe?void 0:Fe.chatStream)||void 0===Ie?void 0:Ie.continueChatResult)||void 0===Be?void 0:Be.header_message,finalResponseStatus:!0,explainability_id:null!==($e=null===(We=null===(Ue=null===(je=null==e?void 0:e.data)||void 0===je?void 0:je.chatStream)||void 0===Ue?void 0:Ue.continueChatResult)||void 0===We?void 0:We.explainability_id)&&void 0!==$e?$e:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(Ye=null===(Ge=null===(qe=null==e?void 0:e.data)||void 0===qe?void 0:qe.chatStream)||void 0===Ge?void 0:Ge.continueChatResult)||void 0===Ye?void 0:Ye.thinking_break)&&!1===(null===(Qe=null===(Xe=null===(Ke=null==e?void 0:e.data)||void 0===Ke?void 0:Ke.chatStream)||void 0===Xe?void 0:Xe.continueChatResult)||void 0===Qe?void 0:Qe.is_orchestrator)&&!1===(null===(et=null===(Ze=null===(Je=null==e?void 0:e.data)||void 0===Je?void 0:Je.chatStream)||void 0===Ze?void 0:Ze.continueChatResult)||void 0===et?void 0:et.isEnd)){var gn,yn;(gn=null===(nt=null===(tt=null==e?void 0:e.data)||void 0===tt?void 0:tt.chatStream)||void 0===nt?void 0:nt.continueChatResult).explainability_id&&gn.responded_by&&(fn=gn.explainability_id,zn=gn.responded_by,n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})),n.has(null===(ot=null===(at=null===(rt=null==e?void 0:e.data)||void 0===rt?void 0:rt.chatStream)||void 0===at?void 0:at.continueChatResult)||void 0===ot?void 0:ot.explainability_id)?t[Hn=null==(yn=n.get(null===(st=null===(it=null===(ct=null==e?void 0:e.data)||void 0===ct?void 0:ct.chatStream)||void 0===it?void 0:it.continueChatResult)||void 0===st?void 0:st.explainability_id))?void 0:yn.index]={responsedata:null===(mt=null===(ut=null===(dt=null===(ht=null==e?void 0:e.data)||void 0===ht?void 0:ht.chatStream)||void 0===dt?void 0:dt.continueChatResult)||void 0===ut?void 0:ut.message)||void 0===mt?void 0:mt.content,responseFrom:null===(ft=null===(vt=null===(pt=null==e?void 0:e.data)||void 0===pt?void 0:pt.chatStream)||void 0===vt?void 0:vt.continueChatResult)||void 0===ft?void 0:ft.responded_by,header_message:null===(yt=null===(gt=null===(zt=null==e?void 0:e.data)||void 0===zt?void 0:zt.chatStream)||void 0===gt?void 0:gt.continueChatResult)||void 0===yt?void 0:yt.header_message,finalResponseStatus:!1,explainability_id:null!==(Ht=null===(bt=null===(Et=null===(Mt=null==e?void 0:e.data)||void 0===Mt?void 0:Mt.chatStream)||void 0===Et?void 0:Et.continueChatResult)||void 0===bt?void 0:bt.explainability_id)&&void 0!==Ht?Ht:"",isParallelToolResponse:!0}:t.push({responsedata:null===(wt=null===(Lt=null===(Ct=null===(Vt=null==e?void 0:e.data)||void 0===Vt?void 0:Vt.chatStream)||void 0===Ct?void 0:Ct.continueChatResult)||void 0===Lt?void 0:Lt.message)||void 0===wt?void 0:wt.content,responseFrom:null===(St=null===(xt=null===(kt=null==e?void 0:e.data)||void 0===kt?void 0:kt.chatStream)||void 0===xt?void 0:xt.continueChatResult)||void 0===St?void 0:St.responded_by,header_message:null===(At=null===(Ot=null===(Tt=null==e?void 0:e.data)||void 0===Tt?void 0:Tt.chatStream)||void 0===Ot?void 0:Ot.continueChatResult)||void 0===At?void 0:At.header_message,finalResponseStatus:!1,explainability_id:null!==(Dt=null===(_t=null===(Nt=null===(Rt=null==e?void 0:e.data)||void 0===Rt?void 0:Rt.chatStream)||void 0===Nt?void 0:Nt.continueChatResult)||void 0===_t?void 0:_t.explainability_id)&&void 0!==Dt?Dt:"",isParallelToolResponse:!1})}var Mn=null===(Bt=null===(It=null===(Ft=null===(Pt=null==e?void 0:e.data)||void 0===Pt?void 0:Pt.chatStream)||void 0===Ft?void 0:Ft.continueChatResult)||void 0===It?void 0:It.message)||void 0===Bt?void 0:Bt.annotations,En=(null===($t=null===(Wt=null===(Ut=null===(jt=null==e?void 0:e.data)||void 0===jt?void 0:jt.chatStream)||void 0===Ut?void 0:Ut.continueChatResult)||void 0===Wt?void 0:Wt.message)||void 0===$t?void 0:$t.userFeedbackId)||"",bn={role:"assistant",content:vn.content,orchestratorAndAgentsMessages:t,time:new Date,requestId:null!==(Kt=null===(Yt=null===(Gt=null===(qt=null==e?void 0:e.data)||void 0===qt?void 0:qt.chatStream)||void 0===Gt?void 0:Gt.continueChatResult)||void 0===Yt?void 0:Yt.requestId)&&void 0!==Kt?Kt:"",citations:null===(Zt=null===(Jt=null===(Qt=null===(Xt=null==e?void 0:e.data)||void 0===Xt?void 0:Xt.chatStream)||void 0===Qt?void 0:Qt.continueChatResult)||void 0===Jt?void 0:Jt.message)||void 0===Zt?void 0:Zt.citations,guides_utilized:null!==(an=null===(rn=null===(nn=null===(tn=null===(en=null==e?void 0:e.data)||void 0===en?void 0:en.chatStream)||void 0===tn?void 0:tn.continueChatResult)||void 0===nn?void 0:nn.message)||void 0===rn?void 0:rn.guides_utilized)&&void 0!==an?an:[],annotations:Mn,resourceId:null===(ln=null===(cn=null===(on=null==e?void 0:e.data)||void 0===on?void 0:on.chatStream)||void 0===cn?void 0:cn.continueChatResult)||void 0===ln?void 0:ln.resourceId,userFeedbackId:En,citationDisplayType:null!==(mn=null===(un=null===(dn=null===(hn=null===(sn=null==e?void 0:e.data)||void 0===sn?void 0:sn.chatStream)||void 0===hn?void 0:hn.continueChatResult)||void 0===dn?void 0:dn.message)||void 0===un?void 0:un.citationDisplayType)&&void 0!==mn?mn:""};if(Mn)for(var Hn=0;Hn<(null==Mn?void 0:Mn.length);Hn++){var Vn=Mn[Hn];bn=M(M({},bn),{content:null===(pn=null==bn?void 0:bn.content)||void 0===pn?void 0:pn.replace(null==Vn?void 0:Vn.text,(null==Vn?void 0:Vn.text)+"<sup>".concat(Hn,"</sup>"))})}return bn}({data:e},n,t);console.log("assistantObject",w),de(V(V([],he,!0),[{role:"user",content:a||"",time:r,isFirstQuestionSent:o||!1,requestId:null!==(b=null===(E=null===(y=null==e?void 0:e.chatStream)||void 0===y?void 0:y.continueChatResult)||void 0===E?void 0:E.requestId)&&void 0!==b?b:""},w],!1)),ye(null===(C=null===(H=null==e?void 0:e.chatStream)||void 0===H?void 0:H.continueChatResult)||void 0===C?void 0:C.isEnd)}},ht=function(e,t,n){var r,a,c,i,l,s,h,d=(null==n?void 0:n.trim())||(null==ae?void 0:ae.trim())||"";if(!("Enter"!==e.key||e.shiftKey||""===(null==n?void 0:n.trim())&&""===(null==ae?void 0:ae.trim())||xe)){Se(!0);var u=new Date;de(V(V([],he.map((function(e,t){var n;return M(M({},e),{content:null===(n=lt(e.content))||void 0===n?void 0:n.replace("WaitMessage: ","")})})),!0),[{role:"user",content:d,time:u,isFirstQuestionSent:!1}],!1));var p=new Map,v=[];ne(!1);var z={WEBSOCKET_URL:f,organizationName:o,chatAssistantName:q,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:(null==n?void 0:n.trim())||(null==ae?void 0:ae.trim())||"",requestId:"requestId-".concat(N8()),customPrompt:"",enableForBackend:!1,guestSessionId:G.current,chatPreviewId:Y.current,customMetaData:M(M({},m),{whenToApply:null===(a=null===(r=null==m?void 0:m.whenToApply)||void 0===r?void 0:r.split(" OR "))||void 0===a?void 0:a.filter((function(e){return""!==e})),whenNotToApply:null===(i=null===(c=null==m?void 0:m.whenNotToApply)||void 0===c?void 0:c.split(" OR "))||void 0===i?void 0:i.filter((function(e){return""!==e})),isFirstQuestion:0===he.length,validation:null!=x?x:null,conflicting_learnings:null!==(l=null==T?void 0:T.conflicting_learnings)&&void 0!==l?l:"",similar_learnings:null!==(s=null==T?void 0:T.similar_learnings)&&void 0!==s?s:""}),customMetaDataDebug:{conflicting_learnings_keys:(null==T?void 0:T.conflicting_learnings)?Object.keys(T.conflicting_learnings):[],similar_learnings_keys:(null==T?void 0:T.similar_learnings)?Object.keys(T.similar_learnings):[],conflicting_count:(null==T?void 0:T.conflicting_learnings)?Object.keys(T.conflicting_learnings).length:0,similar_count:(null==T?void 0:T.similar_learnings)?Object.keys(T.similar_learnings).length:0},aiModel:"",onStreamEvent:function(e){return st(e,p,v,u,d,t)},onStreamEnd:function(e){Se(!1)},onError:function(e){return console.error("Stream error:",e)}};if(""!==(null==ae?void 0:ae.trim())||(null==n?void 0:n.trim())){pe(!0),null===(h=Q.current)||void 0===h||h.blur(),oe(""),ot();for(var g="Thanks for sharing your thoughts. I'm putting together the most helpful suggestions now, so we can make sure this really fits your needs.".split(" "),y="",E=function(e){setTimeout((function(){y+=g[e]+" ",we(y.trim())}),25*e)},b=0;b<g.length;b++)E(b);S8.startChatStream(z)}}},dt=i(new Set);return s((function(){if(P&&!xe){if(dt.current.has(P))return void console.log("[ChatComponent] ⚠️ Duplicate merge trigger ignored:",P);console.log("[ChatComponent] 🔴 MERGE TRIGGER RECEIVED:",P),dt.current.add(P);var e=null,t="A";if(null==T?void 0:T.similar_learnings){var n=Object.values(T.similar_learnings),r=n.findIndex((function(e){return(null==e?void 0:e.id)===P}));-1!==r&&(e=n[r],t=String.fromCharCode(65+r))}if(e){var a="Merge Similar Learning ".concat(t," with current learning");console.log("[ChatComponent] ✅ Sending merge message to chat:",a),ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,a),console.log("[ChatComponent] Message sent successfully")}else console.log("[ChatComponent] ❌ Learning not found for ID:",P);F&&(F(null),console.log("[ChatComponent] Trigger cleared"))}else P&&xe&&console.log("[ChatComponent] ⚠️ Merge trigger received but streaming in progress:",P)}),[P,xe,F]),h((function(){return{img:function(e){e.node;var t=E(e,["node"]);return n("img",M({},t,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==t?void 0:t.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var t=E(e,["node"]);return n("p",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==t?void 0:t.children}))},code:function(e){e.node;var t=E(e,["node"]);return n("span",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==t?void 0:t.children}))},ol:function(e){e.node;var t=E(e,["node"]);return n("ol",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==t?void 0:t.children}))},ul:function(e){e.node;var t=E(e,["node"]);return n("ul",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==t?void 0:t.children}))},wta:function(e){e.node;var t=E(e,["node"]);t.key||t["data-key"];var r=t.label||t.children||"Unknown label";return n(V7,{label:r,onToggle:function(e,t){!function(e,t){var n=Array.isArray(e)?e[0]:e;null==Z||Z.length,ne(!0),ee((function(e){return t?e.includes(n)?e:V(V([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}(e,t)}})}}}),[]),e("div",M({className:j8,style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#fbfaff",border:"1px solid #d1d5db",overflow:"hidden"}},{children:[e("div",M({style:{width:"100%",height:"100%",backgroundColor:"#fbfaff",maxWidth:"100%",overflow:"hidden"}},{children:[n("div",M({ref:Ke},{children:n(b7,{resetChatHistory:function(){var e="".concat(K,"/api/chat/resetHistory?name=").concat(q,"&organizationName=").concat(o);S(null),O(null);try{var t={method:"GET",params:{guestSessionId:G.current},withCredentials:!0};Sk.get(e,t).then((function(){y(""),L(""),z(!0),ne(!1),ee([]),Ve(""),Be(new Set),$e.current="",Ge.current.clear(),dt.current.clear(),F&&F(null),Y.current="".concat(N8()),v(!1),de([]),be(!0),I?(console.log("[ChatComponent] 🔄 Calling onResetLearningData callback"),I()):console.log("[ChatComponent] ❌ onResetLearningData callback not available"),p((function(e){return M(M({},e),{modification:"",tooltip:"",whenToApply:"",whenNotToApply:"",isTooltipEnabled:!1,isModificationEnabled:!0})}))})).catch((function(e){console.error(e)}))}catch(e){pe(!1),console.error(e)}},isStreamEnd:ge})})),e("div",M({style:{width:"100%",height:Qe,maxHeight:Qe,overflowY:"auto",backgroundColor:"#fbfaff"},ref:X},{children:[n("div",M({className:"welcome-message",style:{alignItems:"flex-start",paddingLeft:"0.5rem",paddingTop:"1rem",maxWidth:"70%",fontSize:"1rem",lineHeight:"1.75rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333",fontWeight:"700",textAlign:"left"}},{children:n("span",{children:"I'm here to help fine-tune your learning so it works as accurately as it should."})})),e("div",M({style:{display:"flex",flexDirection:"row",fontFamily:"inherit",padding:"16px 10px 0px 16px",maxWidth:"80%"}},{children:[n("div",M({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.3rem"}},{children:e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),n("div",M({style:{display:"flex",flexDirection:"column",fontWeight:400,color:"#000"}},{children:n("div",M({style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:n("span",{children:n(vM,M({components:{p:function(e){e.node;var t=E(e,["node"]);return n("p",M({},t,{style:{margin:0}},{children:null==t?void 0:t.children}))}}},{children:ie}))})}))}))]})),he.length?he.map((function(t,r){return e("div",M({style:{display:"flex",padding:"0.5rem 1rem",maxWidth:"100%"}},{children:["assistant"==(null==t?void 0:t.role)&&n("div",M({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.5rem",marginRight:"1rem"}},{children:e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),e("div",M({style:{width:"100%"}},{children:["assistant"===t.role&&t.orchestratorAndAgentsMessages&&t.orchestratorAndAgentsMessages.length>0&&n(I8,{orchestratorAndAgentsMessages:null==t?void 0:t.orchestratorAndAgentsMessages,isStreamEnd:ge,isCurrentMessage:r===he.length-1,ThinkingBulbIconComponent:g}),"assistant"===(null==t?void 0:t.role)?n(f7,{index:r,content:null==t?void 0:t.content,messages:he,handleStream:ht}):n("span",{}),n("div",M({style:{display:"flex",justifyContent:"flex-end"}},{children:"user"===t.role?n("div",M({style:{backgroundColor:"#8694A10D",padding:"0 1rem",borderRadius:"8px",maxWidth:"80%"}},{children:n(f7,{index:r,content:null==t?void 0:t.content,messages:he,handleStream:ht,scrollToBottom:ot})})):n("span",{})}))]}))]}))})):Ee&&n(t,{}),me&&e("div",M({style:{display:"flex",padding:"16px 16px 0px 16px"}},{children:[n("div",M({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.2rem"}},{children:e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),n("div",M({style:{display:"inline-flex",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",paddingBottom:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:n("span",{children:Le})}))]}))]}))]})),e("div",M({style:{width:"95%",height:"content-fit",backgroundColor:"#fbfaff",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"end",position:"relative"}},{children:[n("div",M({style:{visibility:Ne?"visible":"hidden",position:"absolute",top:"-3rem",zIndex:0,pointerEvents:"none"}},{children:n("button",M({onClick:ot,style:{borderRadius:"9999px",padding:0,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:"1px solid #d1d5db",pointerEvents:"auto",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1,height:"2.25rem",width:"2.25rem",margin:"0.3rem"}},{children:n("svg",M({fill:"#000000",width:"16px",height:"16px",viewBox:"0 0 24 24",id:"down","data-name":"Flat Color",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{id:"primary",d:"M19.71,13.29a1,1,0,0,0-1.42,0L13,18.59V3a1,1,0,0,0-2,0V18.59l-5.29-5.3a1,1,0,0,0-1.42,1.42l7,7a1,1,0,0,0,1.42,0l7-7A1,1,0,0,0,19.71,13.29Z"})}))}))})),n("div",M({style:{width:"100%",backgroundColor:"#fff",display:"flex",alignItems:"end",gap:"0.5rem",border:"1px solid #E5E7EB",borderRadius:"8px"}},{children:e("div",M({style:{width:"100%",display:"flex"}},{children:[n("textarea",{ref:Q,placeholder:"Tell me more about this learning...",value:ae||"",onChange:function(e){return oe(e.target.value)},onFocus:function(){return Ae(!0)},onBlur:function(){return Ae(!1)},onKeyDown:function(e){return ht(e)},style:{flexGrow:1,padding:"0.5rem",borderRadius:"0.5rem",border:"none",fontSize:"1rem",lineHeight:"1.5rem",resize:"none",backgroundColor:"#fff",color:"inherit",minHeight:Oe?"120px":"50px",height:Oe?"120px":"50px",maxHeight:"120px",overflowY:"auto",fontFamily:"inherit",outline:"none",transition:"min-height 0.3s ease, background-color 0.3s ease",boxSizing:"border-box"}}),e("span",M({style:{display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"end"}},{children:[" ",n("button",M({onClick:function(e){ht(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:Ye,style:{padding:"0.5rem 0.75rem",borderRadius:"0.375rem",border:"none",backgroundColor:"white",color:Ye?"#d1d5db":"#5928ed",fontWeight:"bold",fontSize:"1rem",cursor:Ye?"not-allowed":"pointer",transition:"background-color 0.3s, color 0.3s",height:"50px"}},{children:n(E7,{})}))]}))]}))}))]})),e("div",M({style:{width:"95%",display:"flex",gap:"0.25rem",flexDirection:"row"}},{children:[n(LJ,M({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n("span",M({style:{width:"50%"}},{children:n(u7,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),n(LJ,M({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n("span",M({style:{width:"50%"}},{children:n(u7,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))},L7={},w7={exports:{}},k7={exports:{}};function x7(){return y7||(y7=1,function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(k7)),k7.exports}function S7(){return M7||(M7=1,function(e){var t=x7().default;function n(r,a){if("function"==typeof WeakMap)var o=new WeakMap,c=new WeakMap;return(e.exports=n=function(e,n){if(!n&&e&&e.__esModule)return e;var r,a,i={__proto__:null,default:e};if(null===e||"object"!=t(e)&&"function"!=typeof e)return i;if(r=n?c:o){if(r.has(e))return r.get(e);r.set(e,i)}for(var l in e)"default"!==l&&{}.hasOwnProperty.call(e,l)&&((a=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,l))&&(a.get||a.set)?r(i,l,a):i[l]=e[l]);return i},e.exports.__esModule=!0,e.exports.default=e.exports)(r,a)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(w7)),w7.exports}var T7,O7,A7={},R7=Te(rl);function N7(){return T7||(T7=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.createSvgIcon}});var t=R7}(A7)),A7}var _7,D7=function(){if(O7)return L7;O7=1;var e=p_(),t=S7();Object.defineProperty(L7,"__esModule",{value:!0}),L7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");return L7.default=r,L7}(),P7=Se(D7),F7={};var I7,B7=function(){if(_7)return F7;_7=1;var e=p_(),t=S7();Object.defineProperty(F7,"__esModule",{value:!0}),F7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"}),"Lock");return F7.default=r,F7}(),j7=Se(B7),U7={};var W7,$7=function(){if(I7)return U7;I7=1;var e=p_(),t=S7();Object.defineProperty(U7,"__esModule",{value:!0}),U7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Edit");return U7.default=r,U7}(),q7=Se($7),G7={};var Y7,K7=function(){if(W7)return G7;W7=1;var e=p_(),t=S7();Object.defineProperty(G7,"__esModule",{value:!0}),G7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"}),"KeyboardArrowDown");return G7.default=r,G7}(),X7=Se(K7),Q7=function(t){var r,a,o=t.conflictingConditions,i=function(e){var t={};return e.forEach((function(e){var n="".concat(e.conflictType,"_").concat(e.reason);t[n]||(t[n]=[]),t[n].push(e)})),t},l=(null==o?void 0:o.filter((function(e){return e.condition_wta||e.condition_wnta})))||[],s=(r=i(l),a=[],Object.values(r).forEach((function(e){e.length>0&&a.push(e[0])})),a),h=c((function(){return s.map((function(e,t){return t}))})),d=h[0],u=h[1];return l&&0!==l.length?e(Yj,M({sx:{backgroundColor:"#FEF2F2",border:"1px solid #FCA5A5",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.04)",padding:3,borderRadius:2,mt:3,mb:3,fontFamily:"Plus Jakarta Sans"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontSize:"1.15rem",fontWeight:700,color:"#B91C1C",fontFamily:"Plus Jakarta Sans"}},{children:"Conflicting Conditions Found"})),n(LJ,M({title:"The current learning contains conditions that conflicting. Please review and adjust them to ensure consistency.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(Yj,M({sx:{maxHeight:360,overflowY:"auto",pr:1.5}},{children:s.map((function(t,r){var a=[],o=function(e){return e.map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n\n")},c=[],s=[],h=i(l)["".concat(t.conflictType,"_").concat(t.reason)]||[];h.length>1?h.forEach((function(e){e.condition_wta&&c.push(e.condition_wta),e.condition_wnta&&s.push(e.condition_wnta)})):(t.condition_wta&&c.push(t.condition_wta),t.condition_wnta&&s.push(t.condition_wnta)),c.length>0&&a.push({label:"When To Apply",value:o(c)}),s.length>0&&a.push({label:"When Not To Apply",value:o(s)});var m=d.includes(r);return e(nP,M({expanded:m,onChange:function(){return function(e){u((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(r)},disableGutters:!0,sx:{mb:2,border:"1px solid #FCA5A5",fontFamily:"Plus Jakarta Sans",borderRadius:2,"&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(X7,{style:{color:"#991B1B",transition:"transform 0.3s ease-in-out"}}),"aria-controls":"panel-".concat(r,"-content"),id:"panel-".concat(r,"-header"),sx:{fontFamily:"Plus Jakarta Sans",color:"#991B1B",fontWeight:600,px:2,py:1.5}},{children:"Conflict in current conditions"})),e(hP,M({sx:{px:2,pb:2}},{children:[n(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:2===a.length?"row":"column"},gap:2,mb:2}},{children:a.map((function(t,r){return e(Yj,M({sx:{flex:2===a.length?1:"none",border:"1px solid #FCA5A5",borderRadius:2,padding:2,backgroundColor:"#FFFFFF"}},{children:[n(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:t.label})),n(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:t.value}))]}),r)}))})),e(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#1F2937",lineHeight:1.6,fontFamily:"Plus Jakarta Sans"}},{children:[n("strong",{children:"Reason:"})," ",t.reason]}))]}))]}),r)}))}))]})):null},J7={};var Z7,eee=function(){if(Y7)return J7;Y7=1;var e=p_(),t=S7();Object.defineProperty(J7,"__esModule",{value:!0}),J7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"}),"HelpOutline");return J7.default=r,J7}(),tee=Se(eee),nee={};var ree=function(){if(Z7)return nee;Z7=1;var e=p_(),t=S7();Object.defineProperty(nee,"__esModule",{value:!0}),nee.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M17 20.41L18.41 19 15 15.59 13.59 17 17 20.41zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5 7.5 8z"}),"MergeType");return nee.default=r,nee}(),aee=Se(ree);function oee(e){return e?e.replace(/[^a-zA-Z\s]/g,"").replace(/\s+/g," ").trim():""}function cee(e){var t={topic:"",modification:"",tooltip:""};if(!(null==e?void 0:e.trim()))return t;var n=e.replace(/\*/g,"").replace(/\s+/g," ").trim();console.log("Clean variant:",n);var r=/<(sup|tooltip|info)>[\s*]*([^<]*?)[\s*]*<\/\1>/i,a=n.match(r),o=a?a[2].replace(/\*/g,"").trim():"";console.log("Extracted tooltip:",o);var c=n.replace(r,"").trim();console.log("Main text after tooltip removal:",c);var i=c.match(/.*?replace\s+(.*?)(?:\s+with\s*|$)/i),l="",s="";if(i){l=i[1].trim();var h=c.match(/\s+with\s+(.*?)$/i);s=h?h[1].trim():""}else{var d=c.match(/^(.*?)(?:\s+with\s+(.*?))?$/i);d&&(l=d[1].trim(),s=d[2]?d[2].trim():"")}return l=oee(l),s=oee(s),o=oee(o),console.log("Extracted parts after cleaning:",{mainText:c,topic:l,modification:s,tooltip:o}),l&&(s||o)?(console.log("Final results:",{topic:l,modification:s,tooltip:o}),{topic:l,modification:s,tooltip:o}):(console.log("Validation failed - returning default"),t)}var iee=function(r){var a=r.conflictingConditions,o=r.baseUrl,l=r.organizationName,h=r.chatAssistantName;r.curlPayload;var d=r.onDeleted;r.onMerged;var u=r.onDeleteLearning,m=r.onMergeMessage,p=r.setSendMessageInChat,v=r.editConflictingLearningTrigger,f=r.editSimilarLearningTrigger;r.operationStatus,r.onOperationComplete;var z=r.onSetOperationStatus,g=a||[],y=g[0],E=g[1],C=y||[],L=E||[];console.log("[ConflictsDisplayDB] Component props:",{baseUrl:o,organizationName:l,chatAssistantName:h,conflictingLearningsCount:C.length,similarLearningsCount:L.length,hasOnDeletedCallback:!!d});var w=c((function(){return C.length>0?[0]:[]})),k=w[0],x=w[1],S=c((function(){return L.length>0?[0]:[]})),T=S[0],O=S[1],A=c(new Set),R=A[0],N=A[1],_=c(new Set),D=_[0],P=_[1],F=c(new Set),I=F[0],B=F[1],j=c({}),U=j[0],W=j[1],$=c({}),q=$[0],G=$[1],Y=c({}),K=Y[0],X=Y[1],Q=c({}),J=Q[0],Z=Q[1],ee=i(!0);s((function(){return function(){ee.current=!1}}),[]),s((function(){v&&"object"==typeof v&&Object.keys(v).length>0&&(console.log("Edit conflicting learning response received:",v),Object.entries(v).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,o,c,i,l,s,h;return H(this,(function(d){return n&&n.edit_actions&&n.edit_actions.action&&(console.log("Processing conflicting learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=e.join(" OR "),o=r.join(" OR "),c=cee(n.variant),i=c.topic,l=c.modification,s=c.tooltip,h=C.findIndex((function(e){return e.id===t})),-1!==h&&(C[h]=M(M({},C[h]),{feedback:M(M({},C[h].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:o})})),W((function(e){var n;return M(M({},e),((n={})[t]={topic:i,modification:l,tooltip:s,whenToApply:a,whenNotToApply:o},n))}))),[2]}))}))})),Object.keys(v).forEach((function(e){B((function(t){var n=new Set(t);return n.delete(e),n})),P((function(t){var n=new Set(t);return n.delete(e),n})),W((function(t){var n=M({},t);return delete n[e],n})),G((function(t){var n=M({},t);return delete n[e],n})),X((function(t){var n=M({},t);return delete n[e],n}))})))}),[v]),s((function(){f&&"object"==typeof f&&Object.keys(f).length>0&&(console.log("Edit similar learning response received:",f),Object.entries(f).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,o,c,i,l,s,h;return H(this,(function(d){return n&&n.edit_actions&&n.edit_actions.action&&(console.log("Processing similar learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=e.join(" OR "),o=r.join(" OR "),c=cee(n.variant),i=c.topic,l=c.modification,s=c.tooltip,h=L.findIndex((function(e){return e.id===t})),-1!==h&&(L[h]=M(M({},L[h]),{feedback:M(M({},L[h].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:o})})),W((function(e){var n;return M(M({},e),((n={})[t]={topic:i,modification:l,tooltip:s,whenToApply:a,whenNotToApply:o},n))}))),[2]}))}))})),Object.keys(f).forEach((function(e){B((function(t){var n=new Set(t);return n.delete(e),n})),P((function(t){var n=new Set(t);return n.delete(e),n})),W((function(t){var n=M({},t);return delete n[e],n})),G((function(t){var n=M({},t);return delete n[e],n})),X((function(t){var n=M({},t);return delete n[e],n}))})))}),[f]);var te=function(e,t){G((function(n){var r;return M(M({},n),((r={})[e]=t,r))}))},ne=function(e){G((function(t){var n;return M(M({},t),((n={})[e]=null,n))}))},re=function(e){X((function(t){var n;return M(M({},t),((n={})[e]=null,n))}))},ae=function(t){var r=function(e){var t=Math.min(e,1);return Math.round(100*t)}(t.score),a=function(e){return e>=80?{bg:"#10B981",text:"#f2f2f2"}:e>=50?{bg:"#F59E0B",text:"#f2f2f2"}:{bg:"#cc0000",text:"#f2f2f2"}}(r);return n(LJ,M({title:"AI Confidence Score",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.75rem",padding:"0.25rem 0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.5,py:.5,mr:1,borderRadius:"16px",backgroundColor:a.bg,color:a.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",cursor:"default",transition:"all 0.2s ease-in-out"}},{children:[n("svg",M({width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:a.text})}))})),e(iF,M({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",color:a.text}},{children:[r,"%"]}))]}))}))},oe=function(r,a,c,i){var s,v,f,g;console.log("[ConflictsDisplayDB] Rendering ".concat(c," learning:"),{id:r.id,variant:r.feedback.variant,similarity_score:r.similarity_score,type:c});var y="conflict"===c?k.includes(a):T.includes(a),E="conflict"===c?"#991B1B":"#F87171",C="conflict"===c?"Conflicting with: ".concat(r.feedback.variant):"Similar to: ".concat(r.feedback.variant),L=!!J[r.id],w="conflict"===c?"Why it's conflicting?":"Why it's similar?",S=U[r.id],A=I.has(r.id),_=q[r.id],F=K[r.id],j=S||{whenToApply:Array.isArray(r.feedback.when_to_apply)?r.feedback.when_to_apply.join(", "):r.feedback.when_to_apply||"",whenNotToApply:Array.isArray(r.feedback.when_not_to_apply)?r.feedback.when_not_to_apply.join(", "):r.feedback.when_not_to_apply||""};return e(nP,M({expanded:y,onChange:function(){return function(e,t){"conflict"===t?x((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)})):O((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(a,c)},disableGutters:!0,sx:{mb:2,border:"2px solid #acb5c2",borderRadius:2,fontFamily:"Plus Jakarta Sans","&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(X7,{style:{color:E}}),"aria-controls":"panel-".concat(c,"-").concat(a,"-content"),id:"panel-".concat(c,"-").concat(a,"-header"),"aria-label":"".concat(i?"".concat(i,": "):"").concat(C),sx:{fontFamily:"Plus Jakarta Sans",color:E,fontWeight:600,px:2,py:1.5}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[i&&e(iF,M({component:"span",sx:{fontSize:"0.9rem",fontWeight:700,color:E,mr:1,fontFamily:"Plus Jakarta Sans"}},{children:[i,"."]})),n(iF,M({sx:{fontSize:"0.95rem",fontWeight:600,color:E,fontFamily:"Plus Jakarta Sans"}},{children:C}))]})),n(ae,{score:r.similarity_score})]}))})),e(hP,M({sx:{px:2,pb:2}},{children:[e(nP,M({expanded:L,onChange:function(){return e=r.id,void Z((function(t){var n;return M(M({},t),((n={})[e]=!t[e],n))}));var e},disableGutters:!0,elevation:0,sx:{backgroundColor:"transparent",border:"1px solid #fde68a",borderRadius:2,mb:2,"&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(X7,{style:{color:"#92400e"}}),sx:{backgroundColor:"#fef3c7",borderRadius:L?"8px 8px 0 0":2,minHeight:"auto","& .MuiAccordionSummary-content":{margin:"12px 0"}}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",gap:.5}},{children:[n(iF,M({sx:{fontSize:"0.85rem",fontWeight:600,color:"#92400e",fontFamily:"Plus Jakarta Sans"}},{children:w})),n(LJ,M({title:"Click to expand for more details",arrow:!0},{children:n(tee,{style:{color:"#92400e",fontSize:"1rem",cursor:"pointer"}})}))]}))})),n(hP,M({sx:{p:1.5,backgroundColor:"#fffbeb"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#b45309",fontFamily:"Plus Jakarta Sans"}},{children:r.reason}))}))]})),S&&e(Yj,M({sx:{mb:2,p:2,border:"1px solid #991B1B",borderRadius:2}},{children:[n(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:"#991B1B",fontWeight:600,mb:1,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:"Edit Learning"})),e(Yj,M({sx:{display:"flex",gap:2,alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontFamily:"Plus Jakarta Sans"}},{children:"Replace"})),n(j2,{value:j.topic,onChange:function(e){return W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{topic:e.target.value}),n))}))},disabled:A,size:"small",sx:{flex:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans",backgroundColor:"#FFFFFF"}}}),n(iF,M({sx:{fontFamily:"Plus Jakarta Sans"}},{children:"with"})),n(j2,{value:j.modification,onChange:function(e){return W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{modification:e.target.value}),n))}))},disabled:A,size:"small",sx:{flex:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans",backgroundColor:"#FFFFFF"}}})]})),n(j2,{fullWidth:!0,size:"small",label:"Tooltip (Optional)",value:j.tooltip,onChange:function(e){return W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{tooltip:e.target.value}),n))}))},disabled:A,sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans",backgroundColor:"#FFFFFF"}}})]})),e(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:2,mb:2}},{children:[e(Yj,M({sx:{flex:1,scale:S?1.02:1,border:S&&"whenToApply"===_?"1px solid #991B1B":S?"1px solid #B91C1C":"1px solid #FCA5A5",borderRadius:2,padding:2,transition:"all 0.2s ease-in-out",boxShadow:S&&"whenToApply"===_?"0 0 0 1px rgba(153, 27, 27, 0.1)":"none"}},{children:[e(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:S&&"whenToApply"===_?"#991B1B":S?"#B91C1C":"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:["When To Apply",n("span",M({style:{color:"#e4050b"}},{children:"*"}))]})),S||A?n(j2,{fullWidth:!0,multiline:!0,rows:3,value:A?Array.isArray(r.feedback.when_to_apply)?r.feedback.when_to_apply.join("\n"):r.feedback.when_to_apply||"":j.whenToApply,disabled:A,onChange:function(e){return!A&&W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{whenToApply:e.target.value}),n))}))},onFocus:function(){return!A&&te(r.id,"whenToApply")},onBlur:function(){return!A&&ne(r.id)},sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#FFFFFF",border:"1px solid #991B1B",borderRadius:1},"& .MuiOutlinedInput-notchedOutline":{border:"none"}}}):n(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:Array.isArray(r.feedback.when_to_apply)?r.feedback.when_to_apply.join("\n"):r.feedback.when_to_apply}))]})),e(Yj,M({sx:{flex:1,scale:S?1.02:1,border:S&&"whenToApply"===_?"1px solid #991B1B":S?"1px solid #B91C1C":"1px solid #FCA5A5",borderRadius:2,padding:2,transition:"all 0.2s ease-in-out",boxShadow:S&&"whenNotToApply"===_?"0 0 0 1px rgba(153, 27, 27, 0.1)":"none"}},{children:[n(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:S&&"whenNotToApply"===_?"#991B1B":S?"#B91C1C":"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:"When Not To Apply"})),S||A?n(j2,{fullWidth:!0,multiline:!0,rows:3,value:A?Array.isArray(r.feedback.when_not_to_apply)?r.feedback.when_not_to_apply.join("\n"):r.feedback.when_not_to_apply||"":j.whenNotToApply,disabled:A,onChange:function(e){return!A&&W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{whenNotToApply:e.target.value}),n))}))},onFocus:function(){return!A&&te(r.id,"whenNotToApply")},onBlur:function(){return!A&&ne(r.id)},sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#FFFFFF",border:"1px solid #B91C1C",borderRadius:1},"& .MuiOutlinedInput-notchedOutline":{border:"none"}}}):n(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:Array.isArray(r.feedback.when_not_to_apply)?r.feedback.when_not_to_apply.join("\n"):r.feedback.when_not_to_apply}))]}))]})),S?e(Yj,"save"===F?M({sx:{mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#6B7280",mb:1,fontFamily:"Plus Jakarta Sans",fontWeight:500,fontStyle:"italic"}},{children:"Are you sure you want to save this learning with the edited changes?"})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:1}},{children:[I.has(r.id)&&n(iF,M({variant:"body2",sx:{fontSize:"0.8rem",color:"#545454",fontFamily:"Plus Jakarta Sans",fontWeight:500,fontStyle:"italic",mr:1}},{children:"I got it, Editing your conditions..."})),n(zU,M({size:"small",variant:"contained",onClick:function(){return function(e,t,n){return b(void 0,void 0,void 0,(function(){var r,a,o,c,i,l,s,h;return H(this,(function(d){if(!(r=U[e.id]))return[2];P((function(t){return new Set(t).add(e.id)})),B((function(t){return new Set(t).add(e.id)}));try{console.log("[Edit-UI] Sending edit request to API:",e.id,r),a=e.feedback.variant.match(/<[^>]+>[^<]+<\/[^>]+>/),o=a?a[0]:"<tooltip>$1</tooltip>",c=o.match(/<([^>]+)>/),i=c?c[1]:"tooltip",l="Replace ".concat(r.topic," with ").concat(r.modification).concat(r.tooltip?" <".concat(i,">").concat(r.tooltip,"</").concat(i,">"):""),s=(null===(h=r.whenNotToApply)||void 0===h?void 0:h.trim())?"and WNTA: ".concat(r.whenNotToApply):"and remove the WNTA conditions",p("Edit ".concat(t," learning ").concat(n," variant to ").concat(l," with WTA: ").concat(r.whenToApply," ").concat(s)),ee.current&&z&&z({status:"success",message:"Processing edit request..."})}catch(t){console.error("[Edit-UI] error sending edit request:",t),ee.current&&z&&z({status:"error",message:"Error sending edit request: ".concat(t instanceof Error?t.message:"Unknown error")}),B((function(t){var n=new Set(t);return n.delete(e.id),n})),P((function(t){var n=new Set(t);return n.delete(e.id),n}))}return[2]}))}))}(r,c,i||"")},disabled:D.has(r.id)||I.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:I.has(r.id)?"#10B981":"#1565c0",textTransform:"none",color:"white",height:32,px:1.5,fontWeight:600,minWidth:I.has(r.id)?100:"auto","&:disabled":{backgroundColor:"#f3f4f6",color:"#9CA3AF",height:32}}},{children:I.has(r.id)?e(t,{children:[n(SW,{size:16,style:{color:"black",marginRight:6}}),"Saving..."]}):D.has(r.id)?n(SW,{size:16,style:{color:"white"}}):"Yes"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return re(r.id)},disabled:D.has(r.id)||I.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"No"}))]}))]}):M({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:2,mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#6B7280",fontFamily:"Plus Jakarta Sans",fontWeight:500,fontStyle:"italic"}},{children:"You are now editing this learning. Changes are applied upon saving."})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",gap:1}},{children:[n(zU,M({size:"small",variant:"contained",onClick:function(){return e=r.id,void X((function(t){var n;return M(M({},t),((n={})[e]="save",n))}));var e},disabled:D.has(r.id)||!(null===(s=j.whenToApply)||void 0===s?void 0:s.trim())||!(null===(v=j.topic)||void 0===v?void 0:v.trim())||!(null===(f=j.modification)||void 0===f?void 0:f.trim())&&!(null===(g=j.tooltip)||void 0===g?void 0:g.trim()),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"#1565c0",border:"1px solid #624ea6",textTransform:"none",color:"white",height:32,px:1.5,fontWeight:600,"&:disabled":{backgroundColor:"#f3f4f6",color:"#9CA3AF",borderColor:"#d1d5db",height:32}}},{children:"Save"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return e=r.id,W((function(t){var n=M({},t);return delete n[e],n})),G((function(t){var n=M({},t);return delete n[e],n})),void X((function(t){var n=M({},t);return delete n[e],n}));var e},disabled:D.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"Cancel"}))]}))]})):"merge"===F?e(Yj,M({sx:{mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#6B7280",mb:2,fontFamily:"Plus Jakarta Sans",fontStyle:"italic"}},{children:"Merging will delete this learning and move its conditions into the current one. Do you want to proceed?"})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",gap:1}},{children:[n(zU,M({size:"small",variant:"contained",disabled:!1,onClick:function(){console.log("[Merge-DB] Merge button clicked for learning:",r.id),console.log("[Merge-DB] Sending merge message to chat"),m?(console.log("[Merge-DB] 🔵 MERGE BUTTON CLICKED - Sending merge request for learning:",r.id),console.log("[Merge-DB] Learning data:",r),m(r.id),ee.current&&z&&z({status:"success",message:"Merge request sent to chat for learning: ".concat(r.feedback.variant)})):(console.log("[Merge-DB] No onMergeMessage callback provided"),ee.current&&z&&z({status:"error",message:"Unable to send merge request - chat integration not available"})),X((function(e){var t;return M(M({},e),((t={})[r.id]=null,t))}))},sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"#10B981",textTransform:"none",color:"white",height:32,px:1.5,fontWeight:600,"&:hover":{backgroundColor:"#059669"}}},{children:R.has(r.id)?n(SW,{size:16,style:{color:"white"}}):"Yes"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return re(r.id)},disabled:R.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"No"}))]}))]})):F&&"object"==typeof F&&"delete"===F.action?e(Yj,M({sx:{mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#B91C1C",mb:2,fontFamily:"Plus Jakarta Sans",fontStyle:"italic"}},{children:"This action cannot be undone, are you sure you want to delete this learning?"})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",gap:1}},{children:[n(zU,M({size:"small",variant:"outlined",disabled:R.has(r.id),onClick:function(e){return b(void 0,void 0,void 0,(function(){return H(this,(function(t){e.stopPropagation(),console.log("[Delete-DB] Delete confirmation clicked for learning:",r.id),console.log("[Delete-DB] Setting deleting state for:",r.id),N((function(e){return new Set(e).add(r.id)}));try{u&&(u(F.label),console.log("[Delete-DB] Delete callback called for learning:",r.feedback.variant)),d&&d(r.id),ee.current&&z&&z({status:"success",message:"Successfully deleted learning: ".concat(r.feedback.variant)})}catch(e){console.error("[Delete-DB] error",e),ee.current&&z&&z({status:"error",message:"Error deleting learning: ".concat(e instanceof Error?e.message:"Unknown error")})}finally{ee.current&&(N((function(e){var t=new Set(e);return t.delete(r.id),t})),X((function(e){var t=M({},e);return delete t[r.id],t})))}return[2]}))}))},startIcon:n(P7,{}),sx:{fontFamily:"Plus Jakarta Sans",color:E,textTransform:"none",borderColor:E,"&:hover":{borderColor:E,backgroundColor:"".concat(E,"10")},"&:disabled":{color:"#9CA3AF",borderColor:"#9CA3AF"}}},{children:R.has(r.id)?n(SW,{size:16,style:{color:E}}):"Yes"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return re(r.id)},disabled:R.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"No"}))]}))]})):e(Yj,M({sx:{display:"flex",gap:1,justifyContent:"flex-end",mt:2}},{children:["similar"===c&&n(LJ,M({title:"Merge this similar learning into the current one",arrow:!0},{children:n("span",M({style:{display:"inline-flex"}},{children:n(zU,M({size:"small",variant:"contained",onClick:function(){return e=r.id,void X((function(t){var n;return M(M({},t),((n={})[e]="merge",n))}));var e},startIcon:n(aee,{}),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"white",border:"1px solid #10B981",textTransform:"none",color:"#10B981",height:32,px:1.5,fontWeight:600,"&:hover":{backgroundColor:"#10B98110"}}},{children:"Merge"}))}))})),n(LJ,M({title:o&&l&&h?"Correct Me":"Edit unavailable: missing context",arrow:!0},{children:n("span",M({style:{display:"inline-flex"}},{children:n(zU,M({size:"small",color:"primary",variant:"contained",disabled:!(o&&l&&h)||D.has(r.id),onClick:function(){return function(e){var t=cee(e.feedback.variant);W((function(n){var r;return M(M({},n),((r={})[e.id]={topic:t.topic,modification:t.modification,tooltip:t.tooltip,whenToApply:Array.isArray(e.feedback.when_to_apply)?e.feedback.when_to_apply.join(", "):e.feedback.when_to_apply||"",whenNotToApply:Array.isArray(e.feedback.when_not_to_apply)?e.feedback.when_not_to_apply.join(", "):e.feedback.when_not_to_apply||""},r))}))}(r)},startIcon:n(q7,{}),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"white",border:"1px solid #624ea6",textTransform:"none",color:"#1565c0",height:32,px:1.5,"&:hover":{backgroundColor:"#1565c020"},fontWeight:600}},{children:"Correct Me"}))}))})),n(LJ,M({title:o&&l&&h?"Delete":"Delete unavailable: missing context",arrow:!0},{children:n("span",M({style:{display:"inline-flex"}},{children:n(zU,M({size:"small",variant:"outlined",disabled:!(o&&l&&h)||R.has(r.id),onClick:function(e){e.stopPropagation(),function(e,t,n){var r="".concat("conflict"===n?"Conflicting":"Similar"," Learning ").concat(t);X((function(t){var n;return M(M({},t),((n={})[e]={action:"delete",label:r},n))}))}(r.id,i||"A",c)},startIcon:n(P7,{}),sx:{fontFamily:"Plus Jakarta Sans",color:"#cc0000",textTransform:"none",borderColor:"#cc0000","&:hover":{borderColor:"#cc0000",backgroundColor:"#cc000010"},"&:disabled":{color:"#9CA3AF",borderColor:"#9CA3AF"}}},{children:"Delete"}))}))}))]}))]}))]}),"".concat(c,"-").concat(a))};if(!(C&&0!==C.length||L&&0!==L.length))return null;var ce=function(e){return"similar"===e?"We've identified existing learnings that are similar to the current one. You may want to edit or delete them to avoid duplication or confusion.":"Some existing learnings may contradict the current one. Review them carefully, as they could cause instability when applied together."},ie=function(t,r){if(0===t.length)return null;var a=function(e,t){return 1===e?"similar"===t?"1 Similar Learning Found":"1 Conflicting Learning Found":"".concat(e,"similar"===t?" Similar Learnings Found":" Conflicting Learnings Found")}(t.length,r);return e(Yj,M({sx:{border:"1px solid #FCA5A5",boxShadow:"0 4px 10px rgba(0,0,0,0.05)",p:3,borderRadius:3,mt:3,mb:3,fontFamily:"Plus Jakarta Sans",transition:"all 0.2s ease-in-out","&:hover":{boxShadow:"0 6px 14px rgba(0,0,0,0.08)",transform:"translateY(-2px)"}}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2,justifyContent:"",fontFamily:"Plus Jakarta Sans"}},{children:[n(iF,M({sx:{fontSize:"1.2rem",fontWeight:700,color:"#B91C1C",fontFamily:"Plus Jakarta Sans"}},{children:a})),n(LJ,M({title:ce(r),placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",p:1,borderRadius:1.5,color:"#fff",fontFamily:"Plus Jakarta Sans"}}}},{children:n(Yj,M({sx:{width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",ml:1,fontFamily:"Plus Jakarta Sans"}},{children:n(n7,{size:16,color:"#B91C1C"})}))}))]})),n(Yj,M({sx:{maxHeight:360,overflowY:"auto",pr:1.5,fontFamily:"Plus Jakarta Sans","&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-thumb":{backgroundColor:"#FCA5A5",borderRadius:"8px"},"&::-webkit-scrollbar-track":{backgroundColor:"#FEE2E2"}}},{children:t.map((function(e,t){return oe(e,t,r,function(e){return String.fromCharCode(65+e)}(t))}))}))]}),r)};return e(t,{children:[ie(C,"conflict"),ie(L,"similar")]})},lee=function(t){var r,a,o=t.organizationName,d=t.selectedText,u=t.scopeOptions,m=t.devModeTag,p=t.chatAssistantName,v=t.chatLogo,f=void 0===v?null:v,z=t.submitFunction;t.setShowChat,t.showChat;var g=t.formDataState,y=t.setFormDataState,C=t.instantLearningSuggestions;t.setHasUserFilledForm,t.hasUserFilledForm;var L=t.isNewChatClicked,w=t.setIsNewChatClicked,k=t.setHasUserWrittenModification,x=t.extractedModification,S=t.save,T=t.extractedTooltip;t.isSaveLoading,t.shouldTriggerSave;var O=t.baseUrl;t.topic_table,t.variant_table,t.scope_table,t.embedding_column_name,t.embedding_model;var A=t.validationWtaResponse,R=t.setValidationWtaResponse,N=t.learningWtaResponse,_=t.setLearningWtaResponse,D=t.setIsFormSavedClicked,P=t.onDeleteLearning,F=t.onMergeLearning,I=t.mergeLearningTrigger,B=t.resetLearningTrigger,j=t.editConflictingLearningTrigger,U=t.editSimilarLearningTrigger,W=t.setSendMessageInChat,$=t.isMergeLoading,q=t.setIsMergeLoading,G=c({context:"",issue_with_response:"",original:null!=d?d:"",modification:"",whenToApply:"",whenNotToApply:"",tooltip:"",scope:u[0].value,isTooltipEnabled:!1,isModificationEnabled:!0,isDevMode:!1}),Y=G[0],K=G[1],X=c(!1),Q=X[0],J=X[1],Z=c(!1),ee=Z[0],te=Z[1],ne=c(!1),re=ne[0],ae=ne[1],oe=c(!1),ce=oe[0],ie=oe[1],le=c([]),se=le[0],he=le[1],de=c([]),ue=de[0],me=de[1],pe=c(!1),ve=pe[0],fe=pe[1],ze=c(!1),ge=ze[0],ye=ze[1];s((function(){q(!1)}),[]);var Me=c(!1),Ee=Me[0],be=Me[1],He=c(!1);He[0];var Ve=He[1],Ce=c(null),Le=Ce[0];Ce[1];var we=c(!1);we[0],we[1];var ke=c(null);ke[0],ke[1];var xe=c(null),Se=xe[0],Te=xe[1],Oe=c(!1),Ae=Oe[0],Re=Oe[1],Ne=c(!1);Ne[0];var _e=Ne[1],De=c(null),Pe=De[0],Fe=De[1],Ie=c(null),Be=Ie[0],je=Ie[1],Ue=c(new Set),We=Ue[0],$e=Ue[1],qe=c(null),Ge=qe[0],Ye=qe[1];s((function(){try{j&&"object"==typeof j&&Object.keys(j).length>0&&(console.log("Processing conflicting learning edit actions:",j),Object.entries(j).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,c,i,l,s,h,d;return H(this,(function(u){switch(u.label){case 0:if(!(n&&n.edit_actions&&n.edit_actions.action))return[3,6];if(console.log("Processing conflicting learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=Array.isArray(e)?e.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():e||"",c=Array.isArray(r)?r.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():r||"",Fe((function(e){if(!e)return e;var r=M({},e);return Object.keys(r).forEach((function(e){r[e]&&r[e].id===t&&(r[e]=M(M({},r[e]),{feedback:M(M({},r[e].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:c})}))})),r})),console.log("Updated form with conflicting learning conditions:",{whenToApply:a,whenNotToApply:c}),!(O&&o&&p))return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),i=Pe?Object.values(Pe).find((function(e){return e&&e.id===t})):null,i?i.feedback?(l=cee(n.variant),s={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isUpdateAction:!0,isAgentsFeedback:!0,variant:{id:t,variant:n.variant,conditions_whentoapply:a,conditions_whennottoapply:c,scope:{name:"Custom",value:{scopeId:"askmod-scope-id",scopeName:"askmod"}},topic:{id:null,value:l.topic||"default"},categories:[],originalQuestion:"",parameterizedQuestion:null,created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),created_by:null,updated_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),updated_by:"madumbu.kathyayani@techolution.com",instantLearningType:"iL",appliedTagsIL:[],tagMappingInfoIL:{}}}},console.log("[LearningDetailsForm] Saving edited conditions for conflicting learning ".concat(t,":"),s),[4,g7({baseUrl:O,organizationName:o,chatAssistantName:p,payload:s})]):(console.error("[LearningDetailsForm] Learning feedback not found for ID: ".concat(t)),[2]):(console.error("[LearningDetailsForm] Learning object not found for ID: ".concat(t)),[2]);case 2:return(h=u.sent()).ok?(console.log("edit notifc"),Ye({status:"success",message:"Successfully saved edited conditions for this learning"}),console.log("[LearningDetailsForm] Successfully saved edited conditions for conflicting learning ".concat(t))):(console.error("[LearningDetailsForm] Failed to save edited conditions for conflicting learning ".concat(t,":"),h.status,h.statusText),Ye({status:"error",message:"Failed to save edited conditions for this learning"})),[3,4];case 3:return d=u.sent(),Ye({status:"error",message:"Error saving edited conditions for learning"}),console.error("[LearningDetailsForm] Error saving edited conditions for conflicting learning ".concat(t,":"),d),[3,4];case 4:return[3,6];case 5:console.log("[LearningDetailsForm] Missing required context for edit API call"),u.label=6;case 6:return[2]}}))}))}))),U&&"object"==typeof U&&Object.keys(U).length>0&&(console.log("Processing similar learning edit actions:",U),Object.entries(U).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,c,i,l,s,h,d;return H(this,(function(u){switch(u.label){case 0:if(!(n&&n.edit_actions&&n.edit_actions.action))return[3,6];if(console.log("Processing similar learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=Array.isArray(e)?e.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():e||"",c=Array.isArray(r)?r.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():r||"",je((function(e){if(!e)return e;var r=M({},e);return Object.keys(r).forEach((function(e){r[e]&&r[e].id===t&&(r[e]=M(M({},r[e]),{feedback:M(M({},r[e].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:c})}))})),r})),console.log("Updated form with similar learning conditions:",{whenToApply:a,whenNotToApply:c}),!(O&&o&&p))return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),i=Be?Object.values(Be).find((function(e){return e&&e.id===t})):null,i?i.feedback?(l=cee(n.variant),s={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isUpdateAction:!0,isAgentsFeedback:!0,variant:{id:t,variant:n.variant,conditions_whentoapply:a,conditions_whennottoapply:c,scope:{name:"Custom",value:{scopeId:"askmod-scope-id",scopeName:"askmod"}},topic:{id:null,value:l.topic||"default"},categories:[],originalQuestion:"",parameterizedQuestion:null,created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),created_by:null,updated_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),updated_by:"madumbu.kathyayani@techolution.com",instantLearningType:"iL",appliedTagsIL:[],tagMappingInfoIL:{}}}},console.log("[LearningDetailsForm] Saving edited conditions for similar learning ".concat(t,":"),s),[4,g7({baseUrl:O,organizationName:o,chatAssistantName:p,payload:s})]):(console.error("[LearningDetailsForm] Learning feedback not found for ID: ".concat(t)),[2]):(console.error("[LearningDetailsForm] Learning object not found for ID: ".concat(t)),[2]);case 2:return(h=u.sent()).ok?(console.log("edit notifc"),Ye({status:"success",message:"Successfully saved edited conditions for this similar learning"}),console.log("[LearningDetailsForm] Successfully saved edited conditions for this similar learning")):(console.error("[LearningDetailsForm] Failed to save edited conditions for similar learning ".concat(t,":"),h.status,h.statusText),Ye({status:"error",message:"Failed to save edited conditions for this learning"})),[3,4];case 3:return d=u.sent(),console.error("[LearningDetailsForm] Error saving edited conditions for similar learning ".concat(t,":"),d),[3,4];case 4:return[3,6];case 5:console.log("[LearningDetailsForm] Missing required context for edit API call"),u.label=6;case 6:return[2]}}))}))})))}catch(e){console.error("Error processing edit tool actions:",e)}}),[j,U,Fe,je,O,o,p]);var Ke=l((function(e){return b(void 0,void 0,void 0,(function(){var t,n,r,a;return H(this,(function(c){switch(c.label){case 0:if(console.log("[LearningDetailsForm] Merging learning from chat:",e),!Be)return console.log("No similar learnings data available"),[2];if(!(t=Object.values(Be).find((function(t){return t&&t.id===e}))))return console.log("Learning with ID ".concat(e," not found in similar learnings")),[2];if(console.log("Found learning to merge:",t),console.log("🔵 LEARNING DETAILS FORM - Merge button clicked, waiting for merge response to provide correct conditions"),q(!0),je((function(t){if(!t)return{};var n={};return Object.keys(t).forEach((function(r){t[r].id!==e&&(n[r]=t[r])})),n})),$e((function(t){return new Set(t).add(e)})),setTimeout((function(){Fe((function(e){return je((function(t){return e&&0!==Object.keys(e).length||t&&0!==Object.keys(t).length||_e(!1),t})),e}))}),100),console.log("[LearningDetailsForm] Successfully merged learning from chat"),!(O&&o&&p))return[3,5];c.label=1;case 1:return c.trys.push([1,3,,4]),n={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:e,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(e),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},console.log("[LearningDetailsForm] Deleting merged learning with ID: ".concat(e)),[4,g7({baseUrl:O,organizationName:o,chatAssistantName:p,payload:n})];case 2:return(r=c.sent()).ok?(Ye({status:"success",message:"Learning merged successfully."}),console.log("[LearningDetailsForm] Successfully deleted merged learning ".concat(e))):(console.error("[LearningDetailsForm] Failed to delete merged learning",r.status,r.statusText),Ye({status:"error",message:"Failed to complete merge for learning."})),[3,4];case 3:return a=c.sent(),console.error("[LearningDetailsForm] Error deleting merged learning ".concat(e,":"),a),[3,4];case 4:return[3,6];case 5:console.log("[LearningDetailsForm] Missing required context for delete API call"),c.label=6;case 6:return[2]}}))}))}),[Be,y,he,me,O,o,p]);s((function(){I&&(Ke(I),F&&F(I))}),[I,F,Ke]),s((function(){B&&(console.log("[LearningDetailsForm] 🔄 RESET TRIGGER RECEIVED - Clearing all learning data"),console.log("[LearningDetailsForm] Before reset - DBCWtaApiResponse:",Pe?Object.keys(Pe).length:0,"items"),console.log("[LearningDetailsForm] Before reset - DBSWtaApiResponse:",Be?Object.keys(Be).length:0,"items"),Fe(null),je(null),_e(!1),Re(!1),$e(new Set),he([]),me([]),q(!1),K((function(e){return M(M({},e),{whenToApply:"",whenNotToApply:"",tooltip:"",modification:"",isTooltipEnabled:!1,isModificationEnabled:!0})})),console.log("[LearningDetailsForm] ✅ Learning data reset completed"))}),[B]);var Xe=h((function(){var e,t,n,r,a=""!==(null===(e=null==Y?void 0:Y.original)||void 0===e?void 0:e.trim()),o=""!==(null===(t=null==Y?void 0:Y.whenToApply)||void 0===t?void 0:t.trim()),c=(null==se?void 0:se.length)>0,i=!(null==Y?void 0:Y.isTooltipEnabled)||""!==(null===(n=null==Y?void 0:Y.tooltip)||void 0===n?void 0:n.trim()),l=!0;return(null==Y?void 0:Y.isModificationEnabled)&&(l=""!==(null===(r=null==Y?void 0:Y.modification)||void 0===r?void 0:r.trim())),a&&o&&c&&(i||l)}),[Y,se,C]),Qe=h((function(){var e=Ae&&Se,t=Pe&&Object.keys(Pe).length>0,n=Be&&Object.keys(Be).length>0;return!!e||t||n}),[Ae,Se,Pe,Be]),Je=i(null);s((function(){Y.isModificationEnabled||K((function(e){return M(M({},e),{modification:""})})),Y.isTooltipEnabled||K((function(e){return M(M({},e),{tooltip:""})}))}),[Y.isModificationEnabled,Y.isTooltipEnabled]),s((function(){if(""===x&&(null==Y?void 0:Y.isTooltipEnabled)&&K((function(e){return M(M({},e),{isModificationEnabled:!1})})),""!==x||(null==Y?void 0:Y.isTooltipEnabled)||K((function(e){return M(M({},e),{modification:""})})),x&&""!==x){K((function(e){return M(M({},e),{modification:x,isModificationEnabled:!0})})),ie(!0);var e=setTimeout((function(){ie(!1)}),400);return function(){return clearTimeout(e)}}}),[x]),s((function(){""===T&&K((function(e){return M(M({},e),{isTooltipEnabled:!1})})),T&&""!==T&&K((function(e){return M(M({},e),{tooltip:T,isTooltipEnabled:!0})}))}),[T]),s((function(){L&&$e(new Set)}),[L]),s((function(){L&&(K((function(e){return M(M({},e),{modification:"",tooltip:"",isTooltipEnabled:!1,isModificationEnabled:!0,whenToApply:"",whenNotToApply:""})})),he([]),me([]),q(!1),w(!1),Ve(!1),Re(!1),_e(!1))}),[L]),s((function(){y(Y)}),[Y]),s((function(){(null==g?void 0:g._mergeUpdate)&&(console.log("🔵 LEARNING DETAILS FORM - Detected merge update:",g),g._mergeWTA&&(console.log("🔵 LEARNING DETAILS FORM - Updating suggestedWTA with merge data:",g._mergeWTA),he(g._mergeWTA)),g._mergeWNTA&&(console.log("🔵 LEARNING DETAILS FORM - Updating suggestedWnTA with merge data:",g._mergeWNTA),me(g._mergeWNTA)),y((function(e){return e._mergeUpdate,e._mergeWTA,e._mergeWNTA,E(e,["_mergeUpdate","_mergeWTA","_mergeWNTA"])})))}),[null==g?void 0:g._mergeUpdate,null==g?void 0:g._mergeWTA,null==g?void 0:g._mergeWNTA]),s((function(){""===Y.original.trim()||""===Y.modification.trim()&&""===Y.tooltip.trim()||Q||J(!0)}),[Y]),s((function(){if((null==se?void 0:se.length)>=0){var e=se.join(" OR ");Y.whenToApply!==e&&K((function(t){return M(M({},t),{whenToApply:e})}))}}),[JSON.stringify(se),Y.whenToApply]),s((function(){if((null==ue?void 0:ue.length)>=0){var e=ue.join(" OR ");Y.whenNotToApply!==e&&K((function(t){return M(M({},t),{whenNotToApply:e})}))}}),[JSON.stringify(ue),Y.whenNotToApply]),s((function(){if((null==se?void 0:se.length)>0&&!ve){te(!0);var e=setTimeout((function(){te(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(se)]),s((function(){if((null==ue?void 0:ue.length)>0&&!ge){ae(!0);var e=setTimeout((function(){ae(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(ue)]),s((function(){var e,t,n,r;if(C){fe(!1),ye(!1);var a=null===(e=null==C?void 0:C.conditions_whentoapply)||void 0===e?void 0:e.map((function(e){return e.when_to_apply})),o=null===(t=null==C?void 0:C.conditions_whennottoapply)||void 0===t?void 0:t.map((function(e){return e.when_not_to_apply}));(null===(n=null==C?void 0:C.conditions_whentoapply)||void 0===n?void 0:n.length)&&(he(a.filter((function(e){return""!==e}))),K((function(e){return M(M({},e),{whenToApply:null==a?void 0:a.join(" OR ")})}))),(null===(r=null==C?void 0:C.conditions_whennottoapply)||void 0===r?void 0:r.length)&&(me(o.filter((function(e){return""!==e}))),K((function(e){return M(M({},e),{whenNotToApply:null==o?void 0:o.join(" OR ")})})))}}),[C]);var Ze=i(null),et=l((function(){Ze.current&&clearTimeout(Ze.current),Ze.current=setTimeout((function(){k(!0)}),1e3)}),[]),tt=l((function(e){return function(t){K((function(n){var r;return M(M({},n),((r={})[e]=t.target.value,r))})),et()}}),[et]),nt=function(e){return e.replace(new RegExp("<".concat(m,">"),"gi"),"").replace(new RegExp("</".concat(m,">"),"gi"),"").replace(/<\/?[^>]+(>|$)/g,"")},rt=l((function(e){var t=nt(e);K((function(e){return M(M({},e),{tooltip:t})})),et()}),[et]),at=function(e){return function(t){var n=t.target.checked,r={};"isTooltipEnabled"===e?r={tooltip:n?Y.tooltip:"",isModificationEnabled:!n||Y.isModificationEnabled}:"isModificationEnabled"===e&&(r={modification:n?Y.modification:""}),K((function(t){var a;return M(M(M({},t),r),((a={})[e]=n,a))}))}};s((function(){if(S){console.log("'save: true' received. Forcibly clearing all conflict UI states."),Re(!1),Te(null),D(!0);b(void 0,void 0,void 0,(function(){return H(this,(function(e){return Qe?(console.error("Save action triggered via prop, but is blocked due to unresolved conflicts."),[2]):(console.log("Form submitted:",Y),be(!0),""===(null==Y?void 0:Y.modification)&&K((function(e){return M(M({},e),{isModificationEnabled:!1})})),""===(null==Y?void 0:Y.tooltip)&&K((function(e){return M(M({},e),{isTooltipEnabled:!1})})),z(Y,be),[2])}))}))}}),[S,Qe]);s((function(){A&&!1===A.is_valid?(Re(!0),Te(A.conflictingConditions),dt()):A&&A.is_valid?(Re(!1),Te(null),console.log("valid response received, calling handleSubmit")):(Re(!1),console.log("resetting validateWtaApiResponse"),Te(null))}),[A]),s((function(){if(N){var e=(null==N?void 0:N.conflicting_learnings)||{},t=(null==N?void 0:N.similar_learnings)||{};Object.keys(e).length,Object.keys(t).length;var n=Object.keys(e).reduce((function(t,n){var r=e[n];return We.has(r.id)||(t[n]=r),t}),{}),r=Object.keys(t).reduce((function(e,n){var r=t[n];return We.has(r.id)||(e[n]=r),e}),{});Fe(n),je(r);var a=Object.keys(n).length>0,o=Object.keys(r).length>0;a||o?(_e(!0),Re(!1),dt()):!0===(null==N?void 0:N.is_valid_db)&&_e(!1)}}),[N,We]);var ot,ct,it=i(null),lt=c(!1),st=lt[0],ht=lt[1],dt=function(){var e=it.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),ht(!1)}),200)};return s((function(){var e=it.current,t=function(){var e=it.current;if(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;ht(!(n-(t+r)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[st]),e(Yj,M({p:0,className:j8,sx:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[n(Yj,{children:n(iF,M({sx:{fontSize:20,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Instant Learning"}))}),e(Yj,M({sx:{fontFamily:"Plus Jakarta Sans",display:"flex",flexDirection:"column",gap:2,justifyContent:"space-between",flexGrow:1,paddingTop:"20px",height:"calc(100% - 30px)",overflow:"auto"}},{children:[e(Yj,M({sx:{display:"flex",flexDirection:"column",gap:"20px",height:"calc(100% - 90px)",overflow:"auto",position:"relative"},ref:it},{children:[e(Yj,M({sx:{display:"flex",gap:2}},{children:[e(Yj,M({sx:{flex:1}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[e(iF,M({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",fontWeight:600,display:"flex",alignItems:"center"}},{children:["Original"," ",n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Original word/phrase which needs to be replaced",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(YZ,{sx:{visibility:"hidden"},disabled:!0})]})),n(j2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}},id:"original",value:Y.original,onChange:tt("original"),fullWidth:!0,placeholder:"Enter original"})]})),e(Yj,M({sx:{flex:1}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[e(iF,M({sx:{fontFamily:"Plus Jakarta Sans",fontWeight:600,fontSize:"1rem",display:"flex",alignItems:"center"}},{children:["Modification",Y.isModificationEnabled&&!Y.isTooltipEnabled&&n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Modified word/phrase which Original needs to be replaced with",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(YZ,{checked:Y.isModificationEnabled,disabled:!Y.isTooltipEnabled,onChange:at("isModificationEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),Y.isModificationEnabled&&n(j2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},boxShadow:ce?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"},id:"modification",value:Y.modification,onChange:tt("modification"),fullWidth:!0,placeholder:"Change ".concat(d," to...")})]}))]})),e(Yj,M({sx:{display:"flex",gap:2}},{children:[n(Yj,{sx:{flex:1}}),e(Yj,M({sx:{flex:1}},{children:[e(Yj,M({sx:{display:"flex",justifyContent:"space-between"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"}},{children:["Tooltip",Y.isTooltipEnabled&&n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Adds a tooltip to the modification or the original word",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(YZ,{checked:Y.isTooltipEnabled,onChange:at("isTooltipEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),Y.isTooltipEnabled&&e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[n(iF,M({sx:{fontSize:14,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Dev Mode"})),n(YZ,{checked:Y.isDevMode,onChange:at("isDevMode"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#4b5563"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#4b5563"}}})]}))]})),Y.isTooltipEnabled&&n(j2,{id:"tooltip",inputRef:Je,value:function(){var e=nt(Y.tooltip);return Y.isDevMode?"<".concat(m,">").concat(e,"</").concat(m,">"):e}(),onChange:function(e){return rt(e.target.value)},onFocus:function(){setTimeout((function(){if(Y.isDevMode){var e=nt(Y.tooltip),t="<".concat(m,">").length+e.length,n=Je.current;n&&n.setSelectionRange(t,t)}}),0)},fullWidth:!0,placeholder:Y.isDevMode?"<".concat(m,">Enter tooltip content</").concat(m,">"):"Enter tooltip content",sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]}))]})),e(Yj,M({sx:{display:"flex",gap:2,height:"".concat(Y.isTooltipEnabled?"calc(100% - 248px)":"calc(100% - 200px)")}},{children:[(!(null==se?void 0:se.length)||$)&&e(Yj,M({sx:{flex:1}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",display:"flex",flexDirection:"column"}},{children:[e("div",M({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),n("div",M({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:e("div",M({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},$?{children:[n(SW,{size:24,sx:{color:"#5928ED",mb:1}}),n("div",M({style:{fontWeight:"700",color:"#5928ED"}},{children:"Merging conditions..."})),n("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"0.875rem",flexFlow:"wrap"}},{children:n("div",{children:"Processing merge response...."})}))]}:{children:[n("div",M({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),e("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[n("div",M({style:{}},{children:"Tell us about your learning in "})),n("span",M({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",n("span",{children:"Chat"})]}))]}))}))]}))]})),(null==se?void 0:se.length)>0&&!$&&e(Yj,M({sx:{flex:1,height:"100%"}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:ee?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[e(Yj,M({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[e(Yj,M({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[f&&n(Yj,{component:"img",src:f,alt:"Chat",sx:{width:14,height:14}}),e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==se?void 0:se.length)>0&&n(LJ,M({title:ve?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(UP,M({disabled:se.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return fe((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:n(ve?j7:q7,{fontSize:"small"})}))}))]})),n(Yj,M({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:n("ol",M({style:{paddingLeft:"0rem",fontFamily:"Plus Jakarta Sans",margin:0}},{children:ee?e(Yj,M({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[n(SW,{size:24}),n("span",{children:"Generating When to apply..."})]})):n(Yj,M({sx:{pt:"16px"}},{children:se.map((function(e,t){return{value:e,index:t}})).map((function(t,r){var a=t.value,o=t.index;return e(Yj,M({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:o<se.length-1?2:0,fontFamily:"Plus Jakarta Sans"},component:"li"},{children:[n(j2,{variant:"outlined",disabled:!ve,fullWidth:!0,multiline:!0,value:"".concat(a),onChange:function(e){var t=V([],se,!0);t[o]=e.target.value,R(null),_({similar_learnings:"",conflicting_learnings:""}),he(t),K((function(e){return M(M({},e),{whenToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:e(VG,M({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[o+1,"."]}))}}),ve&&n(UP,M({onClick:function(){if(se.length>1){var e=se.filter((function(e,t){return t!==o}));he(e),K((function(t){return M(M({},t),{whenToApply:e.join(" OR ")})}))}},sx:{mt:1}},{children:n(P7,{})}))]}),o)}))}))}))}))]}))]})),(!(null==ue?void 0:ue.length)||$)&&e(Yj,M({sx:{flex:1}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",n(LJ,M({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,flex:1,display:"flex",flexDirection:"column",height:"calc(100% - 64px)"}},{children:[e("div",M({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),n("div",M({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:e("div",M({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},$?{children:[n(SW,{size:24,sx:{color:"#5928ED",mb:1}}),n("div",M({style:{fontWeight:"700",color:"#5928ED"}},{children:"Merging conditions..."})),n("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"0.875rem",flexFlow:"wrap"}},{children:n("div",{children:"Processing merge response..."})}))]}:{children:[n("div",M({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),e("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[n("div",M({style:{}},{children:"Tell us about your learning in "})),n("span",M({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",n("span",{children:"Chat"})]}))]}))}))]}))]})),(null==ue?void 0:ue.length)>0&&!$&&e(Yj,M({sx:{flex:1,height:"100%"}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",n(LJ,M({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:re?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[e(Yj,M({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[e(Yj,M({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[f&&n(Yj,{component:"img",src:f,alt:"Chat",sx:{width:14,height:14}}),e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==ue?void 0:ue.length)>0&&n(LJ,M({placement:"top",arrow:!0,title:ge?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(UP,M({disabled:ue.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return ye((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:n(ge?j7:q7,{fontSize:"small"})}))}))]})),n(Yj,M({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:n("ol",M({style:{paddingLeft:"0rem",margin:0}},{children:re?e(Yj,M({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[n(SW,{size:24}),n("span",{children:"Generating When not to apply..."})]})):n(Yj,M({sx:{pt:"16px"}},{children:ue.map((function(e,t){return{value:e,index:t}})).map((function(t,r){var a=t.value,o=t.index;return e(Yj,M({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:o<ue.length-1?2:0},component:"li"},{children:[n(j2,{variant:"outlined",disabled:!ge,fullWidth:!0,multiline:!0,value:"".concat(a),error:!a.trim(),onChange:function(e){var t=V([],ue,!0);t[o]=e.target.value,R(null),_({similar_learnings:"",conflicting_learnings:""}),me(t),K((function(e){return M(M({},e),{whenNotToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:e(VG,M({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[o+1,"."]}))}}),ge&&n(UP,M({onClick:function(){if(ue.length>1){var e=ue.filter((function(e,t){return t!==o}));me(e),K((function(t){return M(M({},t),{whenNotToApply:e.join(" OR ")})}))}},disabled:1===ue.length,sx:{mt:1}},{children:n(P7,{})}))]}),o)}))}))}))}))]}))]}))]})),Ae&&Se&&n(Q7,{conflictingConditions:Se}),(ct=Pe&&Object.keys(Pe).length>0||Be&&Object.keys(Be).length>0,console.log("[LearningDetailsForm] 🔍 Checking if warning cards should show:",ct),console.log("[LearningDetailsForm] DBCWtaApiResponse keys:",Pe?Object.keys(Pe).length:0),console.log("[LearningDetailsForm] DBSWtaApiResponse keys:",Be?Object.keys(Be).length:0),ct&&n(iee,{conflictingConditions:[Object.values(Pe||{}),Object.values(Be||{})],baseUrl:O,organizationName:o,chatAssistantName:p||"",curlPayload:null!==(a=null!==(r=null==Le?void 0:Le.curlPayload)&&void 0!==r?r:null===window||void 0===window?void 0:window.__DELETE_CURL__)&&void 0!==a?a:"",onDeleted:function(e){console.log("[LearningDetailsForm] Learning deleted:",e),$e((function(t){return new Set(t).add(e)})),Fe((function(t){if(!t)return{};var n=Object.values(t).filter((function(t){return t.id!==e}));console.log("[LearningDetailsForm] Re-keying conflicting learnings after delete:",{deletedId:e,remainingCount:n.length,remainingLearnings:n.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var r={};return n.forEach((function(e,t){var n=String.fromCharCode(65+t);r[n]=e,console.log("[LearningDetailsForm] Conflicting learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),console.log("[LearningDetailsForm] Final conflicting learnings object:",Object.keys(r)),r})),je((function(t){if(!t)return{};var n=Object.values(t).filter((function(t){return t.id!==e}));console.log("[LearningDetailsForm] Re-keying similar learnings after delete:",{deletedId:e,remainingCount:n.length,remainingLearnings:n.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var r={};return n.forEach((function(e,t){var n=String.fromCharCode(65+t);r[n]=e,console.log("[LearningDetailsForm] Similar learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),console.log("[LearningDetailsForm] Final similar learnings object:",Object.keys(r)),r})),setTimeout((function(){Fe((function(e){return je((function(t){return e&&0!==Object.keys(e).length||t&&0!==Object.keys(t).length||_e(!1),t})),e}))}),100)},onMergeMessage:function(e){console.log("[LearningDetailsForm] 🟡 MERGE MESSAGE RECEIVED:",e),console.log("[LearningDetailsForm] onMergeLearning available:",!!F),F?(console.log("[LearningDetailsForm] Calling onMergeLearning with:",e),F(e)):console.log("[LearningDetailsForm] ❌ onMergeLearning not available")},onDeleteLearning:P,setSendMessageInChat:W,editConflictingLearningTrigger:j,editSimilarLearningTrigger:U,operationStatus:Ge,onOperationComplete:function(){return Ye(null)},onSetOperationStatus:Ye}))]})),e(Yj,M({sx:{display:"flex",gap:2}},{children:[e(Yj,M({sx:{flex:1}},{children:[n(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans"},gutterBottom:!0},{children:"Scope"})),n(tq,M({sx:{width:"50%",fontFamily:"Plus Jakarta Sans"},variant:"outlined"},{children:e(iQ,M({id:"scope",value:Y.scope,onChange:(ot="scope",function(e){K((function(t){var n;return M(M({},t),((n={})[ot]=e.target.value,n))}))}),displayEmpty:!0,sx:{fontFamily:"Plus Jakarta Sans"},fullWidth:!0},{children:[n(dK,M({value:"",disabled:!0},{children:"Select scope"})),u.map((function(e,t){return n(dK,M({value:e.value,sx:{fontFamily:"Plus Jakarta Sans"}},{children:e.labelText}),t)}))]}))}))]})),n(Yj,M({sx:{flex:1,display:"flex",alignItems:"flex-end",justifyContent:"flex-end"}},{children:e(zU,M({variant:"contained",onClick:function(){return b(void 0,void 0,void 0,(function(){return H(this,(function(e){return Qe?(console.warn("Save blocked by button click: Unresolved conflicts are present."),dt(),[2]):(D(!0),[2])}))}))},sx:{width:"30%",height:"56px",fontFamily:"Plus Jakarta Sans",backgroundColor:"green",textTransform:"capitalize","&:hover":{backgroundColor:"#006400"},pointerEvents:Ee?"none":"auto"},disabled:!Xe||Qe},{children:[Ee&&n(SW,{sx:{marginRight:"8px",color:"#fff"},size:16}),Ee?"Saving":"Save"]}))}))]}))]})),Ge&&n(nJ,M({open:!0,autoHideDuration:4e3,onClose:function(){return Ye(null)},anchorOrigin:{vertical:"top",horizontal:"right"}},{children:n(tF,M({onClose:function(){return Ye(null)},severity:Ge.status,sx:{width:"100%"}},{children:Ge.message}))}))]}))},see=function(r){var a=r.open,o=r.selectedText,i=r.scopeOptions,l=r.devModeTag,h=r.submitFunction,d=r.chatAssistantName,u=r.organizationName,m=r.baseUrl,p=r.baseWebsocketUrl,v=r.chatAssistantLogoUrl,f=r.ChatIconComponent,z=r.ggcAssistantName,g=r.closeFunction,y=r.ThinkingBulbIconComponent,E=r.template,b=void 0===E?"":E;r.userQuery,r.topic,r.templateOptions;var H=r.topic_table,V=void 0===H?"".concat(u,"-instantLearning-topics"):H,C=r.variant_table,L=void 0===C?"".concat(u,"-instantLearning-variants"):C,w=r.scope_table,k=void 0===w?"".concat(u,"-instantLearning-scopes"):w,x=r.embedding_column_name,S=void 0===x?"variant_embedding":x,T=r.embedding_model,O=void 0===T?"mxbai-embed-large-v1":T,A=c(a),R=A[0],N=A[1],_=c(!1),D=_[0],P=_[1],F=c(!1),I=F[0],B=F[1],j=c({}),U=j[0],W=j[1],$=c(null),q=$[0],G=$[1],Y=c(!1),K=Y[0],X=Y[1],Q=c(!1),J=Q[0],Z=Q[1],ee=c(null),te=ee[0],ne=ee[1],re=c(""),ae=re[0],oe=re[1],ce=c(!1),ie=ce[0],le=ce[1],se=c(!1),he=se[0],de=se[1],ue=c(!1),me=ue[0],pe=ue[1],ve=c(!1),fe=ve[0],ze=ve[1],ge=c(null),ye=ge[0],Me=ge[1],Ee=function(){N(!1),g()},be=c(null),He=be[0],Ve=be[1],Ce=c(null),Le=Ce[0],we=Ce[1],ke=c(""),xe=ke[0],Se=ke[1],Te=c(null),Oe=Te[0],Ae=Te[1],Re=c(null),Ne=Re[0],_e=Re[1],De=c(!1),Pe=De[0],Fe=De[1],Ie=function(e){Me(e)},Be=c(null),je=Be[0],Ue=Be[1],We=c(!1),$e=We[0],qe=We[1],Ge=function(e){console.log("[InstantLearning] 🟠 HANDLE MERGE LEARNING CALLED:",e),console.log("[InstantLearning] Setting mergeLearningTrigger to:",e),Ue(e),console.log("[InstantLearning] mergeLearningTrigger set successfully")};return s((function(){console.log("[InstantLearning] 🔶 mergeLearningTrigger changed:",je)}),[je]),s((function(){console.log("[InstantLearning] 🔄 resetLearningTrigger changed:",$e)}),[$e]),n(t,{children:e(a$,M({open:R,onClose:Ee,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"95vw",height:"100vh",display:"flex",flexDirection:"column",margin:0,maxWidth:"100vw"}}},{children:[n(UP,M({"aria-label":"close",onClick:Ee,sx:{position:"absolute",right:8,top:8,zIndex:1,color:function(e){return e.palette.grey[500]}}},{children:n("svg",M({width:"28px",height:"28px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"#000000"},{children:n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.707.708L7.293 8l-3.646 3.646.707.708L8 8.707z"})}))})),e(p$,M({sx:{flex:1,overflow:"auto",display:"flex",flexDirection:"row",gap:2}},{children:[n(Yj,M({sx:{minWidth:"350px",maxWidth:"35%",bgcolor:"#f5f5f5",p:0,borderRadius:1,display:"flex",flexDirection:"column"}},{children:n(C7,{chatAssistantLogoUrl:v||"",chatAssistantName:d,organizationName:u,baseUrl:m,setInstantLearningSuggestions:W,formDataState:q,setFormDataState:G,hasUserFilledForm:I,setHasUserFilledForm:B,baseWebsocketUrl:p,setIsNewChatClicked:X,selectedText:o,ChatIconComponent:f,ggcAssistantName:z||"",ThinkingBulbIconComponent:y,hasUserWrittenModification:J,setExtractedModification:ne,setSave:le,setExtractedTooltip:oe,setIsSaveLoading:pe,isSaveLoading:me,save:ie,instantLearningSuggestions:U,template:b,setShouldTriggerSave:ze,validationWtaResponse:He,setValidationWtaResponse:Ve,learningWtaResponse:Le,setLearningWtaResponse:we,isFormSaveClicked:he,setIsFormSavedClicked:de,onDeleteLearning:Ie,deleteLearningTrigger:ye,setDeleteLearningTrigger:Me,onMergeLearning:Ge,mergeLearningTrigger:je,setMergeLearningTrigger:Ue,onResetLearningData:function(){console.log("[InstantLearning] 🔄 RESET CALLBACK TRIGGERED - Setting resetLearningTrigger to true"),qe(!0),setTimeout((function(){qe(!1),console.log("[InstantLearning] 🔄 resetLearningTrigger reset to false")}),100)},setEditConflictingLearningTrigger:Ae,setEditSimilarLearningTrigger:_e,sendMessageInChat:xe,setSendMessageInChat:Se,setIsMergeLoading:Fe})})),n(Yj,M({sx:{minWidth:"65%",maxWidth:"65%",display:"flex",flexDirection:"column"}},{children:n(lee,{organizationName:u,selectedText:o,scopeOptions:i||[],devModeTag:l||"",chatAssistantName:d,submitFunction:h,setShowChat:P,showChat:D,formDataState:q,setFormDataState:G,instantLearningSuggestions:U,setHasUserFilledForm:B,hasUserFilledForm:I,isNewChatClicked:K,setIsNewChatClicked:X,setHasUserWrittenModification:Z,extractedModification:te,save:ie,extractedTooltip:ae,isSaveLoading:me,shouldTriggerSave:fe,baseUrl:m,topic_table:V,variant_table:L,scope_table:k,embedding_column_name:S,embedding_model:O,validationWtaResponse:He,setValidationWtaResponse:Ve,learningWtaResponse:Le,setLearningWtaResponse:we,setIsFormSavedClicked:de,onDeleteLearning:Ie,onMergeLearning:Ge,mergeLearningTrigger:je,resetLearningTrigger:$e,editConflictingLearningTrigger:Oe,editSimilarLearningTrigger:Ne,setSendMessageInChat:Se,isMergeLoading:Pe,setIsMergeLoading:Fe})}))]}))]}))})},hee=function(t){var r=t.color,a=void 0===r?"#4338ca":r;return e("svg",M({xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 56 56",style:{verticalAlign:"middle"}},{children:[n("defs",{children:e("linearGradient",M({id:"sparkleGradient",x1:"0%",y1:"0%",x2:"100%",y2:"0%"},{children:[n("stop",{offset:"0%",stopColor:a}),n("stop",{offset:"100%",stopColor:a})]}))}),n("path",{fill:a,d:"M 26.6875 12.6602 C 26.9687 12.6602 27.1094 12.4961 27.1797 12.2383 C 27.9062 8.3242 27.8594 8.2305 31.9375 7.4570 C 32.2187 7.4102 32.3828 7.2461 32.3828 6.9648 C 32.3828 6.6836 32.2187 6.5195 31.9375 6.4726 C 27.8828 5.6524 28.0000 5.5586 27.1797 1.6914 C 27.1094 1.4336 26.9687 1.2695 26.6875 1.2695 C 26.4062 1.2695 26.2656 1.4336 26.1953 1.6914 C 25.3750 5.5586 25.5156 5.6524 21.4375 6.4726 C 21.1797 6.5195 20.9922 6.6836 20.9922 6.9648 C 20.9922 7.2461 21.1797 7.4102 21.4375 7.4570 C 25.5156 8.2774 25.4687 8.3242 26.1953 12.2383 C 26.2656 12.4961 26.4062 12.6602 26.6875 12.6602 Z M 15.3438 28.7852 C 15.7891 28.7852 16.0938 28.5039 16.1406 28.0821 C 16.9844 21.8242 17.1953 21.8242 23.6641 20.5821 C 24.0860 20.5117 24.3906 20.2305 24.3906 19.7852 C 24.3906 19.3633 24.0860 19.0586 23.6641 18.9883 C 17.1953 18.0977 16.9609 17.8867 16.1406 11.5117 C 16.0938 11.0899 15.7891 10.7852 15.3438 10.7852 C 14.9219 10.7852 14.6172 11.0899 14.5703 11.5352 C 13.7969 17.8164 13.4687 17.7930 7.0469 18.9883 C 6.6250 19.0821 6.3203 19.3633 6.3203 19.7852 C 6.3203 20.2539 6.6250 20.5117 7.1406 20.5821 C 13.5156 21.6133 13.7969 21.7774 14.5703 28.0352 C 14.6172 28.5039 14.9219 28.7852 15.3438 28.7852 Z M 31.2344 54.7305 C 31.8438 54.7305 32.2891 54.2852 32.4062 53.6524 C 34.0703 40.8086 35.8750 38.8633 48.5781 37.4570 C 49.2344 37.3867 49.6797 36.8945 49.6797 36.2852 C 49.6797 35.6758 49.2344 35.2070 48.5781 35.1133 C 35.8750 33.7070 34.0703 31.7617 32.4062 18.9180 C 32.2891 18.2852 31.8438 17.8633 31.2344 17.8633 C 30.6250 17.8633 30.1797 18.2852 30.0860 18.9180 C 28.4219 31.7617 26.5938 33.7070 13.9140 35.1133 C 13.2344 35.2070 12.7891 35.6758 12.7891 36.2852 C 12.7891 36.8945 13.2344 37.3867 13.9140 37.4570 C 26.5703 39.1211 28.3281 40.8321 30.0860 53.6524 C 30.1797 54.2852 30.6250 54.7305 31.2344 54.7305 Z"})]}))};function dee(e,t){void 0===t&&(t=500);var n=c(e),r=n[0],a=n[1];return s((function(){var n=setTimeout((function(){a(e)}),t);return function(){clearTimeout(n)}}),[e,t]),r}var uee={"Azure OpenAI":["gpt-4o","gpt-4o-2024-08-06"],"VertexAI Anthropic":["claude-3.5-sonnet","claude-3-sonnet","claude-3-haiku","claude-3.5-haiku","claude-3.7-sonnet","claude-4-sonnet"],"Google VertexAI":["gemini-2.0-flash","gemini-2.5-flash-lite","gemini-2.5-pro","gemini-2.5-flash","gemini-1.5-pro","gemini-1.0-pro-002","gemini-1.0-pro","gemini-1.5-pro-001","gemini-1.5-pro-002","gemini-1.5-flash-001","gemini-1.5-flash-002"]},mee=function(r){var o,l=r.formState,h=r.setFormState,d=r.config,u=r.isLoadingSuggestions,m=r.onSave,p=r.isSaving,v=r.modelProvider,f=r.setModelProvider,z=r.modelName,g=r.setModelName,y=r.isCheckingExisting,E=r.suggestedFixes,b=r.onRejectFix,H=r.onAcceptFix,C=r.isFixing,L=r.isValidDb,w=r.isFormDirty,k=r.isSaveButtonDisabled,x=r.onValidate;r.validationResponse,r.onFixConflicts;var S=r.formCommand,T=r.setFormCommand,O=c(!1),A=O[0],R=O[1],N=c(l),_=N[0],D=N[1],P=c({}),F=P[0],I=P[1],B=c({}),j=B[0],U=B[1],W=c(null),$=W[0],q=W[1],G=dee(_,2500),Y=i(null),K=i(!1),X=function(t,r){if(C)return e(Yj,M({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",p:2,textAlign:"center",mt:2}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5,color:"#4338ca",mb:1}},{children:[n(SW,{size:20,color:"inherit"}),e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{})," AI fixing Rules...."]}))]})),n(iF,M({sx:{fontSize:"0.9rem",color:"#6b7280",fontFamily:"'Inter', sans-serif",mb:4}},{children:"Our AI is analyzing your requirements and creating new suggestions"})),e(iF,M({sx:{fontSize:"0.85rem",color:"#9ca3af",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:"4px","@keyframes bounce":{"0%, 60%, 100%":{transform:"translateY(0)"},"30%":{transform:"translateY(-8px)"}},"& span":{display:"inline-block",animation:"bounce 1.4s infinite"},"& span:nth-of-type(1)":{animationDelay:"0s"},"& span:nth-of-type(2)":{animationDelay:"0.2s"},"& span:nth-of-type(3)":{animationDelay:"0.4s"}}},{children:[n("span",{children:"●"}),n("span",{children:"●"}),n("span",{children:"●"}),"Please wait..."]}))]}));var a=t[0];return a?e(Yj,M({sx:{mt:2,p:2,border:"1px dashed #6366f1",borderRadius:"8px",backgroundColor:"#f5f3ff"}},{children:[e(Yj,M({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5}},{children:[e(iF,M({variant:"subtitle2",sx:{fontWeight:600,color:"#4338ca",display:"flex",alignItems:"center",gap:1}},{children:[n(hee,{}),"AI Suggestions"]})),e(Yj,M({sx:{display:"flex",alignItems:"center",gap:.5}},{children:[void 0!==a.score&&n(LJ,M({title:"AI Confidence Score",arrow:!0},{children:Q(a.score)})),n(LJ,M({title:"Reject this suggestion"},{children:n(UP,M({size:"small",onClick:function(){return b(r,0)},sx:{color:"#ef4444"}},{children:n(d7,{size:18})}))})),n(LJ,M({title:"Replace all current rules with this one"},{children:n(UP,M({size:"small",onClick:function(){return H(r,a)},sx:{color:"#16a34a"}},{children:n(e7,{size:18})}))}))]}))]})),n(qD,M({elevation:0,sx:{p:"12px 16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e0e0e0"}},{children:n(iF,M({sx:{fontSize:"15px",color:"#1f2937",lineHeight:1.6}},{children:a.text}))})),a.reason&&e(nP,M({expanded:j["".concat(r,"-").concat(0)]||!1,onChange:function(){return function(e,t){var n="".concat(e,"-").concat(t);U((function(e){var t;return M(M({},e),((t={})[n]=!e[n],t))}))}(r,0)},disableGutters:!0,elevation:0,sx:{border:"1px solid #c7d2fe",borderRadius:"8px",overflow:"hidden",mt:1.5,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#4f46e5"}),sx:{backgroundColor:"#eef2ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #c7d2fe",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.85rem",fontWeight:600,color:"#4338ca",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:14}),"Reasoning"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#fdfdff"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:a.reason}))}))]}))]})):null};s((function(){if(!A){D(l);var e={wta:l.wta.map((function(e){return{text:e.text}})),wnta:l.wnta.map((function(e){return{text:e.text}}))};Y.current=JSON.stringify(e)}}),[l,A]),s((function(){if(K.current)K.current=!1;else if(!($&&$.wta.length>0&&0===G.wta.length)){if($){var e=G.wta.length-$.wta.length;if(e>0)if(G.wta.slice(-e).every((function(e){return""===e.text.trim()})))return;var t=G.wnta.length-$.wnta.length;if(t>0)if(G.wnta.slice(-t).every((function(e){return""===e.text.trim()})))return}var n={wta:G.wta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}})),wnta:G.wnta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}}))},r=JSON.stringify(n);A&&!p&&$&&r!==JSON.stringify($)&&r!==Y.current&&(x(G,z),Y.current=r,console.log("Debounced validation useEffect triggered",{isEditing:A,isSaving:p,initialEditState:$,debouncedTempFormState:G,lastValidatedStateRef:Y.current}))}}),[G,A,p,$,z,x]);s((function(){if("SYNC_SNAPSHOT"===S){var e={wta:l.wta.map((function(e){return{text:e.text}})),wnta:l.wnta.map((function(e){return{text:e.text}}))};Y.current=JSON.stringify(e),T(null)}}),[S,l,T]);var Q=function(t){var r,a,o;return t>70?(r="#e9f5ea",a="#34a853",o="#34a853"):t>50?(r="#feefc3",a="#f9ab00",o="#f9ab00"):(r="#fbe9e7",a="#d93025",o="#d93025"),e(Yj,M({sx:{backgroundColor:r,color:a,borderRadius:"14px",padding:"4px 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,fontSize:"12px",fontFamily:"'Inter', sans-serif",gap:"2px"}},{children:[n(hee,{color:o})," ",t.toFixed(1),"%"]}))},J=function(t,r){return e(Yj,u?M({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",p:2,textAlign:"center"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5,color:"#4338ca",mb:1}},{children:[n(SW,{size:20,color:"inherit"}),e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{})," Generating AI Suggestions..."]}))]})),n(iF,M({sx:{fontSize:"0.9rem",color:"#6b7280",fontFamily:"'Inter', sans-serif",mb:4}},{children:"Our AI is analyzing your requirements and creating personalized suggestions"})),e(iF,M({sx:{fontSize:"0.85rem",color:"#9ca3af",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:"4px","@keyframes bounce":{"0%, 60%, 100%":{transform:"translateY(0)"},"30%":{transform:"translateY(-8px)"}},"& span":{display:"inline-block",animation:"bounce 1.4s infinite"},"& span:nth-of-type(1)":{animationDelay:"0s"},"& span:nth-of-type(2)":{animationDelay:"0.2s"},"& span:nth-of-type(3)":{animationDelay:"0.4s"}}},{children:[n("span",{children:"●"}),n("span",{children:"●"}),n("span",{children:"●"}),"Please wait..."]}))]}):y?M({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",p:2,textAlign:"center"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5,color:"#4338ca",mb:1}},{children:[n(SW,{size:20,color:"inherit"}),e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{})," Checking for existing rules..."]}))]})),n(iF,M({sx:{fontSize:"0.9rem",color:"#6b7280",fontFamily:"'Inter', sans-serif",mb:4}},{children:"Comparing rules with other agents in the database."})),e(iF,M({sx:{fontSize:"0.85rem",color:"#9ca3af",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:"4px","@keyframes bounce":{"0%, 60%, 100%":{transform:"translateY(0)"},"30%":{transform:"translateY(-8px)"}},"& span":{display:"inline-block",animation:"bounce 1.4s infinite"},"& span:nth-of-type(1)":{animationDelay:"0s"},"& span:nth-of-type(2)":{animationDelay:"0.2s"},"& span:nth-of-type(3)":{animationDelay:"0.4s"}}},{children:[n("span",{children:"●"}),n("span",{children:"●"}),n("span",{children:"●"}),"Please wait..."]}))]}):M({sx:{backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"16px",display:"flex",flexDirection:"column",flex:1,opacity:p?.6:1,pointerEvents:p?"none":"auto"}},{children:[n(Yj,M({sx:{display:"flex",flexDirection:"column",gap:2,flex:1}},{children:t.length>0?t.map((function(t,o){return e(a.Fragment,{children:[e(Yj,M({sx:{backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"8px 12px",display:"flex",alignItems:"center",gap:2}},{children:[e(iF,M({sx:{fontSize:"15px",fontWeight:500,color:"#6b7280"}},{children:[o+1,"."]})),A?n(j2,{value:t.text,onChange:function(e){return function(e,t,n){D((function(r){var a,o=V([],r[e],!0);return o[t]=M(M({},o[t]),{text:n}),M(M({},r),((a={})[e]=o,a))}))}(r,o,e.target.value)},variant:"standard",multiline:!0,placeholder:"Enter a rule...",disabled:p,InputProps:{disableUnderline:!0},sx:{flex:1,fontSize:"15px"}}):n(iF,M({sx:{fontSize:"15px",color:"#1f2937",flex:1,lineHeight:1.5,wordBreak:"break-word"}},{children:t.text})),void 0!==t.score&&n(LJ,M({title:"AI Confidence Score",arrow:!0},{children:Q(t.score)})),A&&n(UP,M({size:"small",onClick:function(){return function(e,t){D((function(n){var r;return M(M({},n),((r={})[e]=n[e].filter((function(e,n){return n!==t})),r))}))}(r,o)},disabled:p,sx:{color:"#9ca3af","&:hover":{color:"#ef4444"}}},{children:n(d7,{size:16})}))]})),t.reason&&!A&&e(nP,M({expanded:F["".concat(r,"-").concat(o)]||!1,onChange:function(){return function(e,t){var n="".concat(e,"-").concat(t);I((function(e){var t;return M(M({},e),((t={})[n]=!e[n],t))}))}(r,o)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.85rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:16})," ","wta"===r?"Reason behind When To Apply":"Reason behind When Not To Apply"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#ffffff"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:t.reason}))}))]}))]},o)})):n(Yj,M({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"}},{children:!A&&n(iF,M({sx:{color:"#9ca3af",textAlign:"center"}},{children:"No rules defined."}))}))})),A&&n(zU,M({startIcon:n(c7,{size:16}),onClick:function(){return function(e){D((function(t){var n;return M(M({},t),((n={})[e]=V(V([],t[e],!0),[{text:""}],!1),n))}))}(r)},disabled:p,sx:{color:"#6366f1",fontSize:"15px",fontWeight:500,textTransform:"none",mt:t.length>0?2:0,alignSelf:"flex-start"}},{children:"Add Rule"}))]}))};return e(qD,M({elevation:3,sx:{padding:"24px",width:"100%",maxWidth:"950px",margin:"20px",boxSizing:"border-box",borderRadius:"12px",position:"relative"}},{children:[e(Yj,M({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3}},{children:[n(Yj,{children:e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:[n(iF,M({variant:"h5",component:"h2",gutterBottom:!0,sx:{display:"flex",fontWeight:"600",alignItems:"center",gap:1.5,fontFamily:"'Inter', sans-serif",mb:0}},{children:d.mainTitle})),n(LJ,M({title:d.mainTitleTooltip,arrow:!0,slotProps:{tooltip:{sx:{fontSize:"0.8rem",padding:"0.5rem",fontFamily:"'Inter', sans-serif"}}}},{children:n(n7,{size:13,color:"#494d55ff",style:{cursor:"pointer"}})})),e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5}},{children:[n(hee,{}),n(Yj,M({component:"span",sx:{fontWeight:600,fontSize:"1rem",background:"linear-gradient(90deg, #6a11cb 0%, #2575fc 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",display:"inline-block"}},{children:"AI Suggested"}))]}))]}))}),e(Yj,M({sx:{display:"flex",gap:2}},{children:[e(tq,M({size:"small",sx:{minWidth:180}},{children:[n(kG,{children:"Model Provider"}),n(iQ,M({value:v,label:"Model Provider",onChange:function(e){var t=e.target.value;f(t),g(uee[t][0])}},{children:Object.keys(uee).map((function(e){return n(dK,M({value:e},{children:e}),e)}))}))]})),e(tq,M({size:"small",sx:{minWidth:180}},{children:[n(kG,{children:"Model Name"}),n(iQ,M({value:z,label:"Model Name",onChange:function(e){g(e.target.value)}},{children:null===(o=uee[v])||void 0===o?void 0:o.map((function(e){return n(dK,M({value:e},{children:e}),e)}))}))]}))]}))]})),e(Yj,M({sx:{display:"flex",gap:"24px",alignItems:"stretch"}},{children:[e(Yj,M({sx:{flex:1,backgroundColor:"#ffffff",display:"flex",flexDirection:"column"}},{children:[e(iF,M({variant:"subtitle1",sx:{fontWeight:600,marginBottom:"12px",color:"#1f2937",fontSize:"16px",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center"}},{children:["When to Apply ",n("span",M({style:{color:"red",marginRight:"8px"}},{children:"*"})),n(LJ,M({title:d.wtaTooltip,arrow:!0,slotProps:{tooltip:{sx:{fontSize:"0.8rem",padding:"0.5rem",fontFamily:"'Inter', sans-serif"}}}},{children:n(n7,{size:13,color:"#494d55ff",style:{cursor:"pointer"}})}))]})),J(A?_.wta:l.wta,"wta"),!A&&X(E.wta,"wta")]})),e(Yj,M({sx:{flex:1,backgroundColor:"#ffffff",display:"flex",flexDirection:"column"}},{children:[e(iF,M({variant:"subtitle1",sx:{fontWeight:600,marginBottom:"12px",color:"#1f2937",fontSize:"16px",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center"}},{children:["When Not To Apply",n(LJ,M({title:d.wntaTooltip,arrow:!0,slotProps:{tooltip:{sx:{fontSize:"0.8rem",padding:"0.5rem",fontFamily:"'Inter', sans-serif"}}}},{children:n(n7,{size:13,color:"#494d55ff",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),J(A?_.wnta:l.wnta,"wnta"),!A&&X(E.wnta,"wnta")]}))]})),n(Yj,M({sx:{display:"flex",justifyContent:"flex-end",mt:3}},{children:e(t,A?{children:[n(zU,M({onClick:function(){K.current=!1,D(l),R(!1),q(null),Y.current=null},variant:"outlined",disabled:p,sx:{marginRight:"8px",borderColor:"#6b7280",color:"#6b7280",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#f9fafb",borderColor:"#4b5563"}}},{children:"Cancel"})),n(zU,M({onClick:function(){K.current=!1;var e={wta:_.wta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}})),wnta:_.wnta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}}))},t=JSON.stringify(e);t!==Y.current&&(console.log("State changed on confirm, triggering immediate validation."),x(e,z),Y.current=t),h(e),R(!1),q(null)},disabled:p,variant:"contained",sx:{backgroundColor:"#4f46e5",color:"white",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#4338ca"}}},{children:"Confirm"}))]}:{children:[n(zU,M({onClick:function(){K.current=!0,D(l);var e={wta:l.wta.map((function(e){return{text:e.text}})),wnta:l.wnta.map((function(e){return{text:e.text}}))};q(e),R(!0)},variant:"outlined",disabled:u||p||y,startIcon:n(i7,{size:16}),sx:{marginRight:"8px",borderColor:"#6b7280",color:"#6b7280",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#f9fafb",borderColor:"#4b5563"}}},{children:"Edit"})),n(zU,M({variant:"contained",onClick:function(){return m(l)},disabled:k,sx:{backgroundColor:"#4f46e5",color:"white",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#4338ca"}}},{children:p?"Validating...":L&&!w?"Save":"Validate"}))]})}))]}))},pee=function(t){var r=function(e){return Math.round(Math.min(e,100))}(t.score),a={bg:"#f2f0f2",text:"#343f52"};return n(LJ,M({title:"AI Confidence Score",placement:"top",arrow:!0},{children:e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,mr:1,py:.5,borderRadius:"16px",backgroundColor:a.bg,color:a.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{color:a.text}),e(iF,M({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[r,"%"]}))]}))}))},vee=function(t){var r,a,o=t.validationResponse,i=t.onFixConflicts,l=V(V([],(null===(r=o.cross_validation)||void 0===r?void 0:r.map((function(e){return M(M({},e),{type:"Cross-Validation"})})))||[],!0),(null===(a=o.duplication)||void 0===a?void 0:a.map((function(e){var t={reason:e.reason,confidence_score:e.confidence_score,type:"Duplication"},n=e.duplicate_conditions.join("\n");return"wta"===e.type?(t.condition_wta=n,t.type="Duplication (When to Apply)"):(t.condition_wnta=n,t.type="Duplication (When Not to Apply)"),t})))||[],!0),s=c(!1),h=s[0],d=s[1],u=c(l.map((function(e,t){return t}))),m=u[0],p=u[1],v=c({}),f=v[0],z=v[1];if(o.is_valid)return null;var g=function(e){return String.fromCharCode(65+e)};return e(qD,M({elevation:0,sx:{width:"100%",maxWidth:"950px",margin:"20px auto",backgroundColor:"#FFFFFF",border:"1px solid #b3b3b3ff",padding:3,borderRadius:"12px",fontFamily:"'Inter', sans-serif"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontSize:"1.1rem",fontWeight:700,color:"#B91C1C"}},{children:"Validation Failed: Conflicts Found"})),n(LJ,M({slotProps:{tooltip:{sx:{fontSize:"0.9rem"}}},title:"The rules you've defined have logical conflicts. Please review and resolve them below.",arrow:!0},{children:n(n7,{size:16,color:"#B91C1C",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),o.correctness&&e(nP,M({expanded:h,onChange:function(){return d(!h)},disableGutters:!0,elevation:0,sx:{backgroundColor:"transparent",border:"1px solid #FCD34D",borderRadius:2,mb:2,"&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:20,color:"#92400E"}),sx:{backgroundColor:"#fef9f2",borderRadius:h?"8px 8px 0 0":2}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1}},{children:[n(tee,{style:{color:"#bb7601",fontSize:"1.2rem"}}),n(iF,M({sx:{fontSize:"0.95rem",fontWeight:600,color:"#bb7601"}},{children:"Why Validation Failed?"}))]})),n(pee,{score:o.correctness.confidence_score})]}))})),n(hP,M({sx:{p:1.5,backgroundColor:"#fcf8efff"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#bb7601"}},{children:o.correctness.reason}))}))]})),n(Yj,M({sx:{maxHeight:400,overflowY:"auto",pr:1.5}},{children:l.map((function(t,r){var a,o,c=m.includes(r),i=!!t.condition_wta,l=!!t.condition_wnta;return e(nP,M({expanded:c,onChange:function(){return function(e){p((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(r)},disableGutters:!0,sx:{mb:1.5,border:"1px solid #FCA5A5",borderRadius:"3px","&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:20,color:"#991B1B"}),sx:{backgroundColor:"#FEF2F2",borderBottom:c?"1px solid #FCA5A5":"none"}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[n(iF,M({sx:{color:"#991B1B",fontWeight:600,fontSize:"0.95rem"}},{children:"".concat(g(r),". ").concat(t.type," Conflict")})),n(pee,{score:t.confidence_score})]}))})),e(hP,M({sx:{px:2,pb:2,backgroundColor:"#FFF"}},{children:[e(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:i&&l?"row":"column"},gap:2,mb:2}},{children:[i&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:null===(a=t.condition_wta)||void 0===a?void 0:a.split("\n").map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]})),l&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When NOT to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:null===(o=t.condition_wnta)||void 0===o?void 0:o.split("\n").map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]}))]})),e(nP,M({expanded:f[r]||!1,onChange:function(){return function(e){z((function(t){var n;return M(M({},t),((n={})[e]=!t[e],n))}))}(r)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.9rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:16})," Reason behind validation failure?"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#f9fafb"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:t.reason}))}))]}))]}))]}),r)}))})),n(Yj,M({sx:{display:"flex",justifyContent:"flex-end",mt:2}},{children:n(zU,M({variant:"contained",onClick:i,startIcon:n(h7,{size:20}),sx:{backgroundColor:"transparent",textTransform:"none",fontWeight:600,border:"1px solid #838383ff",color:"#4a4a4aff",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#f4f4f4ff"}}},{children:"Auto Fix Conflicts"}))}))]}))},fee=function(t){var r=function(e){return Math.round(Math.min(e,100))}(t.score),a={bg:"#f2f0f2",text:"#343f52"};return n(LJ,M({title:"AI Confidence Score",placement:"top",arrow:!0},{children:e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,mr:1,py:.5,borderRadius:"16px",backgroundColor:a.bg,color:a.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{color:a.text}),e(iF,M({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[r,"%"]}))]}))}))},zee=function(t){var r=t.similarRules,a=t.showUpdateWarning,o=c(r.map((function(e,t){return t}))),i=o[0],l=o[1],s=c({}),h=s[0],d=s[1];if(!r||0===r.length)return null;var u=function(e){return String.fromCharCode(65+e)};return e(qD,M({elevation:0,sx:{width:"100%",maxWidth:"950px",margin:"20px auto",backgroundColor:"#FFFFFF",border:"1px solid #b3b3b3ff",padding:3,borderRadius:"12px",fontFamily:"'Inter', sans-serif"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontSize:"1.1rem",fontWeight:700,color:"#B91C1C"}},{children:"Similar Rules Detected"})),n(LJ,M({slotProps:{tooltip:{sx:{fontSize:"0.9rem"}}},title:"The rules you've defined are similar to existing rules in other agents. Please review them to avoid redundancy.",arrow:!0},{children:n(n7,{size:16,color:"#B91C1C",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),n(Yj,M({sx:{maxHeight:400,overflowY:"auto",pr:1.5}},{children:r.map((function(t,r){var a=i.includes(r),o=t.wtaRules&&t.wtaRules.length>0,c=t.wntaRules&&t.wntaRules.length>0;return e(nP,M({expanded:a,onChange:function(){return function(e){l((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(r)},disableGutters:!0,sx:{mb:1.5,border:"1px solid #FCA5A5",borderRadius:"3px","&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:20,color:"#991B1B"}),sx:{backgroundColor:"#FEF2F2",borderBottom:a?"1px solid #FCA5A5":"none"}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[n(iF,M({sx:{color:"#991B1B",fontWeight:600,fontSize:"0.95rem"}},{children:"".concat(u(r),". ").concat(t.agentName," has a similar rule")})),n(fee,{score:t.confidenceScore})]}))})),e(hP,M({sx:{px:2,pb:2,backgroundColor:"#FFF"}},{children:[e(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:o&&c?"row":"column"},gap:2,mb:2}},{children:[o&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:t.wtaRules.map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]})),c&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When NOT to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:t.wntaRules.map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]}))]})),e(nP,M({expanded:h[r]||!1,onChange:function(){return function(e){d((function(t){var n;return M(M({},t),((n={})[e]=!t[e],n))}))}(r)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.9rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:16})," Reason for Similarity?"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#f9fafb"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:t.reason}))}))]}))]}))]}),r)}))})),a&&n(Yj,M({sx:{mt:3,p:1.5,borderRadius:"8px",backgroundColor:"#FFFBEB",border:"1px solid #FCD34D"}},{children:e(iF,M({sx:{color:"#B45309",fontSize:"0.9rem",fontWeight:500,fontFamily:"'Inter', sans-serif"}},{children:[n("strong",{children:"Warning:"})," Please update the current rules since there already exists a similar rule."]}))}))]}))},gee="WtaWnta-module_parentContainer__-2Txc";C('@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400..900&display=swap");body{font-family:Inter,sans-serif}.WtaWnta-module_parentContainer__-2Txc{align-items:center;background-color:#f0f2f5;box-sizing:border-box;display:flex;flex-direction:column;gap:"24px";min-height:100vh;padding:2rem}');var yee={"agent-genie":{mainTitle:"Set Agent Rules",mainTitleTooltip:"Assistant would use these rules or conditions to call your agent.",wtaTitle:"When to Apply",wtaTooltip:"Specific rules or conditions where the agent must be called",wntaTitle:"When Not To Apply",wntaTooltip:"Specific rules or conditions where the agent should never be called."},"prompt-genie":{mainTitle:"Set Template Rules",mainTitleTooltip:"Set rules or conditions to get best response from the system prompt",wtaTitle:"When to Apply",wtaTooltip:"Specific rules or conditions where the template must be used",wntaTitle:"When Not To Apply",wntaTooltip:"Specific rules or conditions where the template must not be used"},"coding-standards":{mainTitle:"Set Coding Standards",mainTitleTooltip:"The assistant will enforce these coding standards.",wtaTitle:"Must Have",wtaTooltip:"Essential coding standards that must be followed.",wntaTitle:"Must Not Have",wntaTooltip:"Coding practices that should be avoided."}},Mee=function(t){var r=yee[t.mode],a=c((function(){return"agent-genie"===t.mode&&(t.wta||t.wnta)?{wta:(t.wta||[]).map((function(e){return{text:e}})),wnta:(t.wnta||[]).map((function(e){return{text:e}}))}:{wta:[],wnta:[]}})),o=a[0],i=a[1],h=c(null),d=h[0],u=h[1],m=c({wta:[],wnta:[]}),p=m[0],v=m[1],f=c(0),z=f[0];f[1];var g=c(!0),y=g[0],E=g[1],V=c("Google VertexAI"),C=V[0],L=V[1],w=c("gemini-2.5-flash-lite"),k=w[0],x=w[1],S=c(null),T=S[0],O=S[1],A="agent-genie"===t.mode?t:{},R=A.agent_context,N=void 0===R?"":R,_=A.agent_description,D=void 0===_?"":_,P=A.agent_id,F=void 0===P?null:P,I=A.assistant_name,B=void 0===I?"":I,j=A.organization_name,U=void 0===j?"":j,W=A.base_url,$=void 0===W?"":W,q=A.wta,G=void 0===q?[]:q,Y=A.wnta,K=void 0===Y?[]:Y,X="agent-genie"===t.mode&&0===G.length&&0===K.length,Q="prompt-genie"===t.mode?t:{},J=Q.template_context,Z=void 0===J?"":J,ee=Q.template_description,te=void 0===ee?"":ee,ne=Q.baseUrl,re=void 0===ne?"":ne,ae=function(e,t,n,r,a,o){void 0===a&&(a=!0);var i=c([]),l=i[0],h=i[1],d=c(!1),u=d[0],m=d[1],p=c(null),v=p[0],f=p[1],z=dee(e,500),g=dee(t,500);return s((function(){g&&a?b(void 0,void 0,void 0,(function(){var e,t,n,a,c,i,l;return H(this,(function(s){switch(s.label){case 0:console.log("[".concat((new Date).toLocaleTimeString(),"] Attempting to fetch suggestions...")),m(!0),f(null),s.label=1;case 1:return s.trys.push([1,4,5,6]),e={agent_context:z,agent_description:g,mode:"AgentGenie",llm:r,n:1},console.log("API Payload:",e),[4,fetch("".concat(o,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 2:if(!(t=s.sent()).ok)throw new Error("API Error: ".concat(t.statusText));return[4,t.json()];case 3:return n=s.sent(),a=[],null===(i=n.response.conditions_whentoapply)||void 0===i||i.forEach((function(e){a.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(l=n.response.conditions_whennottoapply)||void 0===l||l.forEach((function(e){a.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),h(a),[3,6];case 4:return c=s.sent(),console.error("Failed to fetch suggestions:",c),f(c),[3,6];case 5:return m(!1),[7];case 6:return[2]}}))})):h([])}),[z,g,n,a]),{suggestions:l,isLoading:u,error:v}}(N,D,z,k,X,$),oe=ae.suggestions,ce=ae.isLoading,ie=ae.error,le=function(e,t,n,r,a,o){void 0===a&&(a=!0);var i=c([]),l=i[0],h=i[1],d=c(!1),u=d[0],m=d[1],p=c(null),v=p[0],f=p[1],z=dee(e,500),g=dee(t,500);return s((function(){z&&g&&a?b(void 0,void 0,void 0,(function(){var e,t,n,a,c,i,l;return H(this,(function(s){switch(s.label){case 0:m(!0),f(null),s.label=1;case 1:return s.trys.push([1,4,5,6]),e={template_context:z,template_description:g,mode:"PromptGenie",llm:r,n:1},[4,fetch("".concat(o,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 2:if(!(t=s.sent()).ok)throw new Error("API Error: ".concat(t.statusText));return[4,t.json()];case 3:return n=s.sent(),a=[],null===(i=n.response.conditions_whentoapply)||void 0===i||i.forEach((function(e){a.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(l=n.response.conditions_whennottoapply)||void 0===l||l.forEach((function(e){a.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),h(a),[3,6];case 4:return c=s.sent(),console.error("Failed to fetch prompt suggestions:",c),f(c),[3,6];case 5:return m(!1),[7];case 6:return[2]}}))})):h([])}),[z,g,n,a]),{suggestions:l,isLoading:u,error:v}}(Z,te,z,k,"prompt-genie"===t.mode,re),se=le.suggestions,he=le.isLoading,de=function(e,t,n){var r=c(!1),a=r[0],o=r[1],i=c(null),s=i[0],h=i[1],d=c(null),u=d[0],m=d[1],p=l((function(r,a){return b(void 0,void 0,void 0,(function(){var c,i,l,s;return H(this,(function(d){switch(d.label){case 0:if(o(!0),h(null),m(null),0===(c={agent_context:e,agent_description:t,mode:"AgentGenie",llm:a,wta:r.wta.map((function(e){return e.text})),wnta:r.wnta.map((function(e){return e.text}))}).wta.length)return console.error("WTA conditions cannot be empty."),o(!1),[2,null];d.label=1;case 1:return d.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(i=d.sent()).ok)throw new Error("API Error: ".concat(i.statusText));return[4,i.json()];case 3:return(l=d.sent()).response.is_valid?(console.log("Validation Successful!"),h(null)):(console.warn("Validation failed, conflicts found."),h(l.response)),[2,l.response];case 4:return s=d.sent(),console.error("Failed to validate rules:",s),m(s),[2,null];case 5:return o(!1),[7];case 6:return[2]}}))}))}),[e,t,n]);return{validateAgentRules:p,clearValidation:function(){h(null)},isSaving:a,validationResponse:s,error:u}}(N,D,$),ue=de.validateAgentRules,me=de.clearValidation,pe=de.isSaving,ve=de.validationResponse,fe=de.error,ze=function(e,t,n,r){void 0===n&&(n=!0);var a=c(!1),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1],d=c(null),u=d[0],m=d[1];return{validateRules:function(a,o){return b(void 0,void 0,void 0,(function(){var c,l,s,d;return H(this,(function(u){switch(u.label){case 0:if(!n)return[2,null];if(i(!0),h(null),m(null),0===(c={template_context:e,template_description:t,wta:a.wta.map((function(e){return e.text})),wnta:a.wnta.map((function(e){return e.text})),mode:"PromptGenie",llm_model:o}).wta.length)return console.error("WTA conditions cannot be empty."),m(new Error("When to Apply conditions cannot be empty.")),i(!1),[2,null];u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,fetch("".concat(r,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(l=u.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(s=u.sent()).response.is_valid?(console.log("Prompt Validation Successful!"),h(null)):(console.warn("Prompt Validation failed, conflicts found."),h(s.response)),[2,s.response];case 4:return d=u.sent(),console.error("Failed to validate prompt rules:",d),m(d),[2,null];case 5:return i(!1),[7];case 6:return[2]}}))}))},clearValidation:function(){h(null)},isSaving:o,validationResponse:s,error:u}}(Z,te,"prompt-genie"===t.mode,re),ge=ze.validateRules,ye=ze.clearValidation,Me=ze.isSaving,Ee=ze.validationResponse,be=function(e){var t=c(!1),n=t[0],r=t[1],a=c(null),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1];return{checkExistingRules:function(t,n,a,o){return b(void 0,void 0,void 0,(function(){var c,l,s,d;return H(this,(function(u){switch(u.label){case 0:r(!0),h(null),i(null),c={mode:"AgentGenie",assistantname:a,organizationname:o,wta:t.wta.map((function(e){return e.text})),wnta:t.wnta.map((function(e){return e.text})),agent_id:n},console.log("Checking for existing DB conflicts with payload:",c),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,fetch("".concat(e,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(l=u.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(s=u.sent()).response?(console.log("DB check successful. Setting state with:",s.response),i(s.response)):(console.error("DB check: API response object was missing."),i(null)),[3,6];case 4:return d=u.sent(),console.error("Failed to check for existing rules:",d),h(d),[3,6];case 5:return r(!1),[7];case 6:return[2]}}))}))},isLoading:n,existingConflicts:o,error:s,clearExistingAgentConflicts:function(){i(null)}}}($),He=be.checkExistingRules,Ve=be.isLoading,Ce=be.existingConflicts,Le=be.error,we=be.clearExistingAgentConflicts,ke=function(e){var t=c(!1),n=t[0],r=t[1],a=c([]),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1];return{fixAgentRules:function(t,n,a,o,c){return b(void 0,void 0,void 0,(function(){var l,s,d,u,m,p,v;return H(this,(function(f){switch(f.label){case 0:r(!0),i([]),h(null),l=M(M({},t),{wta:n.wta.map((function(e){return e.text})),wnta:n.wnta.map((function(e){return e.text})),mode:"AgentGenie",agent_description:o,agent_context:a,llm:c,n:1}),f.label=1;case 1:return f.trys.push([1,4,5,6]),[4,fetch("".concat(e,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})];case 2:if(!(s=f.sent()).ok)throw new Error("API Error: ".concat(s.statusText));return[4,s.json()];case 3:return d=f.sent(),u=[],null===(p=d.response.conditions_whentoapply)||void 0===p||p.forEach((function(e){u.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(v=d.response.conditions_whennottoapply)||void 0===v||v.forEach((function(e){u.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),i(u),[3,6];case 4:return m=f.sent(),console.error("Failed to fix rules:",m),h(m),[3,6];case 5:return r(!1),[7];case 6:return[2]}}))}))},isFixing:n,fixedSuggestions:o,error:s}}($),xe=ke.fixAgentRules,Se=ke.isFixing,Te=ke.fixedSuggestions,Oe=ke.error,Ae=function(e){var t=c(!1),n=t[0],r=t[1],a=c([]),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1];return{fixPromptRules:function(t,n,a,o,c){return b(void 0,void 0,void 0,(function(){var l,s,d,u,m,p,v;return H(this,(function(f){switch(f.label){case 0:r(!0),i([]),h(null),l=M(M({},t),{wta:n.wta.map((function(e){return e.text})),wnta:n.wnta.map((function(e){return e.text})),mode:"PromptGenie",template_context:a,template_description:o,llm:c}),f.label=1;case 1:return f.trys.push([1,4,5,6]),[4,fetch("".concat(e,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})];case 2:if(!(s=f.sent()).ok)throw new Error("API Error: ".concat(s.statusText));return[4,s.json()];case 3:return d=f.sent(),u=[],null===(p=d.response.conditions_whentoapply)||void 0===p||p.forEach((function(e){u.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(v=d.response.conditions_whennottoapply)||void 0===v||v.forEach((function(e){u.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),i(u),[3,6];case 4:return m=f.sent(),console.error("Failed to fix prompt rules:",m),h(m),[3,6];case 5:return r(!1),[7];case 6:return[2]}}))}))},isFixing:n,fixedSuggestions:o,error:s}}(re),Re=Ae.fixPromptRules,Ne=Ae.isFixing,_e=Ae.fixedSuggestions,De=Se||Ne,Pe="agent-genie"===t.mode?Te:_e,Fe=ce||he,Ie=pe||Me,Be=ve||Ee,je="agent-genie"===t.mode?oe:se,Ue=!d||JSON.stringify(o)!==JSON.stringify(d),We=!(!Be||Be.is_valid),$e=Ie||Fe||Ve||We&&!Ue;s((function(){if(Pe.length>0){var e=Pe.filter((function(e){return"wta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}})),t=Pe.filter((function(e){return"wnta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}}));v({wta:e,wnta:t})}}),[Pe]),s((function(){if(je.length>0){var e=je.filter((function(e){return"wta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}})),t=je.filter((function(e){return"wnta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}}));i({wta:e,wnta:t})}}),[je]);var qe=function(){return b(void 0,void 0,void 0,(function(){return H(this,(function(e){switch(e.label){case 0:return Be?(me(),ye(),"agent-genie"!==t.mode?[3,2]:[4,xe(Be,o,N,D,k)]):[2];case 1:return e.sent(),[3,4];case 2:return"prompt-genie"!==t.mode?[3,4]:[4,Re(Be,o,Z,te,k)];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))};if(ie||fe||Le||Oe){var Ge=ie||fe||Le||Oe;return e(iF,M({color:"error"},{children:["An error occurred: ",null==Ge?void 0:Ge.message]}))}var Ye=((null==Ce?void 0:Ce.similar_conditions)||[]).map((function(e){return{agentName:e.ui_name,confidenceScore:e.confidence_score,reason:e.reason,wtaRules:[e.when_to_use],wntaRules:e.when_not_to_use?[e.when_not_to_use]:[]}}));return e(Yj,M({className:gee},{children:[Be&&!Be.is_valid&&n(vee,{validationResponse:Be,onFixConflicts:qe}),Ce&&Ce.similar_conditions.length>0&&y&&n(zee,{similarRules:Ye,showUpdateWarning:!(null==Ce?void 0:Ce.is_valid_db)}),n(mee,{formState:o,setFormState:i,config:r,isLoadingSuggestions:Fe,onSave:function(e){return b(void 0,void 0,void 0,(function(){var n,r,a,c;return H(this,(function(l){switch(l.label){case 0:return(null==Ce?void 0:Ce.is_valid_db)&&!Ue?"agent-genie"===t.mode?(n=o.wta.map((function(e){return e.text})).join(" OR "),r=o.wnta.map((function(e){return e.text})).join(" OR "),console.log("Save to DB clicked for Agent Genie. Final strings prepared."),console.log("When to Apply:",n),console.log("When Not to Apply:",r),null===(c=t.onSaveComplete)||void 0===c||c.call(t,{wta:n,wnta:r}),[2]):[2]:(u(e),E(!1),i(e),"agent-genie"!==t.mode?[3,4]:[4,ue(e,k)]);case 1:return(a=l.sent())&&a.is_valid?(E(!0),[4,He(e,F,B,U)]):[3,3];case 2:l.sent(),l.label=3;case 3:return[3,7];case 4:return"prompt-genie"!==t.mode?[3,6]:[4,ge(e,k)];case 5:return l.sent(),[3,7];case 6:console.log("Save triggered in '".concat(t.mode,"' mode. Skipping API calls.")),l.label=7;case 7:return[2]}}))}))},isSaving:Ie,isCheckingExisting:Ve,modelProvider:C,setModelProvider:L,modelName:k,setModelName:x,suggestedFixes:p,onRejectFix:function(e,n){"agent-genie"===t.mode?(me(),we&&we()):"prompt-genie"===t.mode&&ye(),v((function(t){var r;return M(M({},t),((r={})[e]=t[e].filter((function(e,t){return t!==n})),r))}))},onAcceptFix:function(e,n){var r;"agent-genie"===t.mode?(me(),we&&we()):"prompt-genie"===t.mode&&ye();var a=M(M({},o),((r={})[e]=[{text:n.text}],r));i((function(t){var r;return M(M({},t),((r={})[e]=[{text:n.text}],r))})),u(a),O("SYNC_SNAPSHOT"),v((function(t){var n;return M(M({},t),((n={})[e]=[],n))}))},isFixing:De,isValidDb:(null==Ce?void 0:Ce.is_valid_db)||!1,isSaveButtonDisabled:$e,isFormDirty:Ue,onValidate:function(e,n){return b(void 0,void 0,void 0,(function(){var r,a;return H(this,(function(o){switch(o.label){case 0:return E(!1),u(e),r={wta:e.wta.map((function(e){return{text:e.text}})),wnta:e.wnta.map((function(e){return{text:e.text}}))},u(r),"agent-genie"!==t.mode?[3,4]:[4,ue(e,n)];case 1:return(a=o.sent())&&a.is_valid?(E(!0),[4,He(e,F,B,U)]):[3,3];case 2:o.sent(),o.label=3;case 3:return[3,6];case 4:return"prompt-genie"!==t.mode?[3,6]:[4,ge(e,n)];case 5:o.sent(),o.label=6;case 6:return[2]}}))}))},validationResponse:Be,onFixConflicts:qe,formCommand:T,setFormCommand:O})]}))},Eee="PdfEditorCitation-module_citationRoot__5OtUI",bee="PdfEditorCitation-module_citationTitle__X9kQm",Hee="PdfEditorCitation-module_citationBody__C99jX",Vee="PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V";C(".PdfEditorCitation-module_citationRoot__5OtUI{display:flex;flex-direction:column}.PdfEditorCitation-module_citationTitle__X9kQm{align-items:center;background-color:#eff6ff;border:1px solid #000;border-radius:10px;cursor:pointer;display:inline-flex;gap:10px;padding:5px 8px;width:fit-content}.PdfEditorCitation-module_citationBody__C99jX{background-color:#fff;flex-grow:1}.PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V{display:none}.PdfEditorCitation-module_citationBodyWhenFullScreen__VKtop{bottom:0;height:100%!important;left:0;max-height:100%;position:absolute;right:0;top:0;width:100%!important}");var Cee,Lee={};var wee,kee=function(){if(Cee)return Lee;Cee=1;var e=p_(),t=S7();Object.defineProperty(Lee,"__esModule",{value:!0}),Lee.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");return Lee.default=r,Lee}(),xee=Se(kee),See={};var Tee=function(){if(wee)return See;wee=1;var e=p_(),t=S7();Object.defineProperty(See,"__esModule",{value:!0}),See.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");return See.default=r,See}(),Oee=Se(Tee),Aee=function(){return Aee=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},Aee.apply(this,arguments)};function Ree(e,t,n,r){return new(n||(n=Promise))((function(a,o){function c(e){try{l(r.next(e))}catch(e){o(e)}}function i(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){e.done?a(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(c,i)}l((r=r.apply(e,t||[])).next())}))}function Nee(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=i(0),c.throw=i(1),c.return=i(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,i[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function _ee(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var Dee=void 0!==ot?ot:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function Pee(){throw new Error("setTimeout has not been defined")}function Fee(){throw new Error("clearTimeout has not been defined")}var Iee=Pee,Bee=Fee;function jee(e){if(Iee===setTimeout)return setTimeout(e,0);if((Iee===Pee||!Iee)&&setTimeout)return Iee=setTimeout,setTimeout(e,0);try{return Iee(e,0)}catch(t){try{return Iee.call(null,e,0)}catch(t){return Iee.call(this,e,0)}}}"function"==typeof Dee.setTimeout&&(Iee=setTimeout),"function"==typeof Dee.clearTimeout&&(Bee=clearTimeout);var Uee,Wee=[],$ee=!1,qee=-1;function Gee(){$ee&&Uee&&($ee=!1,Uee.length?Wee=Uee.concat(Wee):qee=-1,Wee.length&&Yee())}function Yee(){if(!$ee){var e=jee(Gee);$ee=!0;for(var t=Wee.length;t;){for(Uee=Wee,Wee=[];++qee<t;)Uee&&Uee[qee].run();qee=-1,t=Wee.length}Uee=null,$ee=!1,function(e){if(Bee===clearTimeout)return clearTimeout(e);if((Bee===Fee||!Bee)&&clearTimeout)return Bee=clearTimeout,clearTimeout(e);try{return Bee(e)}catch(t){try{return Bee.call(null,e)}catch(t){return Bee.call(this,e)}}}(e)}}function Kee(e,t){this.fun=e,this.array=t}function Xee(){}Kee.prototype.run=function(){this.fun.apply(null,this.array)};var Qee=Xee,Jee=Xee,Zee=Xee,ete=Xee,tte=Xee,nte=Xee,rte=Xee,ate=Dee.performance||{},ote=ate.now||ate.mozNow||ate.msNow||ate.oNow||ate.webkitNow||function(){return(new Date).getTime()},cte=new Date,ite={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];Wee.push(new Kee(e,t)),1!==Wee.length||$ee||jee(Yee)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Qee,addListener:Jee,once:Zee,off:ete,removeListener:tte,removeAllListeners:nte,emit:rte,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*ote.call(ate),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-cte)/1e3}};function lte(e,t){return function(){return e.apply(t,arguments)}}const{toString:ste}=Object.prototype,{getPrototypeOf:hte}=Object,dte=(fte=Object.create(null),e=>{const t=ste.call(e);return fte[t]||(fte[t]=t.slice(8,-1).toLowerCase())}),ute=e=>(e=e.toLowerCase(),t=>dte(t)===e),mte=e=>t=>typeof t===e,{isArray:pte}=Array,vte=mte("undefined");var fte;const zte=ute("ArrayBuffer"),gte=mte("string"),yte=mte("function"),Mte=mte("number"),Ete=e=>null!==e&&"object"==typeof e,bte=e=>{if("object"!==dte(e))return!1;const t=hte(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},Hte=ute("Date"),Vte=ute("File"),Cte=ute("Blob"),Lte=ute("FileList"),wte=ute("URLSearchParams"),[kte,xte,Ste,Tte]=["ReadableStream","Request","Response","Headers"].map(ute);function Ote(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,a;if("object"!=typeof e&&(e=[e]),pte(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{const a=n?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length;let c;for(r=0;r<o;r++)c=a[r],t.call(null,e[c],c,e)}}function Ate(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,a=n.length;for(;a-- >0;)if(r=n[a],t===r.toLowerCase())return r;return null}const Rte="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Dee,Nte=e=>!vte(e)&&e!==Rte,_te=(Dte="undefined"!=typeof Uint8Array&&hte(Uint8Array),e=>Dte&&e instanceof Dte);var Dte;const Pte=ute("HTMLFormElement"),Fte=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ite=ute("RegExp"),Bte=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Ote(n,((n,a)=>{let o;!1!==(o=t(n,a,e))&&(r[a]=o||n)})),Object.defineProperties(e,r)},jte="abcdefghijklmnopqrstuvwxyz",Ute="0123456789",Wte={DIGIT:Ute,ALPHA:jte,ALPHA_DIGIT:jte+jte.toUpperCase()+Ute},$te=ute("AsyncFunction"),qte=(Gte="function"==typeof setImmediate,Yte=yte(Rte.postMessage),Gte?setImmediate:Yte?(Kte=`axios@${Math.random()}`,Xte=[],Rte.addEventListener("message",(({source:e,data:t})=>{e===Rte&&t===Kte&&Xte.length&&Xte.shift()()}),!1),e=>{Xte.push(e),Rte.postMessage(Kte,"*")}):e=>setTimeout(e));var Gte,Yte,Kte,Xte;const Qte="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Rte):ite.nextTick||qte;var Jte={isArray:pte,isArrayBuffer:zte,isBuffer:function(e){return null!==e&&!vte(e)&&null!==e.constructor&&!vte(e.constructor)&&yte(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||yte(e.append)&&("formdata"===(t=dte(e))||"object"===t&&yte(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&zte(e.buffer),t},isString:gte,isNumber:Mte,isBoolean:e=>!0===e||!1===e,isObject:Ete,isPlainObject:bte,isReadableStream:kte,isRequest:xte,isResponse:Ste,isHeaders:Tte,isUndefined:vte,isDate:Hte,isFile:Vte,isBlob:Cte,isRegExp:Ite,isFunction:yte,isStream:e=>Ete(e)&&yte(e.pipe),isURLSearchParams:wte,isTypedArray:_te,isFileList:Lte,forEach:Ote,merge:function e(){const{caseless:t}=Nte(this)&&this||{},n={},r=(r,a)=>{const o=t&&Ate(n,a)||a;bte(n[o])&&bte(r)?n[o]=e(n[o],r):bte(r)?n[o]=e({},r):pte(r)?n[o]=r.slice():n[o]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Ote(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(Ote(t,((t,r)=>{n&&yte(t)?e[r]=lte(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let a,o,c;const i={};if(t=t||{},null==e)return t;do{for(a=Object.getOwnPropertyNames(e),o=a.length;o-- >0;)c=a[o],r&&!r(c,e,t)||i[c]||(t[c]=e[c],i[c]=!0);e=!1!==n&&hte(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:dte,kindOfTest:ute,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(pte(e))return e;let t=e.length;if(!Mte(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Pte,hasOwnProperty:Fte,hasOwnProp:Fte,reduceDescriptors:Bte,freezeMethods:e=>{Bte(e,((t,n)=>{if(yte(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];yte(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return pte(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Ate,global:Rte,isContextDefined:Nte,ALPHABET:Wte,generateString:(e=16,t=Wte.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&yte(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(Ete(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const a=pte(e)?[]:{};return Ote(e,((e,t)=>{const o=n(e,r+1);!vte(o)&&(a[t]=o)})),t[r]=void 0,a}}return e};return n(e,0)},isAsyncFn:$te,isThenable:e=>e&&(Ete(e)||yte(e))&&yte(e.then)&&yte(e.catch),setImmediate:qte,asap:Qte},Zte=[],ene=[],tne="undefined"!=typeof Uint8Array?Uint8Array:Array,nne=!1;function rne(){nne=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Zte[t]=e[t],ene[e.charCodeAt(t)]=t;ene["-".charCodeAt(0)]=62,ene["_".charCodeAt(0)]=63}function ane(e,t,n){for(var r,a,o=[],c=t;c<n;c+=3)r=(e[c]<<16)+(e[c+1]<<8)+e[c+2],o.push(Zte[(a=r)>>18&63]+Zte[a>>12&63]+Zte[a>>6&63]+Zte[63&a]);return o.join("")}function one(e){var t;nne||rne();for(var n=e.length,r=n%3,a="",o=[],c=16383,i=0,l=n-r;i<l;i+=c)o.push(ane(e,i,i+c>l?l:i+c));return 1===r?(t=e[n-1],a+=Zte[t>>2],a+=Zte[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=Zte[t>>10],a+=Zte[t>>4&63],a+=Zte[t<<2&63],a+="="),o.push(a),o.join("")}function cne(e,t,n,r,a){var o,c,i=8*a-r-1,l=(1<<i)-1,s=l>>1,h=-7,d=n?a-1:0,u=n?-1:1,m=e[t+d];for(d+=u,o=m&(1<<-h)-1,m>>=-h,h+=i;h>0;o=256*o+e[t+d],d+=u,h-=8);for(c=o&(1<<-h)-1,o>>=-h,h+=r;h>0;c=256*c+e[t+d],d+=u,h-=8);if(0===o)o=1-s;else{if(o===l)return c?NaN:1/0*(m?-1:1);c+=Math.pow(2,r),o-=s}return(m?-1:1)*c*Math.pow(2,o-r)}function ine(e,t,n,r,a,o){var c,i,l,s=8*o-a-1,h=(1<<s)-1,d=h>>1,u=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,m=r?0:o-1,p=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,c=h):(c=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-c))<1&&(c--,l*=2),(t+=c+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(c++,l/=2),c+d>=h?(i=0,c=h):c+d>=1?(i=(t*l-1)*Math.pow(2,a),c+=d):(i=t*Math.pow(2,d-1)*Math.pow(2,a),c=0));a>=8;e[n+m]=255&i,m+=p,i/=256,a-=8);for(c=c<<a|i,s+=a;s>0;e[n+m]=255&c,m+=p,c/=256,s-=8);e[n+m-p]|=128*v}var lne={}.toString,sne=Array.isArray||function(e){return"[object Array]"==lne.call(e)};function hne(){return une.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function dne(e,t){if(hne()<t)throw new RangeError("Invalid typed array length");return une.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=une.prototype:(null===e&&(e=new une(t)),e.length=t),e}function une(e,t,n){if(!(une.TYPED_ARRAY_SUPPORT||this instanceof une))return new une(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return vne(this,e)}return mne(this,e,t,n)}function mne(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),une.TYPED_ARRAY_SUPPORT?(e=t).__proto__=une.prototype:e=fne(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!une.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|yne(t,n),a=(e=dne(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}(e,t,n):function(e,t){if(gne(t)){var n=0|zne(t.length);return 0===(e=dne(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?dne(e,0):fne(e,t);if("Buffer"===t.type&&sne(t.data))return fne(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function pne(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function vne(e,t){if(pne(t),e=dne(e,t<0?0:0|zne(t)),!une.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function fne(e,t){var n=t.length<0?0:0|zne(t.length);e=dne(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function zne(e){if(e>=hne())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+hne().toString(16)+" bytes");return 0|e}function gne(e){return!(null==e||!e._isBuffer)}function yne(e,t){if(gne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return qne(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Gne(e).length;default:if(r)return qne(e).length;t=(""+t).toLowerCase(),r=!0}}function Mne(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Nne(this,t,n);case"utf8":case"utf-8":return Tne(this,t,n);case"ascii":return Ane(this,t,n);case"latin1":case"binary":return Rne(this,t,n);case"base64":return Sne(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _ne(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Ene(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function bne(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=une.from(t,r)),gne(t))return 0===t.length?-1:Hne(e,t,n,r,a);if("number"==typeof t)return t&=255,une.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Hne(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function Hne(e,t,n,r,a){var o,c=1,i=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;c=2,i/=2,l/=2,n/=2}function s(e,t){return 1===c?e[t]:e.readUInt16BE(t*c)}if(a){var h=-1;for(o=n;o<i;o++)if(s(e,o)===s(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===l)return h*c}else-1!==h&&(o-=o-h),h=-1}else for(n+l>i&&(n=i-l),o=n;o>=0;o--){for(var d=!0,u=0;u<l;u++)if(s(e,o+u)!==s(t,u)){d=!1;break}if(d)return o}return-1}function Vne(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var c=0;c<r;++c){var i=parseInt(t.substr(2*c,2),16);if(isNaN(i))return c;e[n+c]=i}return c}function Cne(e,t,n,r){return Yne(qne(t,e.length-n),e,n,r)}function Lne(e,t,n,r){return Yne(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function wne(e,t,n,r){return Lne(e,t,n,r)}function kne(e,t,n,r){return Yne(Gne(t),e,n,r)}function xne(e,t,n,r){return Yne(function(e,t){for(var n,r,a,o=[],c=0;c<e.length&&!((t-=2)<0);++c)r=(n=e.charCodeAt(c))>>8,a=n%256,o.push(a),o.push(r);return o}(t,e.length-n),e,n,r)}function Sne(e,t,n){return 0===t&&n===e.length?one(e):one(e.slice(t,n))}function Tne(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var o,c,i,l,s=e[a],h=null,d=s>239?4:s>223?3:s>191?2:1;if(a+d<=n)switch(d){case 1:s<128&&(h=s);break;case 2:128==(192&(o=e[a+1]))&&(l=(31&s)<<6|63&o)>127&&(h=l);break;case 3:o=e[a+1],c=e[a+2],128==(192&o)&&128==(192&c)&&(l=(15&s)<<12|(63&o)<<6|63&c)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:o=e[a+1],c=e[a+2],i=e[a+3],128==(192&o)&&128==(192&c)&&128==(192&i)&&(l=(15&s)<<18|(63&o)<<12|(63&c)<<6|63&i)>65535&&l<1114112&&(h=l)}null===h?(h=65533,d=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),a+=d}return function(e){var t=e.length;if(t<=One)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=One));return n}(r)}une.TYPED_ARRAY_SUPPORT=void 0===Dee.TYPED_ARRAY_SUPPORT||Dee.TYPED_ARRAY_SUPPORT,hne(),une.poolSize=8192,une._augment=function(e){return e.__proto__=une.prototype,e},une.from=function(e,t,n){return mne(null,e,t,n)},une.TYPED_ARRAY_SUPPORT&&(une.prototype.__proto__=Uint8Array.prototype,une.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&une[Symbol.species]),une.alloc=function(e,t,n){return function(e,t,n,r){return pne(t),t<=0?dne(e,t):void 0!==n?"string"==typeof r?dne(e,t).fill(n,r):dne(e,t).fill(n):dne(e,t)}(null,e,t,n)},une.allocUnsafe=function(e){return vne(null,e)},une.allocUnsafeSlow=function(e){return vne(null,e)},une.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Kne(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Kne(e.slice(0,0))}(e))},une.compare=function(e,t){if(!gne(e)||!gne(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,o=Math.min(n,r);a<o;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},une.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},une.concat=function(e,t){if(!sne(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return une.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=une.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var o=e[n];if(!gne(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,a),a+=o.length}return r},une.byteLength=yne,une.prototype._isBuffer=!0,une.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Ene(this,t,t+1);return this},une.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Ene(this,t,t+3),Ene(this,t+1,t+2);return this},une.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Ene(this,t,t+7),Ene(this,t+1,t+6),Ene(this,t+2,t+5),Ene(this,t+3,t+4);return this},une.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Tne(this,0,e):Mne.apply(this,arguments)},une.prototype.equals=function(e){if(!gne(e))throw new TypeError("Argument must be a Buffer");return this===e||0===une.compare(this,e)},une.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},une.prototype.compare=function(e,t,n,r,a){if(!gne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(a>>>=0)-(r>>>=0),c=(n>>>=0)-(t>>>=0),i=Math.min(o,c),l=this.slice(r,a),s=e.slice(t,n),h=0;h<i;++h)if(l[h]!==s[h]){o=l[h],c=s[h];break}return o<c?-1:c<o?1:0},une.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},une.prototype.indexOf=function(e,t,n){return bne(this,e,t,n,!0)},une.prototype.lastIndexOf=function(e,t,n){return bne(this,e,t,n,!1)},une.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return Vne(this,e,t,n);case"utf8":case"utf-8":return Cne(this,e,t,n);case"ascii":return Lne(this,e,t,n);case"latin1":case"binary":return wne(this,e,t,n);case"base64":return kne(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xne(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},une.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var One=4096;function Ane(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function Rne(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function Nne(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a="",o=t;o<n;++o)a+=$ne(e[o]);return a}function _ne(e,t,n){for(var r=e.slice(t,n),a="",o=0;o<r.length;o+=2)a+=String.fromCharCode(r[o]+256*r[o+1]);return a}function Dne(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Pne(e,t,n,r,a,o){if(!gne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Fne(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,o=Math.min(e.length-n,2);a<o;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function Ine(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,o=Math.min(e.length-n,4);a<o;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function Bne(e,t,n,r,a,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function jne(e,t,n,r,a){return a||Bne(e,0,n,4),ine(e,t,n,r,23,4),n+4}function Une(e,t,n,r,a){return a||Bne(e,0,n,8),ine(e,t,n,r,52,8),n+8}une.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),une.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=une.prototype;else{var a=t-e;n=new une(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+e]}return n},une.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r},une.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},une.prototype.readUInt8=function(e,t){return t||Dne(e,1,this.length),this[e]},une.prototype.readUInt16LE=function(e,t){return t||Dne(e,2,this.length),this[e]|this[e+1]<<8},une.prototype.readUInt16BE=function(e,t){return t||Dne(e,2,this.length),this[e]<<8|this[e+1]},une.prototype.readUInt32LE=function(e,t){return t||Dne(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},une.prototype.readUInt32BE=function(e,t){return t||Dne(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},une.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},une.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=t,a=1,o=this[e+--r];r>0&&(a*=256);)o+=this[e+--r]*a;return o>=(a*=128)&&(o-=Math.pow(2,8*t)),o},une.prototype.readInt8=function(e,t){return t||Dne(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},une.prototype.readInt16LE=function(e,t){t||Dne(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},une.prototype.readInt16BE=function(e,t){t||Dne(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},une.prototype.readInt32LE=function(e,t){return t||Dne(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},une.prototype.readInt32BE=function(e,t){return t||Dne(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},une.prototype.readFloatLE=function(e,t){return t||Dne(e,4,this.length),cne(this,e,!0,23,4)},une.prototype.readFloatBE=function(e,t){return t||Dne(e,4,this.length),cne(this,e,!1,23,4)},une.prototype.readDoubleLE=function(e,t){return t||Dne(e,8,this.length),cne(this,e,!0,52,8)},une.prototype.readDoubleBE=function(e,t){return t||Dne(e,8,this.length),cne(this,e,!1,52,8)},une.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Pne(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,o=0;for(this[t]=255&e;++o<n&&(a*=256);)this[t+o]=e/a&255;return t+n},une.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Pne(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,o=1;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=e/o&255;return t+n},une.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,1,255,0),une.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},une.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,65535,0),une.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Fne(this,e,t,!0),t+2},une.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,65535,0),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Fne(this,e,t,!1),t+2},une.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,4294967295,0),une.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ine(this,e,t,!0),t+4},une.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,4294967295,0),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ine(this,e,t,!1),t+4},une.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Pne(this,e,t,n,a-1,-a)}var o=0,c=1,i=0;for(this[t]=255&e;++o<n&&(c*=256);)e<0&&0===i&&0!==this[t+o-1]&&(i=1),this[t+o]=(e/c|0)-i&255;return t+n},une.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Pne(this,e,t,n,a-1,-a)}var o=n-1,c=1,i=0;for(this[t+o]=255&e;--o>=0&&(c*=256);)e<0&&0===i&&0!==this[t+o+1]&&(i=1),this[t+o]=(e/c|0)-i&255;return t+n},une.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,1,127,-128),une.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},une.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,32767,-32768),une.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Fne(this,e,t,!0),t+2},une.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,32767,-32768),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Fne(this,e,t,!1),t+2},une.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,2147483647,-2147483648),une.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ine(this,e,t,!0),t+4},une.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ine(this,e,t,!1),t+4},une.prototype.writeFloatLE=function(e,t,n){return jne(this,e,t,!0,n)},une.prototype.writeFloatBE=function(e,t,n){return jne(this,e,t,!1,n)},une.prototype.writeDoubleLE=function(e,t,n){return Une(this,e,t,!0,n)},une.prototype.writeDoubleBE=function(e,t,n){return Une(this,e,t,!1,n)},une.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,o=r-n;if(this===e&&n<t&&t<r)for(a=o-1;a>=0;--a)e[a+t]=this[a+n];else if(o<1e3||!une.TYPED_ARRAY_SUPPORT)for(a=0;a<o;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},une.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!une.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var c=gne(e)?e:qne(new une(e,r).toString()),i=c.length;for(o=0;o<n-t;++o)this[o+t]=c[o%i]}return this};var Wne=/[^+\/0-9A-Za-z-_]/g;function $ne(e){return e<16?"0"+e.toString(16):e.toString(16)}function qne(e,t){var n;t=t||1/0;for(var r=e.length,a=null,o=[],c=0;c<r;++c){if((n=e.charCodeAt(c))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(c+1===r){(t-=3)>-1&&o.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&o.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Gne(e){return function(e){var t,n,r,a,o,c;nne||rne();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[i-2]?2:"="===e[i-1]?1:0,c=new tne(3*i/4-o),r=o>0?i-4:i;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)a=ene[e.charCodeAt(t)]<<18|ene[e.charCodeAt(t+1)]<<12|ene[e.charCodeAt(t+2)]<<6|ene[e.charCodeAt(t+3)],c[l++]=a>>16&255,c[l++]=a>>8&255,c[l++]=255&a;return 2===o?(a=ene[e.charCodeAt(t)]<<2|ene[e.charCodeAt(t+1)]>>4,c[l++]=255&a):1===o&&(a=ene[e.charCodeAt(t)]<<10|ene[e.charCodeAt(t+1)]<<4|ene[e.charCodeAt(t+2)]>>2,c[l++]=a>>8&255,c[l++]=255&a),c}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Wne,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yne(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function Kne(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Xne(e,t,n,r,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}Jte.inherits(Xne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Jte.toJSONObject(this.config),code:this.code,status:this.status}}});const Qne=Xne.prototype,Jne={};function Zne(e){return Jte.isPlainObject(e)||Jte.isArray(e)}function ere(e){return Jte.endsWith(e,"[]")?e.slice(0,-2):e}function tre(e,t,n){return e?e.concat(t).map((function(e,t){return e=ere(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Jne[e]={value:e}})),Object.defineProperties(Xne,Jne),Object.defineProperty(Qne,"isAxiosError",{value:!0}),Xne.from=(e,t,n,r,a,o)=>{const c=Object.create(Qne);return Jte.toFlatObject(e,c,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Xne.call(c,e.message,t,n,r,a),c.cause=e,c.name=e.name,o&&Object.assign(c,o),c};const nre=Jte.toFlatObject(Jte,{},null,(function(e){return/^is[A-Z]/.test(e)}));function rre(e,t,n){if(!Jte.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Jte.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Jte.isUndefined(t[e])}))).metaTokens,a=n.visitor||s,o=n.dots,c=n.indexes,i=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Jte.isSpecCompliantForm(t);if(!Jte.isFunction(a))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Jte.isDate(e))return e.toISOString();if(!i&&Jte.isBlob(e))throw new Xne("Blob is not supported. Use a Buffer instead.");return Jte.isArrayBuffer(e)||Jte.isTypedArray(e)?i&&"function"==typeof Blob?new Blob([e]):une.from(e):e}function s(e,n,a){let i=e;if(e&&!a&&"object"==typeof e)if(Jte.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Jte.isArray(e)&&function(e){return Jte.isArray(e)&&!e.some(Zne)}(e)||(Jte.isFileList(e)||Jte.endsWith(n,"[]"))&&(i=Jte.toArray(e)))return n=ere(n),i.forEach((function(e,r){!Jte.isUndefined(e)&&null!==e&&t.append(!0===c?tre([n],r,o):null===c?n:n+"[]",l(e))})),!1;return!!Zne(e)||(t.append(tre(a,n,o),l(e)),!1)}const h=[],d=Object.assign(nre,{defaultVisitor:s,convertValue:l,isVisitable:Zne});if(!Jte.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Jte.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+r.join("."));h.push(n),Jte.forEach(n,(function(n,o){!0===(!(Jte.isUndefined(n)||null===n)&&a.call(t,n,Jte.isString(o)?o.trim():o,r,d))&&e(n,r?r.concat(o):[o])})),h.pop()}}(e),t}function are(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function ore(e,t){this._pairs=[],e&&rre(e,this,t)}const cre=ore.prototype;function ire(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function lre(e,t,n){if(!t)return e;const r=n&&n.encode||ire;Jte.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let o;if(o=a?a(t,n):Jte.isURLSearchParams(t)?t.toString():new ore(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}cre.append=function(e,t){this._pairs.push([e,t])},cre.toString=function(e){const t=e?function(t){return e.call(this,t,are)}:are;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class sre{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Jte.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var hre={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dre={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ore,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ure="undefined"!=typeof window&&"undefined"!=typeof document,mre="object"==typeof navigator&&navigator||void 0,pre=ure&&(!mre||["ReactNative","NativeScript","NS"].indexOf(mre.product)<0),vre="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,fre=ure&&window.location.href||"http://localhost";var zre={...Object.freeze({__proto__:null,hasBrowserEnv:ure,hasStandardBrowserWebWorkerEnv:vre,hasStandardBrowserEnv:pre,navigator:mre,origin:fre}),...dre};function gre(e){function t(e,n,r,a){let o=e[a++];if("__proto__"===o)return!0;const c=Number.isFinite(+o),i=a>=e.length;return o=!o&&Jte.isArray(r)?r.length:o,i?(Jte.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!c):(r[o]&&Jte.isObject(r[o])||(r[o]=[]),t(e,n,r[o],a)&&Jte.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const a=n.length;let o;for(r=0;r<a;r++)o=n[r],t[o]=e[o];return t}(r[o])),!c)}if(Jte.isFormData(e)&&Jte.isFunction(e.entries)){const n={};return Jte.forEachEntry(e,((e,r)=>{t(function(e){return Jte.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const yre={transitional:hre,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,a=Jte.isObject(e);if(a&&Jte.isHTMLForm(e)&&(e=new FormData(e)),Jte.isFormData(e))return r?JSON.stringify(gre(e)):e;if(Jte.isArrayBuffer(e)||Jte.isBuffer(e)||Jte.isStream(e)||Jte.isFile(e)||Jte.isBlob(e)||Jte.isReadableStream(e))return e;if(Jte.isArrayBufferView(e))return e.buffer;if(Jte.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return rre(e,new zre.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return zre.isNode&&Jte.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=Jte.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return rre(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return a||r?(t.setContentType("application/json",!1),function(e){if(Jte.isString(e))try{return(0,JSON.parse)(e),Jte.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||yre.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Jte.isResponse(e)||Jte.isReadableStream(e))return e;if(e&&Jte.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw Xne.from(e,Xne.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:zre.classes.FormData,Blob:zre.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jte.forEach(["delete","get","head","post","put","patch"],(e=>{yre.headers[e]={}}));const Mre=Jte.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ere=Symbol("internals");function bre(e){return e&&String(e).trim().toLowerCase()}function Hre(e){return!1===e||null==e?e:Jte.isArray(e)?e.map(Hre):String(e)}function Vre(e,t,n,r,a){return Jte.isFunction(r)?r.call(this,t,n):(a&&(t=n),Jte.isString(t)?Jte.isString(r)?-1!==t.indexOf(r):Jte.isRegExp(r)?r.test(t):void 0:void 0)}class Cre{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function a(e,t,n){const a=bre(t);if(!a)throw new Error("header name must be a non-empty string");const o=Jte.findKey(r,a);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=Hre(e))}const o=(e,t)=>Jte.forEach(e,((e,n)=>a(e,n,t)));if(Jte.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Jte.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,a;return e&&e.split("\n").forEach((function(e){a=e.indexOf(":"),n=e.substring(0,a).trim().toLowerCase(),r=e.substring(a+1).trim(),!n||t[n]&&Mre[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(Jte.isHeaders(e))for(const[t,r]of e.entries())a(r,t,n);else null!=e&&a(t,e,n);return this}get(e,t){if(e=bre(e)){const n=Jte.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Jte.isFunction(t))return t.call(this,e,n);if(Jte.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=bre(e)){const n=Jte.findKey(this,e);return!(!n||void 0===this[n]||t&&!Vre(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function a(e){if(e=bre(e)){const a=Jte.findKey(n,e);!a||t&&!Vre(0,n[a],a,t)||(delete n[a],r=!0)}}return Jte.isArray(e)?e.forEach(a):a(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const a=t[n];e&&!Vre(0,this[a],a,e,!0)||(delete this[a],r=!0)}return r}normalize(e){const t=this,n={};return Jte.forEach(this,((r,a)=>{const o=Jte.findKey(n,a);if(o)return t[o]=Hre(r),void delete t[a];const c=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(a):String(a).trim();c!==a&&delete t[a],t[c]=Hre(r),n[c]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Jte.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Jte.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Ere]=this[Ere]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=bre(e);t[r]||(function(e,t){const n=Jte.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,a){return this[r].call(this,t,e,n,a)},configurable:!0})}))}(n,e),t[r]=!0)}return Jte.isArray(e)?e.forEach(r):r(e),this}}function Lre(e,t){const n=this||yre,r=t||n,a=Cre.from(r.headers);let o=r.data;return Jte.forEach(e,(function(e){o=e.call(n,o,a.normalize(),t?t.status:void 0)})),a.normalize(),o}function wre(e){return!(!e||!e.__CANCEL__)}function kre(e,t,n){Xne.call(this,null==e?"canceled":e,Xne.ERR_CANCELED,t,n),this.name="CanceledError"}function xre(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Xne("Request failed with status code "+n.status,[Xne.ERR_BAD_REQUEST,Xne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Cre.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Jte.reduceDescriptors(Cre.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),Jte.freezeMethods(Cre),Jte.inherits(kre,Xne,{__CANCEL__:!0});const Sre=(e,t,n=3)=>{let r=0;const a=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let a,o=0,c=0;return t=void 0!==t?t:1e3,function(i){const l=Date.now(),s=r[c];a||(a=l),n[o]=i,r[o]=l;let h=c,d=0;for(;h!==o;)d+=n[h++],h%=e;if(o=(o+1)%e,o===c&&(c=(c+1)%e),l-a<t)return;const u=s&&l-s;return u?Math.round(1e3*d/u):void 0}}(50,250);return function(e,t){let n,r,a=0,o=1e3/t;const c=(t,o=Date.now())=>{a=o,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),i=t-a;i>=o?c(e,t):(n=e,r||(r=setTimeout((()=>{r=null,c(n)}),o-i)))},()=>n&&c(n)]}((n=>{const o=n.loaded,c=n.lengthComputable?n.total:void 0,i=o-r,l=a(i);r=o,e({loaded:o,total:c,progress:c?o/c:void 0,bytes:i,rate:l||void 0,estimated:l&&c&&o<=c?(c-o)/l:void 0,event:n,lengthComputable:null!=c,[t?"download":"upload"]:!0})}),n)},Tre=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ore=e=>(...t)=>Jte.asap((()=>e(...t)));var Are=zre.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,zre.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(zre.origin),zre.navigator&&/(msie|trident)/i.test(zre.navigator.userAgent)):()=>!0,Rre=zre.hasStandardBrowserEnv?{write(e,t,n,r,a,o){const c=[e+"="+encodeURIComponent(t)];Jte.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),Jte.isString(r)&&c.push("path="+r),Jte.isString(a)&&c.push("domain="+a),!0===o&&c.push("secure"),document.cookie=c.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Nre(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const _re=e=>e instanceof Cre?{...e}:e;function Dre(e,t){t=t||{};const n={};function r(e,t,n,r){return Jte.isPlainObject(e)&&Jte.isPlainObject(t)?Jte.merge.call({caseless:r},e,t):Jte.isPlainObject(t)?Jte.merge({},t):Jte.isArray(t)?t.slice():t}function a(e,t,n,a){return Jte.isUndefined(t)?Jte.isUndefined(e)?void 0:r(void 0,e,0,a):r(e,t,0,a)}function o(e,t){if(!Jte.isUndefined(t))return r(void 0,t)}function c(e,t){return Jte.isUndefined(t)?Jte.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function i(n,a,o){return o in t?r(n,a):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:i,headers:(e,t,n)=>a(_re(e),_re(t),0,!0)};return Jte.forEach(Object.keys(Object.assign({},e,t)),(function(r){const o=l[r]||a,c=o(e[r],t[r],r);Jte.isUndefined(c)&&o!==i||(n[r]=c)})),n}var Pre=e=>{const t=Dre({},e);let n,{data:r,withXSRFToken:a,xsrfHeaderName:o,xsrfCookieName:c,headers:i,auth:l}=t;if(t.headers=i=Cre.from(i),t.url=lre(Nre(t.baseURL,t.url),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Jte.isFormData(r))if(zre.hasStandardBrowserEnv||zre.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(!1!==(n=i.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];i.setContentType([e||"multipart/form-data",...t].join("; "))}if(zre.hasStandardBrowserEnv&&(a&&Jte.isFunction(a)&&(a=a(t)),a||!1!==a&&Are(t.url))){const e=o&&c&&Rre.read(c);e&&i.set(o,e)}return t},Fre="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=Pre(e);let a=r.data;const o=Cre.from(r.headers).normalize();let c,i,l,s,h,{responseType:d,onUploadProgress:u,onDownloadProgress:m}=r;function p(){s&&s(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(c),r.signal&&r.signal.removeEventListener("abort",c)}let v=new XMLHttpRequest;function f(){if(!v)return;const r=Cre.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders());xre((function(e){t(e),p()}),(function(e){n(e),p()}),{data:d&&"text"!==d&&"json"!==d?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:r,config:e,request:v}),v=null}v.open(r.method.toUpperCase(),r.url,!0),v.timeout=r.timeout,"onloadend"in v?v.onloadend=f:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(f)},v.onabort=function(){v&&(n(new Xne("Request aborted",Xne.ECONNABORTED,e,v)),v=null)},v.onerror=function(){n(new Xne("Network Error",Xne.ERR_NETWORK,e,v)),v=null},v.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const a=r.transitional||hre;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Xne(t,a.clarifyTimeoutError?Xne.ETIMEDOUT:Xne.ECONNABORTED,e,v)),v=null},void 0===a&&o.setContentType(null),"setRequestHeader"in v&&Jte.forEach(o.toJSON(),(function(e,t){v.setRequestHeader(t,e)})),Jte.isUndefined(r.withCredentials)||(v.withCredentials=!!r.withCredentials),d&&"json"!==d&&(v.responseType=r.responseType),m&&([l,h]=Sre(m,!0),v.addEventListener("progress",l)),u&&v.upload&&([i,s]=Sre(u),v.upload.addEventListener("progress",i),v.upload.addEventListener("loadend",s)),(r.cancelToken||r.signal)&&(c=t=>{v&&(n(!t||t.type?new kre(null,e,v):t),v.abort(),v=null)},r.cancelToken&&r.cancelToken.subscribe(c),r.signal&&(r.signal.aborted?c():r.signal.addEventListener("abort",c)));const z=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);z&&-1===zre.protocols.indexOf(z)?n(new Xne("Unsupported protocol "+z+":",Xne.ERR_BAD_REQUEST,e)):v.send(a||null)}))};const Ire=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const a=function(e){if(!n){n=!0,c();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Xne?t:new kre(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,a(new Xne(`timeout ${t} of ms exceeded`,Xne.ETIMEDOUT))}),t);const c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(a):e.removeEventListener("abort",a)})),e=null)};e.forEach((e=>e.addEventListener("abort",a)));const{signal:i}=r;return i.unsubscribe=()=>Jte.asap(c),i}},Bre=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,a=0;for(;a<n;)r=a+t,yield e.slice(a,r),a=r},jre=(e,t,n,r)=>{const a=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Bre(n,t)}(e,t);let o,c=0,i=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await a.next();if(t)return i(),void e.close();let o=r.byteLength;if(n){let e=c+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw i(e),e}},cancel:e=>(i(e),a.return())},{highWaterMark:2})},Ure="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Wre=Ure&&"function"==typeof ReadableStream,$re=Ure&&("function"==typeof TextEncoder?(qre=new TextEncoder,e=>qre.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var qre;const Gre=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Yre=Wre&&Gre((()=>{let e=!1;const t=new Request(zre.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Kre=Wre&&Gre((()=>Jte.isReadableStream(new Response("").body))),Xre={stream:Kre&&(e=>e.body)};var Qre;Ure&&(Qre=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Xre[e]&&(Xre[e]=Jte.isFunction(Qre[e])?t=>t[e]():(t,n)=>{throw new Xne(`Response type '${e}' is not supported`,Xne.ERR_NOT_SUPPORT,n)})})));var Jre=Ure&&(async e=>{let{url:t,method:n,data:r,signal:a,cancelToken:o,timeout:c,onDownloadProgress:i,onUploadProgress:l,responseType:s,headers:h,withCredentials:d="same-origin",fetchOptions:u}=Pre(e);s=s?(s+"").toLowerCase():"text";let m,p=Ire([a,o&&o.toAbortSignal()],c);const v=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let f;try{if(l&&Yre&&"get"!==n&&"head"!==n&&0!==(f=await(async(e,t)=>{const n=Jte.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Jte.isBlob(e))return e.size;if(Jte.isSpecCompliantForm(e)){const t=new Request(zre.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Jte.isArrayBufferView(e)||Jte.isArrayBuffer(e)?e.byteLength:(Jte.isURLSearchParams(e)&&(e+=""),Jte.isString(e)?(await $re(e)).byteLength:void 0)})(t):n})(h,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(Jte.isFormData(r)&&(e=n.headers.get("content-type"))&&h.setContentType(e),n.body){const[e,t]=Tre(f,Sre(Ore(l)));r=jre(n.body,65536,e,t)}}Jte.isString(d)||(d=d?"include":"omit");const a="credentials"in Request.prototype;m=new Request(t,{...u,signal:p,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:r,duplex:"half",credentials:a?d:void 0});let o=await fetch(m);const c=Kre&&("stream"===s||"response"===s);if(Kre&&(i||c&&v)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=Jte.toFiniteNumber(o.headers.get("content-length")),[n,r]=i&&Tre(t,Sre(Ore(i),!0))||[];o=new Response(jre(o.body,65536,n,(()=>{r&&r(),v&&v()})),e)}s=s||"text";let z=await Xre[Jte.findKey(Xre,s)||"text"](o,e);return!c&&v&&v(),await new Promise(((t,n)=>{xre(t,n,{data:z,headers:Cre.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:m})}))}catch(t){if(v&&v(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new Xne("Network Error",Xne.ERR_NETWORK,e,m),{cause:t.cause||t});throw Xne.from(t,t&&t.code,e,m)}});const Zre={http:null,xhr:Fre,fetch:Jre};Jte.forEach(Zre,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const eae=e=>`- ${e}`,tae=e=>Jte.isFunction(e)||null===e||!1===e;var nae=e=>{e=Jte.isArray(e)?e:[e];const{length:t}=e;let n,r;const a={};for(let o=0;o<t;o++){let t;if(n=e[o],r=n,!tae(n)&&(r=Zre[(t=String(n)).toLowerCase()],void 0===r))throw new Xne(`Unknown adapter '${t}'`);if(r)break;a[t||"#"+o]=r}if(!r){const e=Object.entries(a).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new Xne("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(eae).join("\n"):" "+eae(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function rae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new kre(null,e)}function aae(e){return rae(e),e.headers=Cre.from(e.headers),e.data=Lre.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),nae(e.adapter||yre.adapter)(e).then((function(t){return rae(e),t.data=Lre.call(e,e.transformResponse,t),t.headers=Cre.from(t.headers),t}),(function(t){return wre(t)||(rae(e),t&&t.response&&(t.response.data=Lre.call(e,e.transformResponse,t.response),t.response.headers=Cre.from(t.response.headers))),Promise.reject(t)}))}const oae={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{oae[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const cae={};oae.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,a,o)=>{if(!1===e)throw new Xne(r(a," has been removed"+(t?" in "+t:"")),Xne.ERR_DEPRECATED);return t&&!cae[a]&&(cae[a]=!0,console.warn(r(a," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,a,o)}},oae.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var iae={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Xne("options must be an object",Xne.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let a=r.length;for(;a-- >0;){const o=r[a],c=t[o];if(c){const t=e[o],n=void 0===t||c(t,o,e);if(!0!==n)throw new Xne("option "+o+" must be "+n,Xne.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Xne("Unknown option "+o,Xne.ERR_BAD_OPTION)}},validators:oae};const lae=iae.validators;class sae{constructor(e){this.defaults=e,this.interceptors={request:new sre,response:new sre}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Dre(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:a}=t;void 0!==n&&iae.assertOptions(n,{silentJSONParsing:lae.transitional(lae.boolean),forcedJSONParsing:lae.transitional(lae.boolean),clarifyTimeoutError:lae.transitional(lae.boolean)},!1),null!=r&&(Jte.isFunction(r)?t.paramsSerializer={serialize:r}:iae.assertOptions(r,{encode:lae.function,serialize:lae.function},!0)),iae.assertOptions(t,{baseUrl:lae.spelling("baseURL"),withXsrfToken:lae.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=a&&Jte.merge(a.common,a[t.method]);a&&Jte.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete a[e]})),t.headers=Cre.concat(o,a);const c=[];let i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,c.unshift(e.fulfilled,e.rejected))}));const l=[];let s;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let h,d=0;if(!i){const e=[aae.bind(this),void 0];for(e.unshift.apply(e,c),e.push.apply(e,l),h=e.length,s=Promise.resolve(t);d<h;)s=s.then(e[d++],e[d++]);return s}h=c.length;let u=t;for(d=0;d<h;){const t=c[d++],n=c[d++];try{u=t(u)}catch(e){n.call(this,e);break}}try{s=aae.call(this,u)}catch(e){return Promise.reject(e)}for(d=0,h=l.length;d<h;)s=s.then(l[d++],l[d++]);return s}getUri(e){return lre(Nre((e=Dre(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}Jte.forEach(["delete","get","head","options"],(function(e){sae.prototype[e]=function(t,n){return this.request(Dre(n||{},{method:e,url:t,data:(n||{}).data}))}})),Jte.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,a){return this.request(Dre(a||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}sae.prototype[e]=t(),sae.prototype[e+"Form"]=t(!0)}));class hae{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,a){n.reason||(n.reason=new kre(e,r,a),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new hae((function(t){e=t})),cancel:e}}}const dae={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(dae).forEach((([e,t])=>{dae[t]=e}));const uae=function e(t){const n=new sae(t),r=lte(sae.prototype.request,n);return Jte.extend(r,sae.prototype,n,{allOwnKeys:!0}),Jte.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Dre(t,n))},r}(yre);uae.Axios=sae,uae.CanceledError=kre,uae.CancelToken=hae,uae.isCancel=wre,uae.VERSION="1.7.9",uae.toFormData=rre,uae.AxiosError=Xne,uae.Cancel=uae.CanceledError,uae.all=function(e){return Promise.all(e)},uae.spread=function(e){return function(t){return e.apply(null,t)}},uae.isAxiosError=function(e){return Jte.isObject(e)&&!0===e.isAxiosError},uae.mergeConfig=Dre,uae.AxiosHeaders=Cre,uae.formToJSON=e=>gre(Jte.isHTMLForm(e)?new FormData(e):e),uae.getAdapter=nae,uae.HttpStatusCode=dae,uae.default=uae;var mae=function(){function e(){}return e.convertJsonToQueryParamsString=function(e){return Object.keys(e).map((function(t){return t+"="+e[t]})).join("&")},e}(),pae=function(){function e(e){var t=this;this._backendBaseUrl="",this.updatePdf=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfApisEndPointRoute()),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfData=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfPagesData=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createCommentThread=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.deleteCommentThread=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/delete"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.getCommentThreadById=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/").concat(e.commentThreadId))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchCommentThreads=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createComment=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/comments"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchUsersOfPdf=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/getUsers?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createPageAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:if(Object.keys(e.annotation||{}).length>1)throw new Error("invalid request payload");return[4,null===(n=this.api)||void 0===n?void 0:n.post(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchAllAnnotationsOfThePage=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.updatePageAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.deletePageAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.delete("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchPdfScales=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createPdfScale=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute()),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.deletePdfScale=function(e){return Ree(t,void 0,void 0,(function(){var t;return Nee(this,(function(n){switch(n.label){case 0:return[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfScalesApisEndPointRoute(),"/delete"),e)];case 1:return n.sent(),[2]}}))}))},this.updatePdfScale=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfScalesApisEndPointRoute(),"/update"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.convertImageToPdf=function(e){var n=e.imageDownloadUrl,r=e.imageWidth,a=e.imageHeight;return Ree(t,void 0,void 0,(function(){var e,t,o,c,i;return Nee(this,(function(l){switch(l.label){case 0:return e={pdfFileName:"image.pdf",imageDetails:{imageDownloadUrl:n,imageWidth:r,imageHeight:a}},[4,null===(o=this.api)||void 0===o?void 0:o.post("".concat(this.getPdfApisEndPointRoute()),e)];case 1:if(t=l.sent(),!(null===(c=null==t?void 0:t.data)||void 0===c?void 0:c._id))throw new Error("pdfId not found");return[4,null===(i=this.api)||void 0===i?void 0:i.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==t?void 0:t.data._id})];case 2:return l.sent(),[2,{_id:null==t?void 0:t.data._id}]}}))}))},this.backendBaseUrl=e.backendBaseUrl,this.api=uae.create({baseURL:this.backendBaseUrl,headers:{"Content-type":"application/json; charset=utf-8"},withCredentials:!0})}return Object.defineProperty(e.prototype,"backendBaseUrl",{get:function(){return this._backendBaseUrl},set:function(e){this._backendBaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"api",{get:function(){return this._api},set:function(e){this._api=e},enumerable:!1,configurable:!0}),e.prototype.getPdfApisEndPointRoute=function(){return"".concat(this.backendBaseUrl,"/pdfs")},e.prototype.getPdfPagesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/pages")},e.prototype.getPdfScalesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/scales")},e.prototype.getPdfPagesAnnotationApisEndPointRoute=function(){return"".concat(this.getPdfPagesApisEndPointRoute(),"/annotation")},e.calculateDistanceBetweenTwoCoordinatesInPdfPagePoints=function(e){var t=e.normalisedCoordinates2.x-e.normalisedCoordinates1.x,n=e.normalisedCoordinates2.y-e.normalisedCoordinates1.y;return Math.sqrt(t*t+n*n)/(e.pdfPageImageOriginalWidth/e.pdfPageOriginalWidthInPoints)},e.convertPdfPagePointsDistanceToInches=function(e){return e.pdfPagePointsDistance/72},e.convertInchesToCentimeters=function(e){return 2.54*e.inches},e.convertInchesToMeters=function(e){return e.inches/39.37},e.convertInchesToFeet=function(e){return e.inches/12},e.convertInchesDistanceToPdfPagePoints=function(e){return 72*e.inchesDistance},e.isUserMoreNearToHorizontalAxisOrVerticalAxis=function(e){var t=e.firstCoordinate,n=e.secondCoordinate,r=n.x-t.x,a=n.y-t.y;return Math.abs(r)>Math.abs(a)?"horizontal":"vertical"},e.prototype.insertPdfAndItsPagesInDb=function(e){var t,n,r;return Ree(this,void 0,void 0,(function(){var a,o,c;return Nee(this,(function(i){switch(i.label){case 0:return(a=new FormData).append("pdfDownloadUrl",e.pdfSourceUrl),e.pdfFileName&&a.append("pdfFileName",e.pdfFileName),[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),a,{headers:{"Content-Type":"multipart/form-data"}})];case 1:if(o=i.sent(),!(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return c=null===(r=this.api)||void 0===r?void 0:r.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==o?void 0:o.data._id}),e.shouldWaitForPdfPagesCreation?[4,c]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2,{_id:null==o?void 0:o.data._id}]}}))}))},e.convertNormalisedCoordinatesToUnNormalisedCoordinates=function(t){for(var n=t.normalisedCoordinates,r=t.normalisedXDimension,a=t.normalisedYDimension,o=t.unNormalisedXDimension,c=t.unNormalisedYDimension,i=[],l=0,s=n;l<s.length;l++){var h=s[l],d=h.x,u=h.y,m=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:d,normalisedDimension:r,unNormalisedDimension:o}),p=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:u,normalisedDimension:a,unNormalisedDimension:c});i.push({x:m,y:p})}return i},e.doNotMakeCoordinatesGoOutOfBoundary=function(e){for(var t=e.coordinates,n=e.coordinateBoundaries,r=0,a=t;r<a.length;r++){var o=a[r];o.x<n.xMin?o.x=n.xMin:o.x>n.xMax&&(o.x=n.xMax),o.y<n.yMin?o.y=n.yMin:o.y>n.yMax&&(o.y=n.yMax)}return t},e.prototype.insertPdfAndItsPagesInDBViaHTML=function(e){var t,n,r;return Ree(this,void 0,void 0,(function(){var a,o,c,i,l,s,h;return Nee(this,(function(d){switch(d.label){case 0:if(!(a=document.getElementById(e.htmlElementId)))throw new Error("htmlELement corresponding to the id not found");return o=a.outerHTML,e.cssClassNamesWhichShouldBeRemovedBeforeHtmlToPdfConversion.forEach((function(e){o=o.replaceAll(e,"")})),c=Array.from(document.querySelectorAll("style")).map((function(e){return e.outerHTML})).join("\n"),i='\n <html>\n <head>\n <meta charset="UTF-8">\n '.concat(c,"\n </head>\n <body>\n ").concat(o,"\n </body>\n </html>\n "),l={pdfFileName:"react-html.pdf",htmlDocument:{document:i,width:a.clientWidth}},[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),l)];case 1:if(s=d.sent(),!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return h=null===(r=this.api)||void 0===r?void 0:r.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==s?void 0:s.data._id}),e.shouldWaitForPdfPagesCreation?[4,h]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2,{_id:null==s?void 0:s.data._id}]}}))}))},e.convertValueFromOneUnitToAnotherUnit=function(e){var t=e.valueToConvert,n=e.fromUnit,r=e.toUnit;if(n===r)return t;var a=0;if("cm"===n)if("m"===r)a=t/100;else if("inch"===r)a=t/2.54;else{if("ft"!==r)throw new Error("Invalid toUnit");a=t/30.48}else if("m"===n)if("cm"===r)a=100*t;else if("inch"===r)a=39.37*t;else{if("ft"!==r)throw new Error("Invalid toUnit");a=3.281*t}else if("inch"===n)if("cm"===r)a=2.54*t;else if("m"===r)a=t/39.37;else{if("ft"!==r)throw new Error("Invalid toUnit");a=t/12}else{if("ft"!==n)throw new Error("Invalid fromUnit");if("cm"===r)a=30.48*t;else if("m"===r)a=t/3.281;else{if("inch"!==r)throw new Error("Invalid toUnit");a=12*t}}return a},e.convertNormalisedValueToUnNormalisedForShowingInUI=function(e){var t=e.normalisedValue,n=e.normalisedDimension;return t*(e.unNormalisedDimension/n)},e.convertUnNormalisedValueToNormalised=function(e){var t=e.unNormalisedValue,n=e.normalisedDimension;return t/(e.unNormalisedDimension/n)},e.convertCoordinatesArrayToNumberArray=function(e){for(var t=e.coordinates,n=[],r=0;r<t.length;r++)n.push(t[r].x),n.push(t[r].y);return n},e}(),vae=function(){function e(){}return e.getImageWidthHeightFromURL=function(e){return Ree(this,void 0,void 0,(function(){var t;return Nee(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,new Promise((function(t,n){try{var r=new Image;r.onload=function(){return t({width:r.width,height:r.height})},r.src=e}catch(e){n(new Error(e.message))}}))];case 1:return[2,n.sent()];case 2:throw t=n.sent(),new Error(t.message);case 3:return[2]}}))}))},e.getImageHeight=function(e,t){return e/t},e.getImageWidth=function(e,t){return e*t},e.downloadImage=function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){return t(r)},r.onerror=function(){return n(new Error("Image loading having url ".concat(e," got failed")))},r.src=e}))},e}(),fae={d:(e,t)=>{for(var n in t)fae.o(t,n)&&!fae.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},zae=globalThis.pdfjsLib={};fae.d(zae,{AbortException:()=>$ae,AnnotationEditorLayer:()=>Hle,AnnotationEditorParamsType:()=>Vae,AnnotationEditorType:()=>Hae,AnnotationEditorUIManager:()=>Soe,AnnotationLayer:()=>ale,AnnotationMode:()=>bae,ColorPicker:()=>ple,DOMSVGFactory:()=>Lie,DrawLayer:()=>Vle,FeatureTest:()=>Kae,GlobalWorkerOptions:()=>Lce,ImageKind:()=>Lae,InvalidPDFException:()=>Bae,MissingPDFException:()=>jae,OPS:()=>kae,OutputScale:()=>Eoe,PDFDataRangeTransport:()=>hie,PDFDateString:()=>voe,PDFWorker:()=>pie,PasswordResponses:()=>xae,PermissionFlag:()=>Cae,PixelsPerInch:()=>roe,RenderingCancelledException:()=>coe,TextLayer:()=>eie,TouchManager:()=>Ooe,UnexpectedResponseException:()=>Uae,Util:()=>Qae,VerbosityLevel:()=>wae,XfaLayer:()=>wie,build:()=>Eie,createValidAbsoluteUrl:()=>_ae,fetchData:()=>aoe,getDocument:()=>iie,getFilenameFromUrl:()=>soe,getPdfFilenameFromUrl:()=>hoe,getXfaPageViewport:()=>foe,isDataScheme:()=>ioe,isPdfFile:()=>loe,noContextMenu:()=>moe,normalizeUnicode:()=>eoe,setLayerDimensions:()=>Moe,shadow:()=>Dae,stopEvent:()=>poe,version:()=>Mie});const gae=!("object"!=typeof xt||xt+""!="[object process]"||xt.versions.nw||xt.versions.electron&&xt.type&&"browser"!==xt.type),yae=[1,0,0,1,0,0],Mae=[.001,0,0,.001,0,0],Eae=1.35,bae={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Hae={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Vae={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Cae={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Lae={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},wae={ERRORS:0,WARNINGS:1,INFOS:5},kae={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},xae={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Sae=wae.WARNINGS;function Tae(){return Sae}function Oae(e){Sae>=wae.INFOS&&console.log(`Info: ${e}`)}function Aae(e){Sae>=wae.WARNINGS&&console.log(`Warning: ${e}`)}function Rae(e){throw new Error(e)}function Nae(e,t){e||Rae(t)}function _ae(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=decodeURIComponent(escape(e))}catch{}}const r=t?new URL(e,t):new URL(e);if(function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch{}return null}function Dae(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const Pae=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=new Error,e.constructor=e,e}();class Fae extends Pae{constructor(e,t){super(e,"PasswordException"),this.code=t}}class Iae extends Pae{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class Bae extends Pae{constructor(e){super(e,"InvalidPDFException")}}class jae extends Pae{constructor(e){super(e,"MissingPDFException")}}class Uae extends Pae{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class Wae extends Pae{constructor(e){super(e,"FormatError")}}class $ae extends Pae{constructor(e){super(e,"AbortException")}}function qae(e){"object"==typeof e&&void 0!==e?.length||Rae("Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const r=[];for(let a=0;a<t;a+=n){const o=Math.min(a+n,t),c=e.subarray(a,o);r.push(String.fromCharCode.apply(null,c))}return r.join("")}function Gae(e){"string"!=typeof e&&Rae("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=255&e.charCodeAt(r);return n}function Yae(e){const t=Object.create(null);for(const[n,r]of e)t[n]=r;return t}class Kae{static get isLittleEndian(){return Dae(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return Dae(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Dae(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Dae(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?Dae(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):Dae(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Dae(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Xae=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));class Qae{static makeHexColor(e,t,n){return`#${Xae[e]}${Xae[t]}${Xae[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=this.applyTransform(e,t),r=this.applyTransform(e.slice(2,4),t),a=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],r[0],a[0],o[0]),Math.min(n[1],r[1],a[1],o[1]),Math.max(n[0],r[0],a[0],o[0]),Math.max(n[1],r[1],a[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],a=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],c=(n+o)/2,i=Math.sqrt((n+o)**2-4*(n*o-a*r))/2,l=c+i||1,s=c-i||1;return[Math.sqrt(l),Math.sqrt(s)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;const a=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return a>o?null:[n,a,r,o]}static#e(e,t,n,r,a,o,c,i,l,s){if(l<=0||l>=1)return;const h=1-l,d=l*l,u=d*l,m=h*(h*(h*e+3*l*t)+3*d*n)+u*r,p=h*(h*(h*a+3*l*o)+3*d*c)+u*i;s[0]=Math.min(s[0],m),s[1]=Math.min(s[1],p),s[2]=Math.max(s[2],m),s[3]=Math.max(s[3],p)}static#t(e,t,n,r,a,o,c,i,l,s,h,d){if(Math.abs(l)<1e-12)return void(Math.abs(s)>=1e-12&&this.#e(e,t,n,r,a,o,c,i,-h/s,d));const u=s**2-4*h*l;if(u<0)return;const m=Math.sqrt(u),p=2*l;this.#e(e,t,n,r,a,o,c,i,(-s+m)/p,d),this.#e(e,t,n,r,a,o,c,i,(-s-m)/p,d)}static bezierBoundingBox(e,t,n,r,a,o,c,i,l){return l?(l[0]=Math.min(l[0],e,c),l[1]=Math.min(l[1],t,i),l[2]=Math.max(l[2],e,c),l[3]=Math.max(l[3],t,i)):l=[Math.min(e,c),Math.min(t,i),Math.max(e,c),Math.max(t,i)],this.#t(e,n,a,c,t,r,o,i,3*(3*(n-a)-e+c),6*(e-2*n+a),3*(n-e),l),this.#t(e,n,a,c,t,r,o,i,3*(3*(r-o)-t+i),6*(t-2*r+o),3*(r-t),l),l}}let Jae=null,Zae=null;function eoe(e){return Jae||(Jae=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Zae=new Map([["ſt","ſt"]])),e.replaceAll(Jae,((e,t,n)=>t?t.normalize("NFKC"):Zae.get(n)))}const toe="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(e,...t){return new Promise((n=>{n(e(...t))}))});const noe="http://www.w3.org/2000/svg";class roe{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function aoe(e,t="text"){if(uoe(e,document.baseURI)){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);switch(t){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise(((n,r)=>{const a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType=t,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE)if(200!==a.status&&0!==a.status)r(new Error(a.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":return void n(a.response)}n(a.responseText)}},a.send(null)}))}class ooe{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:a=0,offsetY:o=0,dontFlip:c=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=a,this.offsetY=o,n*=t;const i=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let s,h,d,u,m,p,v,f;switch((r%=360)<0&&(r+=360),r){case 180:s=-1,h=0,d=0,u=1;break;case 90:s=0,h=1,d=1,u=0;break;case 270:s=0,h=-1,d=-1,u=0;break;case 0:s=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}c&&(d=-d,u=-u),0===s?(m=Math.abs(l-e[1])*n+a,p=Math.abs(i-e[0])*n+o,v=(e[3]-e[1])*n,f=(e[2]-e[0])*n):(m=Math.abs(i-e[0])*n+a,p=Math.abs(l-e[1])*n+o,v=(e[2]-e[0])*n,f=(e[3]-e[1])*n),this.transform=[s*n,h*n,d*n,u*n,m-s*n*i-d*n*l,p-h*n*i-u*n*l],this.width=v,this.height=f}get rawDims(){const{userUnit:e,viewBox:t}=this,n=t.map((t=>t*e));return Dae(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:r=this.offsetY,dontFlip:a=!1}={}){return new ooe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:a})}convertToViewportPoint(e,t){return Qae.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=Qae.applyTransform([e[0],e[1]],this.transform),n=Qae.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return Qae.applyInverseTransform([e,t],this.transform)}}class coe extends Pae{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function ioe(e){const t=e.length;let n=0;for(;n<t&&""===e[n].trim();)n++;return"data:"===e.substring(n,n+5).toLowerCase()}function loe(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function soe(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function hoe(e,t="document.pdf"){if("string"!=typeof e)return t;if(ioe(e))return Aae('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let a=n.exec(r[1])||n.exec(r[2])||n.exec(r[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}class doe{started=Object.create(null);times=[];time(e){e in this.started&&Aae(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Aae(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let t=0;for(const{name:e}of this.times)t=Math.max(e.length,t);for(const{name:n,start:r,end:a}of this.times)e.push(`${n.padEnd(t)} ${a-r}ms\n`);return e.join("")}}function uoe(e,t){try{const{protocol:n}=t?new URL(e,t):new URL(e);return"http:"===n||"https:"===n}catch{return!1}}function moe(e){e.preventDefault()}function poe(e){e.preventDefault(),e.stopPropagation()}class voe{static#n;static toDateObject(e){if(!e||"string"!=typeof e)return null;this.#n||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const t=this.#n.exec(e);if(!t)return null;const n=parseInt(t[1],10);let r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let a=parseInt(t[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let c=parseInt(t[5],10);c=c>=0&&c<=59?c:0;let i=parseInt(t[6],10);i=i>=0&&i<=59?i:0;const l=t[7]||"Z";let s=parseInt(t[8],10);s=s>=0&&s<=23?s:0;let h=parseInt(t[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===l?(o+=s,c+=h):"+"===l&&(o-=s,c-=h),new Date(Date.UTC(n,r,a,o,c,i))}}function foe(e,{scale:t=1,rotation:n=0}){const{width:r,height:a}=e.attributes.style,o=[0,0,parseInt(r),parseInt(a)];return new ooe({viewBox:o,userUnit:1,scale:t,rotation:n})}function zoe(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):(Aae(`Not a valid color format: "${e}"`),[0,0,0])}function goe(e){const{a:t,b:n,c:r,d:a,e:o,f:c}=e.getTransform();return[t,n,r,a,o,c]}function yoe(e){const{a:t,b:n,c:r,d:a,e:o,f:c}=e.getTransform().invertSelf();return[t,n,r,a,o,c]}function Moe(e,t,n=!1,r=!0){if(t instanceof ooe){const{pageWidth:r,pageHeight:a}=t.rawDims,{style:o}=e,c=Kae.isCSSRoundSupported,i=`var(--scale-factor) * ${r}px`,l=`var(--scale-factor) * ${a}px`,s=c?`round(down, ${i}, var(--scale-round-x, 1px))`:`calc(${i})`,h=c?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;n&&t.rotation%180!=0?(o.width=h,o.height=s):(o.width=s,o.height=h)}r&&e.setAttribute("data-main-rotation",t.rotation)}class Eoe{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class boe{#r=null;#a=null;#o;#c=null;#i=null;static#l=null;constructor(e){this.#o=e,boe.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const e=this.#r=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=this.#o._uiManager._signal;e.addEventListener("contextmenu",moe,{signal:t}),e.addEventListener("pointerdown",boe.#s,{signal:t});const n=this.#c=document.createElement("div");n.className="buttons",e.append(n);const r=this.#o.toolbarPosition;if(r){const{style:t}=e,n="ltr"===this.#o._uiManager.direction?1-r[0]:r[0];t.insetInlineEnd=100*n+"%",t.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return this.#h(),e}get div(){return this.#r}static#s(e){e.stopPropagation()}#d(e){this.#o._focusEventsAllowed=!1,poe(e)}#u(e){this.#o._focusEventsAllowed=!0,poe(e)}#m(e){const t=this.#o._uiManager._signal;e.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",moe,{signal:t})}hide(){this.#r.classList.add("hidden"),this.#a?.hideDropdown()}show(){this.#r.classList.remove("hidden"),this.#i?.shown()}#h(){const{editorType:e,_uiManager:t}=this.#o,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",boe.#l[e]),this.#m(n),n.addEventListener("click",(e=>{t.delete()}),{signal:t._signal}),this.#c.append(n)}get#p(){const e=document.createElement("div");return e.className="divider",e}async addAltText(e){const t=await e.render();this.#m(t),this.#c.prepend(t,this.#p),this.#i=e}addColorPicker(e){this.#a=e;const t=e.renderButton();this.#m(t),this.#c.prepend(t,this.#p)}remove(){this.#r.remove(),this.#a?.destroy(),this.#a=null}}class Hoe{#c=null;#r=null;#v;constructor(e){this.#v=e}#f(){const e=this.#r=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",moe,{signal:this.#v._signal});const t=this.#c=document.createElement("div");return t.className="buttons",e.append(t),this.#z(),e}#g(e,t){let n=0,r=0;for(const a of e){const e=a.y+a.height;if(e<n)continue;const o=a.x+(t?a.width:0);e>n?(r=o,n=e):t?o>r&&(r=o):o<r&&(r=o)}return[t?1-r:r,n]}show(e,t,n){const[r,a]=this.#g(t,n),{style:o}=this.#r||=this.#f();e.append(this.#r),o.insetInlineEnd=100*r+"%",o.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#r.remove()}#z(){const e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=this.#v._signal;e.addEventListener("contextmenu",moe,{signal:n}),e.addEventListener("click",(()=>{this.#v.highlightSelection("floating_button")}),{signal:n}),this.#c.append(e)}}function Voe(e,t,n){for(const r of n)t.addEventListener(r,e[r].bind(e))}class Coe{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class Loe{#M=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);return crypto.getRandomValues(e),qae(e)}();#y=0;#E=null;static get _isSVGFittingCanvas(){const e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),t=new Image;return t.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Dae(this,"_isSVGFittingCanvas",t.decode().then((()=>(e.drawImage(t,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]))))}async#b(e,t){this.#E||=new Map;let n=this.#E.get(e);if(null===n)return null;if(n?.bitmap)return n.refCounter+=1,n;try{let e;if(n||={bitmap:null,id:`image_${this.#M}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof t?(n.url=t,e=await aoe(t,"blob")):t instanceof File?e=n.file=t:t instanceof Blob&&(e=t),"image/svg+xml"===e.type){const t=Loe._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise(((e,o)=>{a.onload=()=>{n.bitmap=a,n.isSvg=!0,e()},r.onload=async()=>{const e=n.svgUrl=r.result;a.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=r.onerror=o}));r.readAsDataURL(e),await o}else n.bitmap=await createImageBitmap(e);n.refCounter=1}catch(e){Aae(e),n=null}return this.#E.set(e,n),n&&this.#E.set(n.id,n),n}async getFromFile(e){const{lastModified:t,name:n,size:r,type:a}=e;return this.#b(`${t}_${n}_${r}_${a}`,e)}async getFromUrl(e){return this.#b(e,e)}async getFromBlob(e,t){const n=await t;return this.#b(e,n)}async getFromId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#E||=new Map;let n=this.#E.get(e);if(n?.bitmap)return n.refCounter+=1,n;const r=new OffscreenCanvas(t.width,t.height);return r.getContext("2d").drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#M}_${this.#y++}`,refCounter:1,isSvg:!1},this.#E.set(e,n),this.#E.set(n.id,n),n}getSvgUrl(e){const t=this.#E.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return;if(t.refCounter-=1,0!==t.refCounter)return;const{bitmap:n}=t;if(!t.url&&!t.file){const e=new OffscreenCanvas(n.width,n.height);e.getContext("bitmaprenderer").transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#M}_`)}}class woe{#H=[];#V=!1;#C;#L=-1;constructor(e=128){this.#C=e}add({cmd:e,undo:t,post:n,mustExec:r,type:a=NaN,overwriteIfSameType:o=!1,keepUndo:c=!1}){if(r&&e(),this.#V)return;const i={cmd:e,undo:t,post:n,type:a};if(-1===this.#L)return this.#H.length>0&&(this.#H.length=0),this.#L=0,void this.#H.push(i);if(o&&this.#H[this.#L].type===a)return c&&(i.undo=this.#H[this.#L].undo),void(this.#H[this.#L]=i);const l=this.#L+1;l===this.#C?this.#H.splice(0,1):(this.#L=l,l<this.#H.length&&this.#H.splice(l)),this.#H.push(i)}undo(){if(-1===this.#L)return;this.#V=!0;const{undo:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1,this.#L-=1}redo(){if(this.#L<this.#H.length-1){this.#L+=1,this.#V=!0;const{cmd:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1}}hasSomethingToUndo(){return-1!==this.#L}hasSomethingToRedo(){return this.#L<this.#H.length-1}cleanType(e){if(-1!==this.#L){for(let t=this.#L;t>=0;t--)if(this.#H[t].type!==e)return this.#H.splice(t+1,this.#L-t),void(this.#L=t);this.#H.length=0,this.#L=-1}}destroy(){this.#H=null}}class koe{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:t}=Kae.platform;for(const[n,r,a={}]of e)for(const e of n){const n=e.startsWith("mac+");t&&n?(this.callbacks.set(e.slice(4),{callback:r,options:a}),this.allKeys.add(e.split("+").at(-1))):t||n||(this.callbacks.set(e,{callback:r,options:a}),this.allKeys.add(e.split("+").at(-1)))}}#w(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;const n=this.callbacks.get(this.#w(t));if(!n)return;const{callback:r,options:{bubbles:a=!1,args:o=[],checker:c=null}}=n;c&&!c(e,t)||(r.bind(e,...o,t)(),a||poe(t))}}class xoe{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return function(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const n of e.keys()){t.style.color=n;const r=window.getComputedStyle(t).color;e.set(n,zoe(r))}t.remove()}(e),Dae(this,"_colors",e)}convert(e){const t=zoe(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,n]of this._colors)if(n.every(((e,n)=>e===t[n])))return xoe._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?Qae.makeHexColor(...t):e}}class Soe{#k=new AbortController;#x=null;#S=new Map;#T=new Map;#O=null;#A=null;#R=null;#N=new woe;#_=null;#D=null;#P=0;#F=new Set;#I=null;#B=null;#j=new Set;_editorUndoBar=null;#U=!1;#W=!1;#$=!1;#q=null;#G=null;#Y=null;#K=null;#X=!1;#Q=null;#J=new Coe;#Z=!1;#ee=!1;#te=null;#ne=null;#re=null;#ae=null;#oe=Hae.NONE;#ce=new Set;#ie=null;#le=null;#se=null;#he={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#de=[0,0];#ue=null;#me=null;#pe=null;#ve=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=Soe.prototype,t=e=>e.#me.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),n=(e,{target:t})=>{if(t instanceof HTMLInputElement){const{type:e}=t;return"text"!==e&&"number"!==e}return!0},r=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return Dae(this,"_keyboardManager",new koe([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(t)&&!e.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:t}]]))}constructor(e,t,n,r,a,o,c,i,l,s,h,d,u){const m=this._signal=this.#k.signal;this.#me=e,this.#pe=t,this.#O=n,this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:m}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),r._on("setpreference",this.onSetPreference.bind(this),{signal:m}),r._on("switchannotationeditorparams",(e=>this.updateParams(e.type,e.value)),{signal:m}),this.#fe(),this.#ze(),this.#ge(),this.#A=a.annotationStorage,this.#q=a.filterFactory,this.#le=o,this.#K=c||null,this.#U=i,this.#W=l,this.#$=s,this.#ae=h||null,this.viewParameters={realScale:roe.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ve?.resolve(),this.#ve=null,this.#k?.abort(),this.#k=null,this._signal=null;for(const e of this.#T.values())e.destroy();this.#T.clear(),this.#S.clear(),this.#j.clear(),this.#x=null,this.#ce.clear(),this.#N.destroy(),this.#O?.destroy(),this.#Q?.hide(),this.#Q=null,this.#G&&(clearTimeout(this.#G),this.#G=null),this.#ue&&(clearTimeout(this.#ue),this.#ue=null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#ae}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#$}get hcmFilter(){return Dae(this,"hcmFilter",this.#le?this.#q.addHCMFilter(this.#le.foreground,this.#le.background):"none")}get direction(){return Dae(this,"direction",getComputedStyle(this.#me).direction)}get highlightColors(){return Dae(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((e=>e.split("=").map((e=>e.trim()))))):null)}get highlightColorNames(){return Dae(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(e=>e.reverse()))):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#D=e}setMainHighlightColorPicker(e){this.#re=e}editAltText(e,t=!1){this.#O?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){"enableNewAltTextWhenAddingImage"===e&&(this.#$=t)}onPageChanging({pageNumber:e}){this.#P=e-1}focusMainContainer(){this.#me.focus()}findParent(e,t){for(const n of this.#T.values()){const{x:r,y:a,width:o,height:c}=n.div.getBoundingClientRect();if(e>=r&&e<=r+o&&t>=a&&t<=a+c)return n}return null}disableUserSelect(e=!1){this.#pe.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#j.add(e)}removeShouldRescale(e){this.#j.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*roe.PDF_TO_CSS_UNITS;for(const e of this.#j)e.onScaleChanging();this.#D?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#ye({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Me(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const t of this.#T.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=t,c=t.toString(),i=this.#ye(t).closest(".textLayer"),l=this.getSelectionBoxes(i);if(!l)return;t.empty();const s=this.#Me(i),h=this.#oe===Hae.NONE,d=()=>{s?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:c}),h&&this.showAllEditors("highlight",!0,!0)};h?this.switchToMode(Hae.HIGHLIGHT,d):d()}#Ee(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=this.#ye(e).closest(".textLayer"),n=this.getSelectionBoxes(t);n&&(this.#Q||=new Hoe(this),this.#Q.show(t,n,"ltr"===this.direction))}addToAnnotationStorage(e){e.isEmpty()||!this.#A||this.#A.has(e.id)||this.#A.setValue(e.id,e)}#be(){const e=document.getSelection();if(!e||e.isCollapsed)return void(this.#ie&&(this.#Q?.hide(),this.#ie=null,this.#He({hasSelectedText:!1})));const{anchorNode:t}=e;if(t===this.#ie)return;const n=this.#ye(e).closest(".textLayer");if(n){if(this.#Q?.hide(),this.#ie=t,this.#He({hasSelectedText:!0}),(this.#oe===Hae.HIGHLIGHT||this.#oe===Hae.NONE)&&(this.#oe===Hae.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#X=this.isShiftKeyDown,!this.isShiftKeyDown)){const e=this.#oe===Hae.HIGHLIGHT?this.#Me(n):null;e?.toggleDrawing();const t=new AbortController,r=this.combinedSignal(t),a=n=>{"pointerup"===n.type&&0!==n.button||(t.abort(),e?.toggleDrawing(!0),"pointerup"===n.type&&this.#Ve("main_toolbar"))};window.addEventListener("pointerup",a,{signal:r}),window.addEventListener("blur",a,{signal:r})}}else this.#ie&&(this.#Q?.hide(),this.#ie=null,this.#He({hasSelectedText:!1}))}#Ve(e=""){this.#oe===Hae.HIGHLIGHT?this.highlightSelection(e):this.#U&&this.#Ee()}#fe(){document.addEventListener("selectionchange",this.#be.bind(this),{signal:this._signal})}#Ce(){if(this.#Y)return;this.#Y=new AbortController;const e=this.combinedSignal(this.#Y);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#Le(){this.#Y?.abort(),this.#Y=null}blur(){if(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of this.#ce)if(t.div.contains(e)){this.#ne=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#ne)return;const[e,t]=this.#ne;this.#ne=null,t.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),t.focus()}#ge(){if(this.#te)return;this.#te=new AbortController;const e=this.combinedSignal(this.#te);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#we(){this.#te?.abort(),this.#te=null}#ke(){if(this.#_)return;this.#_=new AbortController;const e=this.combinedSignal(this.#_);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#xe(){this.#_?.abort(),this.#_=null}#ze(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ge(),this.#ke()}removeEditListeners(){this.#we(),this.#xe()}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const n of this.#B)if(n.isHandlingMimeForPasting(t))return e.dataTransfer.dropEffect="copy",void e.preventDefault()}drop(e){for(const t of e.dataTransfer.items)for(const n of this.#B)if(n.isHandlingMimeForPasting(t.type))return n.paste(t,this.currentLayer),void e.preventDefault()}copy(e){if(e.preventDefault(),this.#x?.commitOrRemove(),!this.hasSelection)return;const t=[];for(const e of this.#ce){const n=e.serialize(!0);n&&t.push(n)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const e of t.items)for(const t of this.#B)if(t.isHandlingMimeForPasting(e.type))return void t.paste(e,this.currentLayer);let n=t.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(e){return void Aae(`paste: "${e.message}".`)}if(!Array.isArray(n))return;this.unselectAll();const r=this.currentLayer;try{const e=[];for(const t of n){const n=await r.deserialize(t);if(!n)return;e.push(n)}const t=()=>{for(const t of e)this.#Se(t);this.#Te(e)},a=()=>{for(const t of e)t.remove()};this.addCommands({cmd:t,undo:a,mustExec:!0})}catch(e){Aae(`paste: "${e.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#oe===Hae.NONE||this.isEditorHandlingKeyboard||Soe._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#He(e){Object.entries(e).some((([e,t])=>this.#he[e]!==t))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#he,e)}),this.#oe===Hae.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#Oe([[Vae.HIGHLIGHT_FREE,!0]]))}#Oe(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#Ce(),this.#ke(),this.#He({isEditing:this.#oe!==Hae.NONE,isEmpty:this.#Ae(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Le(),this.#xe(),this.#He({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#B){this.#B=e;for(const e of this.#B)this.#Oe(e.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#T.get(this.#P)}getLayer(e){return this.#T.get(e)}get currentPageIndex(){return this.#P}addLayer(e){this.#T.set(e.pageIndex,e),this.#Z?e.enable():e.disable()}removeLayer(e){this.#T.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#oe!==e&&(!this.#ve||(await this.#ve.promise,this.#ve))){if(this.#ve=Promise.withResolvers(),this.#oe=e,e===Hae.NONE)return this.setEditingState(!1),this.#Re(),this._editorUndoBar?.hide(),void this.#ve.resolve();this.setEditingState(!0),await this.#Ne(),this.unselectAll();for(const t of this.#T.values())t.updateMode(e);if(!t)return n&&this.addNewEditorFromKeyboard(),void this.#ve.resolve();for(const e of this.#S.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#ve.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#oe&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(this.#B){switch(e){case Vae.CREATE:return void this.currentLayer.addNewEditor();case Vae.HIGHLIGHT_DEFAULT_COLOR:this.#re?.updateColor(t);break;case Vae.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#se||=new Map).set(e,t),this.showAllEditors("highlight",t)}for(const n of this.#ce)n.updateParams(e,t);for(const n of this.#B)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(const n of this.#S.values())n.editorType===e&&n.show(t);(this.#se?.get(Vae.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#Oe([[Vae.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#ee!==e){this.#ee=e;for(const t of this.#T.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}async#Ne(){if(!this.#Z){this.#Z=!0;const e=[];for(const t of this.#T.values())e.push(t.enable());await Promise.all(e);for(const e of this.#S.values())e.enable()}}#Re(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const e of this.#T.values())e.disable();for(const e of this.#S.values())e.disable()}}getEditors(e){const t=[];for(const n of this.#S.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#S.get(e)}addEditor(e){this.#S.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#G&&clearTimeout(this.#G),this.#G=setTimeout((()=>{this.focusMainContainer(),this.#G=null}),0)),this.#S.delete(e.id),this.unselect(e),e.annotationElementId&&this.#F.has(e.annotationElementId)||this.#A?.remove(e.id)}addDeletedAnnotationElement(e){this.#F.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#F.has(e)}removeDeletedAnnotationElement(e){this.#F.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#Se(e){const t=this.#T.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#x!==e&&(this.#x=e,e&&this.#Oe(e.propertiesToUpdate))}get#_e(){let e=null;for(e of this.#ce);return e}updateUI(e){this.#_e===e&&this.#Oe(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#Oe(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#ce.has(e))return this.#ce.delete(e),e.unselect(),void this.#He({hasSelectedEditor:this.hasSelection});this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}setSelected(e){this.#D?.commitOrRemove();for(const t of this.#ce)t!==e&&t.unselect();this.#ce.clear(),this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}isSelected(e){return this.#ce.has(e)}get firstSelectedEditor(){return this.#ce.values().next().value}unselect(e){e.unselect(),this.#ce.delete(e),this.#He({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ce.size}get isEnterHandled(){return 1===this.#ce.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#He({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ae()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Ae()})}addCommands(e){this.#N.add(e),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ae()})}cleanUndoStack(e){this.#N.cleanType(e)}#Ae(){if(0===this.#S.size)return!0;if(1===this.#S.size)for(const e of this.#S.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...this.#ce],n=()=>{for(const e of t)this.#Se(e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo:n,mustExec:!0})}commitOrRemove(){this.#x?.commitOrRemove()}hasSomethingToControl(){return this.#x||this.hasSelection}#Te(e){for(const e of this.#ce)e.unselect();this.#ce.clear();for(const t of e)t.isEmpty()||(this.#ce.add(t),t.select());this.#He({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#ce)e.commit();this.#Te(this.#S.values())}unselectAll(){if((!this.#x||(this.#x.commitOrRemove(),this.#oe===Hae.NONE))&&!this.#D?.commitOrRemove()&&this.hasSelection){for(const e of this.#ce)e.unselect();this.#ce.clear(),this.#He({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#de[0]+=e,this.#de[1]+=t;const[r,a]=this.#de,o=[...this.#ce];this.#ue&&clearTimeout(this.#ue),this.#ue=setTimeout((()=>{this.#ue=null,this.#de[0]=this.#de[1]=0,this.addCommands({cmd:()=>{for(const e of o)this.#S.has(e.id)&&e.translateInPage(r,a)},undo:()=>{for(const e of o)this.#S.has(e.id)&&e.translateInPage(-r,-a)},mustExec:!1})}),1e3);for(const n of o)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#I=new Map;for(const e of this.#ce)this.#I.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#I)return!1;this.disableUserSelect(!1);const e=this.#I;this.#I=null;let t=!1;for(const[{x:n,y:r,pageIndex:a},o]of e)o.newX=n,o.newY=r,o.newPageIndex=a,t||=n!==o.savedX||r!==o.savedY||a!==o.savedPageIndex;if(!t)return!1;const n=(e,t,n,r)=>{if(this.#S.has(e.id)){const a=this.#T.get(r);a?e._setParentAndPosition(a,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(const[t,{newX:r,newY:a,newPageIndex:o}]of e)n(t,r,a,o)},undo:()=>{for(const[t,{savedX:r,savedY:a,savedPageIndex:o}]of e)n(t,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#I)for(const n of this.#I.keys())n.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#ce.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#x===e}getActive(){return this.#x}getMode(){return this.#oe}get imageManager(){return Dae(this,"imageManager",new Loe)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;const{x:n,y:r,width:a,height:o}=e.getBoundingClientRect();let c;switch(e.getAttribute("data-main-rotation")){case"90":c=(e,t,c,i)=>({x:(t-r)/o,y:1-(e+c-n)/a,width:i/o,height:c/a});break;case"180":c=(e,t,c,i)=>({x:1-(e+c-n)/a,y:1-(t+i-r)/o,width:c/a,height:i/o});break;case"270":c=(e,t,c,i)=>({x:1-(t+i-r)/o,y:(e-n)/a,width:i/o,height:c/a});break;default:c=(e,t,c,i)=>({x:(e-n)/a,y:(t-r)/o,width:c/a,height:i/o})}const i=[];for(let e=0,n=t.rangeCount;e<n;e++){const n=t.getRangeAt(e);if(!n.collapsed)for(const{x:e,y:t,width:r,height:a}of n.getClientRects())0!==r&&0!==a&&i.push(c(e,t,r,a))}return 0===i.length?null:i}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#R||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#R?.delete(e)}renderAnnotationElement(e){const t=this.#R?.get(e.data.id);if(!t)return;const n=this.#A.getRawValue(t);n&&(this.#oe!==Hae.NONE||n.hasBeenModified)&&n.renderAnnotationElement(e)}}class Toe{#i=null;#De=!1;#Pe=null;#Fe=null;#Ie=null;#Be=null;#je=!1;#Ue=null;#o=null;#We=null;#$e=null;#qe=!1;static#Ge=null;static _l10n=null;constructor(e){this.#o=e,this.#qe=e._uiManager.useNewAltTextFlow,Toe.#Ge||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){Toe._l10n??=e}async render(){const e=this.#Pe=document.createElement("button");e.className="altText",e.tabIndex="0";const t=this.#Fe=document.createElement("span");e.append(t),this.#qe?(e.classList.add("new"),e.setAttribute("data-l10n-id",Toe.#Ge.missing),t.setAttribute("data-l10n-id",Toe.#Ge["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=this.#o._uiManager._signal;e.addEventListener("contextmenu",moe,{signal:n}),e.addEventListener("pointerdown",(e=>e.stopPropagation()),{signal:n});const r=e=>{e.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#qe&&this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Ye}})};return e.addEventListener("click",r,{capture:!0,signal:n}),e.addEventListener("keydown",(t=>{t.target===e&&"Enter"===t.key&&(this.#je=!0,r(t))}),{signal:n}),await this.#Ke(),e}get#Ye(){return(this.#i?"added":null===this.#i&&this.guessedText&&"review")||"missing"}finish(){this.#Pe&&(this.#Pe.focus({focusVisible:this.#je}),this.#je=!1)}isEmpty(){return this.#qe?null===this.#i:!this.#i&&!this.#De}hasData(){return this.#qe?null!==this.#i||!!this.#We:this.isEmpty()}get guessedText(){return this.#We}async setGuessedText(e){null===this.#i&&(this.#We=e,this.#$e=await Toe._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#Ke())}toggleAltTextBadge(e=!1){if(!this.#qe||this.#i)return this.#Ue?.remove(),void(this.#Ue=null);if(!this.#Ue){const e=this.#Ue=document.createElement("div");e.className="noAltTextBadge",this.#o.div.append(e)}this.#Ue.classList.toggle("hidden",!e)}serialize(e){let t=this.#i;return e||this.#We!==t||(t=this.#$e),{altText:t,decorative:this.#De,guessedText:this.#We,textWithDisclaimer:this.#$e}}get data(){return{altText:this.#i,decorative:this.#De}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:a=!1}){n&&(this.#We=n,this.#$e=r),this.#i===e&&this.#De===t||(a||(this.#i=e,this.#De=t),this.#Ke())}toggle(e=!1){this.#Pe&&(!e&&this.#Be&&(clearTimeout(this.#Be),this.#Be=null),this.#Pe.disabled=!e)}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Ye}})}destroy(){this.#Pe?.remove(),this.#Pe=null,this.#Fe=null,this.#Ie=null,this.#Ue?.remove(),this.#Ue=null}async#Ke(){const e=this.#Pe;if(!e)return;if(this.#qe){if(e.classList.toggle("done",!!this.#i),e.setAttribute("data-l10n-id",Toe.#Ge[this.#Ye]),this.#Fe?.setAttribute("data-l10n-id",Toe.#Ge[`${this.#Ye}-label`]),!this.#i)return void this.#Ie?.remove()}else{if(!this.#i&&!this.#De)return e.classList.remove("done"),void this.#Ie?.remove();e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=this.#Ie;if(!t){this.#Ie=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${this.#o.id}`;const n=100,r=this.#o._uiManager._signal;r.addEventListener("abort",(()=>{clearTimeout(this.#Be),this.#Be=null}),{once:!0}),e.addEventListener("mouseenter",(()=>{this.#Be=setTimeout((()=>{this.#Be=null,this.#Ie.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})}),n)}),{signal:r}),e.addEventListener("mouseleave",(()=>{this.#Be&&(clearTimeout(this.#Be),this.#Be=null),this.#Ie?.classList.remove("show")}),{signal:r})}this.#De?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=this.#i),t.parentNode||e.append(t);const n=this.#o.getImageForAltText();n?.setAttribute("aria-describedby",t.id)}}class Ooe{#me;#Xe=!1;#Qe=null;#Je;#Ze;#et;#tt;#nt;#rt=null;#at;#ot=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:a=null,onPinchEnd:o=null,signal:c}){this.#me=e,this.#Qe=n,this.#Je=t,this.#Ze=r,this.#et=a,this.#tt=o,this.#at=new AbortController,this.#nt=AbortSignal.any([c,this.#at.signal]),e.addEventListener("touchstart",this.#ct.bind(this),{passive:!1,signal:this.#nt})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Dae(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ct(e){if(this.#Je?.()||e.touches.length<2)return;if(!this.#ot){this.#ot=new AbortController;const e=AbortSignal.any([this.#nt,this.#ot.signal]),t=this.#me,n={signal:e,passive:!1};t.addEventListener("touchmove",this.#it.bind(this),n),t.addEventListener("touchend",this.#lt.bind(this),n),t.addEventListener("touchcancel",this.#lt.bind(this),n),this.#Ze?.()}if(poe(e),2!==e.touches.length||this.#Qe?.())return void(this.#rt=null);let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#rt={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#it(e){if(!this.#rt||2!==e.touches.length)return;let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]);const{screenX:r,screenY:a}=t,{screenX:o,screenY:c}=n,i=this.#rt,{touch0X:l,touch0Y:s,touch1X:h,touch1Y:d}=i,u=h-l,m=d-s,p=o-r,v=c-a,f=Math.hypot(p,v)||1,z=Math.hypot(u,m)||1;if(!this.#Xe&&Math.abs(z-f)<=Ooe.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(i.touch0X=r,i.touch0Y=a,i.touch1X=o,i.touch1Y=c,e.preventDefault(),!this.#Xe)return void(this.#Xe=!0);const g=[(r+o)/2,(a+c)/2];this.#et?.(g,z,f)}#lt(e){this.#ot.abort(),this.#ot=null,this.#tt?.(),this.#rt&&(e.preventDefault(),this.#rt=null,this.#Xe=!1)}destroy(){this.#at?.abort(),this.#at=null}}class Aoe{#st=null;#ht=null;#i=null;#dt=!1;#ut=null;#mt="";#pt=!1;#vt=null;#ft=null;#zt=null;#gt=null;#yt="";#Mt=!1;#Et=null;#bt=!1;#Ht=!1;#Vt=!1;#Ct=null;#Lt=0;#wt=0;#kt=null;#xt=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#St=!1;#Tt=Aoe._zIndex++;static _borderLineWidth=-1;static _colorManager=new xoe;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const e=Aoe.prototype._resizeWithKeyboard,t=Soe.TRANSLATE_SMALL,n=Soe.TRANSLATE_BIG;return Dae(this,"_resizerKeyboardManager",new koe([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,n]}],[["Escape","mac+Escape"],Aoe.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[a,o];const[c,i]=this.parentDimensions;this.x=e.x/c,this.y=e.y/i,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Dae(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new Roe({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(Aoe._l10n??=e,Aoe._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Aoe._borderLineWidth)return;const n=getComputedStyle(document.documentElement);Aoe._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Rae("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#St}set _isDraggable(e){this.#St=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e),this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e),this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Tt}setParent(e){null!==e?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#Ot(),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#Mt?this.#Mt=!1:this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;t?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){const[a,o]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/a,this.y=(t+r)/o,this.fixAndSetPosition()}#At([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#At(this.parentDimensions,e,t)}translateInPage(e,t){this.#Et||=[this.x,this.y,this.width,this.height],this.#At(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#Et||=[this.x,this.y,this.width,this.height];const{div:n,parentDimensions:[r,a]}=this;if(this.x+=e/r,this.y+=t/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:c}=this;const[i,l]=this.getBaseTranslation();o+=i,c+=l;const{style:s}=n;s.left=`${(100*o).toFixed(2)}%`,s.top=`${(100*c).toFixed(2)}%`,this._onTranslating(o,c),n.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#Et&&(this.#Et[0]!==this.x||this.#Et[1]!==this.y)}get _hasBeenResized(){return!!this.#Et&&(this.#Et[2]!==this.width||this.#Et[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:n}=Aoe,r=n/e,a=n/t;switch(this.rotation){case 90:return[-r,a];case 180:return[r,a];case 270:return[r,-a];default:return[-r,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[n,r]}=this;let{x:a,y:o,width:c,height:i}=this;if(c*=n,i*=r,a*=n,o*=r,this._mustFixPosition)switch(e){case 0:a=Math.max(0,Math.min(n-c,a)),o=Math.max(0,Math.min(r-i,o));break;case 90:a=Math.max(0,Math.min(n-i,a)),o=Math.min(r,Math.max(c,o));break;case 180:a=Math.min(n,Math.max(c,a)),o=Math.min(r,Math.max(i,o));break;case 270:a=Math.min(n,Math.max(i,a)),o=Math.max(0,Math.min(r-c,o))}this.x=a/=n,this.y=o/=r;const[l,s]=this.getBaseTranslation();a+=l,o+=s,t.left=`${(100*a).toFixed(2)}%`,t.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}static#Rt(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return Aoe.#Rt(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return Aoe.#Rt(e,t,360-this.parentRotation)}#Nt(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){const[n,r]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*e/n).toFixed(2)}%`,this.#pt||(a.height=`${(100*t/r).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:n}=e,r=n.endsWith("%"),a=!this.#pt&&t.endsWith("%");if(r&&a)return;const[o,c]=this.parentDimensions;r||(e.width=`${(100*parseFloat(n)/o).toFixed(2)}%`),this.#pt||a||(e.height=`${(100*parseFloat(t)/c).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_t(){if(this.#vt)return;this.#vt=document.createElement("div"),this.#vt.classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const n of e){const e=document.createElement("div");this.#vt.append(e),e.classList.add("resizer",n),e.setAttribute("data-resizer-name",n),e.addEventListener("pointerdown",this.#Dt.bind(this,n),{signal:t}),e.addEventListener("contextmenu",moe,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#vt)}#Dt(e,t){t.preventDefault();const{isMac:n}=Kae.platform;if(0!==t.button||t.ctrlKey&&n)return;this.#i?.toggle(!1);const r=this._isDraggable;this._isDraggable=!1,this.#ft=[t.screenX,t.screenY];const a=new AbortController,o=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Pt.bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",poe,{passive:!1,signal:o}),window.addEventListener("contextmenu",moe,{signal:o}),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const c=this.parent.div.style.cursor,i=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const l=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=c,this.div.style.cursor=i,this.#Ft()};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}#It(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t;const[a,o]=this.parentDimensions;this.setDims(a*n,o*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#Ft(){if(!this.#zt)return;const{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#zt;this.#zt=null;const a=this.x,o=this.y,c=this.width,i=this.height;a===e&&o===t&&c===n&&i===r||this.addCommands({cmd:this.#It.bind(this,a,o,c,i),undo:this.#It.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(1e4*e)/1e4}#Pt(e,t){const[n,r]=this.parentDimensions,a=this.x,o=this.y,c=this.width,i=this.height,l=Aoe.MIN_SIZE/n,s=Aoe.MIN_SIZE/r,h=this.#Nt(this.rotation),d=(e,t)=>[h[0]*e+h[2]*t,h[1]*e+h[3]*t],u=this.#Nt(360-this.rotation);let m,p,v=!1,f=!1;switch(e){case"topLeft":v=!0,m=(e,t)=>[0,0],p=(e,t)=>[e,t];break;case"topMiddle":m=(e,t)=>[e/2,0],p=(e,t)=>[e/2,t];break;case"topRight":v=!0,m=(e,t)=>[e,0],p=(e,t)=>[0,t];break;case"middleRight":f=!0,m=(e,t)=>[e,t/2],p=(e,t)=>[0,t/2];break;case"bottomRight":v=!0,m=(e,t)=>[e,t],p=(e,t)=>[0,0];break;case"bottomMiddle":m=(e,t)=>[e/2,t],p=(e,t)=>[e/2,0];break;case"bottomLeft":v=!0,m=(e,t)=>[0,t],p=(e,t)=>[e,0];break;case"middleLeft":f=!0,m=(e,t)=>[0,t/2],p=(e,t)=>[e,t/2]}const z=m(c,i),g=p(c,i);let y=d(...g);const M=Aoe._round(a+y[0]),E=Aoe._round(o+y[1]);let b,H,V=1,C=1;if(t.fromKeyboard)({deltaX:b,deltaY:H}=t);else{const{screenX:e,screenY:n}=t,[r,a]=this.#ft;[b,H]=this.screenToPageTranslation(e-r,n-a),this.#ft[0]=e,this.#ft[1]=n}var L,w;if([b,H]=(L=b/n,w=H/r,[u[0]*L+u[2]*w,u[1]*L+u[3]*w]),v){const e=Math.hypot(c,i);V=C=Math.max(Math.min(Math.hypot(g[0]-z[0]-b,g[1]-z[1]-H)/e,1/c,1/i),l/c,s/i)}else f?V=Math.max(l,Math.min(1,Math.abs(g[0]-z[0]-b)))/c:C=Math.max(s,Math.min(1,Math.abs(g[1]-z[1]-H)))/i;const k=Aoe._round(c*V),x=Aoe._round(i*C);y=d(...p(k,x));const S=M-y[0],T=E-y[1];this.#Et||=[this.x,this.y,this.width,this.height],this.width=k,this.height=x,this.x=S,this.y=T,this.setDims(n*k,r*x),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ht||(this._editToolbar=new boe(this),this.div.append(this._editToolbar.render()),this.#i&&await this._editToolbar.addAltText(this.#i)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#i?.destroy())}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#i||(Toe.initialize(Aoe._l10n),this.#i=new Toe(this),this.#st&&(this.#i.data=this.#st,this.#st=null),await this.addEditToolbar())}get altTextData(){return this.#i?.data}set altTextData(e){this.#i&&(this.#i.data=e)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(e){await(this.#i?.setGuessedText(e))}serializeAltText(e){return this.#i?.serialize(e)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#dt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#Bt();const[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),Voe(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#xt||=new Ooe({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#jt.bind(this),onPinching:this.#Ut.bind(this),onPinchEnd:this.#Wt.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#jt(){this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ut(e,t,n){let r=n/t*.7+1-.7;if(1===r)return;const a=this.#Nt(this.rotation),o=(e,t)=>[a[0]*e+a[2]*t,a[1]*e+a[3]*t],[c,i]=this.parentDimensions,l=this.x,s=this.y,h=this.width,d=this.height,u=Aoe.MIN_SIZE/c,m=Aoe.MIN_SIZE/i;r=Math.max(Math.min(r,1/h,1/d),u/h,m/d);const p=Aoe._round(h*r),v=Aoe._round(d*r);if(p===h&&v===d)return;this.#Et||=[l,s,h,d];const f=o(h/2,d/2),z=Aoe._round(l+f[0]),g=Aoe._round(s+f[1]),y=o(p/2,v/2);this.x=z-y[0],this.y=g-y[1],this.width=p,this.height=v,this.setDims(c*p,i*v),this.fixAndSetPosition(),this._onResizing()}#Wt(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#Ft()}pointerdown(e){const{isMac:t}=Kae.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(this.#Mt=!0,this._isDraggable?this.#$t(e):this.#qt(e))}get isSelected(){return this._uiManager.isSelected(this)}#qt(e){const{isMac:t}=Kae.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#$t(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1;const r=new AbortController,a=this._uiManager.combinedSignal(r),o={capture:!0,passive:!1,signal:a},c=e=>{r.abort(),this.#ut=null,this.#Mt=!1,this._uiManager.endDragSession()||this.#qt(e),n&&this._onStopDragging()};t&&(this.#Lt=e.clientX,this.#wt=e.clientY,this.#ut=e.pointerId,this.#mt=e.pointerType,window.addEventListener("pointermove",(e=>{n||(n=!0,this._onStartDragging());const{clientX:t,clientY:r,pointerId:a}=e;if(a!==this.#ut)return void poe(e);const[o,c]=this.screenToPageTranslation(t-this.#Lt,r-this.#wt);this.#Lt=t,this.#wt=r,this._uiManager.dragSelectedEditors(o,c)}),o),window.addEventListener("touchmove",poe,o),window.addEventListener("pointerdown",(e=>{e.pointerType===this.#mt&&(this.#xt||e.isPrimary)&&c(e),poe(e)}),o));const i=e=>{this.#ut&&this.#ut!==e.pointerId?poe(e):c(e)};window.addEventListener("pointerup",i,{signal:a}),window.addEventListener("blur",i,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ct&&clearTimeout(this.#Ct),this.#Ct=setTimeout((()=>{this.#Ct=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){const r=this.parentScale,[a,o]=this.pageDimensions,[c,i]=this.pageTranslation,l=e/r,s=t/r,h=this.x*a,d=this.y*o,u=this.width*a,m=this.height*o;switch(n){case 0:return[h+l+c,o-d-s-m+i,h+l+u+c,o-d-s+i];case 90:return[h+s+c,o-d+l+i,h+s+m+c,o-d+l+u+i];case 180:return[h-l-u+c,o-d+s+i,h-l+c,o-d+s+m+i];case 270:return[h-s-m+c,o-d-l-u+i,h-s+c,o-d-l+i];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[n,r,a,o]=e,c=a-n,i=o-r;switch(this.rotation){case 0:return[n,t-o,c,i];case 90:return[n,t-r,i,c];case 180:return[a,t-r,c,i];case 270:return[a,t-o,i,c];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#Ht=!0}disableEditMode(){this.#Ht=!1}isInEditMode(){return this.#Ht}shouldGetKeyboardEvents(){return this.#Vt}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:a,innerWidth:o}=window;return t<o&&r>0&&e<a&&n>0}#Bt(){if(this.#gt||!this.div)return;this.#gt=new AbortController;const e=this._uiManager.combinedSignal(this.#gt);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#Bt()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){Rae("An editor must be serializable")}static async deserialize(e,t,n){const r=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});r.rotation=e.rotation,r.#st=e.accessibilityData;const[a,o]=r.pageDimensions,[c,i,l,s]=r.getRectInCurrentCoords(e.rect,o);return r.x=c/a,r.y=i/o,r.width=l/a,r.height=s/o,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#gt?.abort(),this.#gt=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ct&&(clearTimeout(this.#Ct),this.#Ct=null),this.#Ot(),this.removeEditToolbar(),this.#kt){for(const e of this.#kt.values())clearTimeout(e);this.#kt=null}this.parent=null,this.#xt?.destroy(),this.#xt=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_t(),this.#vt.classList.remove("hidden"),Voe(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const t=this.#vt.children;if(!this.#ht){this.#ht=Array.from(t);const e=this.#Gt.bind(this),n=this.#Yt.bind(this),r=this._uiManager._signal;for(const t of this.#ht){const a=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton"),t.addEventListener("keydown",e,{signal:r}),t.addEventListener("blur",n,{signal:r}),t.addEventListener("focus",this.#Kt.bind(this,a),{signal:r}),t.setAttribute("data-l10n-id",Aoe._l10nResizer[a])}}const n=this.#ht[0];let r=0;for(const e of t){if(e===n)break;r++}const a=(360-this.rotation+this.parentRotation)%360/90*(this.#ht.length/4);if(a!==r){if(a<r)for(let e=0;e<r-a;e++)this.#vt.append(this.#vt.firstChild);else if(a>r)for(let e=0;e<a-r;e++)this.#vt.firstChild.before(this.#vt.lastChild);let e=0;for(const n of t){const t=this.#ht[e++].getAttribute("data-resizer-name");n.setAttribute("data-l10n-id",Aoe._l10nResizer[t])}}this.#Xt(0),this.#Vt=!0,this.#vt.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#Gt(e){Aoe._resizerKeyboardManager.exec(this,e)}#Yt(e){this.#Vt&&e.relatedTarget?.parentNode!==this.#vt&&this.#Ot()}#Kt(e){this.#yt=this.#Vt?e:""}#Xt(e){if(this.#ht)for(const t of this.#ht)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#Vt&&this.#Pt(this.#yt,{deltaX:e,deltaY:t,fromKeyboard:!0})}#Ot(){this.#Vt=!1,this.#Xt(-1),this.#Ft()}_stopResizingWithKeyboard(){this.#Ot(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#vt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#bt}set isEditing(e){this.#bt=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#pt=!0;const n=e/t,{style:r}=this.div;r.aspectRatio=n,r.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#kt||=new Map;const{action:t}=e;let n=this.#kt.get(t);return n&&clearTimeout(n),n=setTimeout((()=>{this._reportTelemetry(e),this.#kt.delete(t),0===this.#kt.size&&(this.#kt=null)}),Aoe._telemetryTimeout),void this.#kt.set(t,n)}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#dt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#dt=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.before(t)}}else t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);return t}resetAnnotationElement(e){const{firstChild:t}=e.container;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}class Roe extends Aoe{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Noe=3285377520,_oe=4294901760,Doe=65535;class Poe{constructor(e){this.h1=e?4294967295&e:Noe,this.h2=e?4294967295&e:Noe}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let r=0,a=e.length;r<a;r++){const a=e.charCodeAt(r);a<=255?t[n++]=a:(t[n++]=a>>>8,t[n++]=255&a)}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice(),n=t.byteLength}const r=n>>2,a=n-4*r,o=new Uint32Array(t.buffer,0,r);let c=0,i=0,l=this.h1,s=this.h2;const h=3432918353,d=461845907,u=11601,m=13715;for(let e=0;e<r;e++)1&e?(c=o[e],c=c*h&_oe|c*u&Doe,c=c<<15|c>>>17,c=c*d&_oe|c*m&Doe,l^=c,l=l<<13|l>>>19,l=5*l+3864292196):(i=o[e],i=i*h&_oe|i*u&Doe,i=i<<15|i>>>17,i=i*d&_oe|i*m&Doe,s^=i,s=s<<13|s>>>19,s=5*s+3864292196);switch(c=0,a){case 3:c^=t[4*r+2]<<16;case 2:c^=t[4*r+1]<<8;case 1:c^=t[4*r],c=c*h&_oe|c*u&Doe,c=c<<15|c>>>17,c=c*d&_oe|c*m&Doe,1&r?l^=c:s^=c}this.h1=l,this.h2=s}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&_oe|36045*e&Doe,t=4283543511*t&_oe|(2950163797*(t<<16|e>>>16)&_oe)>>>16,e^=t>>>1,e=444984403*e&_oe|60499*e&Doe,t=3301882366*t&_oe|(3120437893*(t<<16|e>>>16)&_oe)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const Foe=Object.freeze({map:null,hash:"",transfer:void 0});class Ioe{#Qt=!1;#Jt=null;#Zt=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const n=this.#Zt.get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return this.#Zt.get(e)}remove(e){if(this.#Zt.delete(e),0===this.#Zt.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const e of this.#Zt.values())if(e instanceof Aoe)return;this.onAnnotationEditor(null)}}setValue(e,t){const n=this.#Zt.get(e);let r=!1;if(void 0!==n)for(const[e,a]of Object.entries(t))n[e]!==a&&(r=!0,n[e]=a);else r=!0,this.#Zt.set(e,t);r&&this.#en(),t instanceof Aoe&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#Zt.has(e)}getAll(){return this.#Zt.size>0?Yae(this.#Zt):null}setAll(e){for(const[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#Zt.size}#en(){this.#Qt||(this.#Qt=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qt&&(this.#Qt=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Boe(this)}get serializable(){if(0===this.#Zt.size)return Foe;const e=new Map,t=new Poe,n=[],r=Object.create(null);let a=!1;for(const[n,o]of this.#Zt){const c=o instanceof Aoe?o.serialize(!1,r):o;c&&(e.set(n,c),t.update(`${n}:${JSON.stringify(c)}`),a||=!!c.bitmap)}if(a)for(const t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Foe}get editorStats(){let e=null;const t=new Map;for(const n of this.#Zt.values()){if(!(n instanceof Aoe))continue;const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;t.has(a)||t.set(a,Object.getPrototypeOf(n).constructor),e||=Object.create(null);const o=e[a]||=new Map;for(const[e,t]of Object.entries(r)){if("type"===e)continue;let n=o.get(e);n||(n=new Map,o.set(e,n));const r=n.get(t)??0;n.set(t,r+1)}}for(const[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#Jt=null}get modifiedIds(){if(this.#Jt)return this.#Jt;const e=[];for(const t of this.#Zt.values())t instanceof Aoe&&t.annotationElementId&&t.serialize()&&e.push(t.annotationElementId);return this.#Jt={ids:new Set(e),hash:e.join(",")}}}class Boe extends Ioe{#tn;constructor(e){super();const{map:t,hash:n,transfer:r}=e.serializable,a=structuredClone(t,r?{transfer:r}:null);this.#tn={map:a,hash:n,transfer:r}}get print(){Rae("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#tn}get modifiedIds(){return Dae(this,"modifiedIds",{ids:new Set,hash:""})}}class joe{#nn=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#nn.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(e&&!this.#nn.has(e.loadedName))if(Nae(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:r,style:a}=e,o=new FontFace(n,r,a);this.addNativeFontFace(o);try{await o.load(),this.#nn.add(n),t?.(e)}catch{Aae(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}}else Rae("Not implemented: loadSystemFont without the Font Loading API.")}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void await this.loadSystemFont(e);if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw Aae(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise((t=>{const n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}get isFontLoadingAPISupported(){return Dae(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let e=!1;return(gae||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Dae(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const{loadingRequests:t}=this,n={done:!1,complete:function(){for(Nae(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){return Dae(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function r(e,t,n,r){return e.substring(0,t)+r+e.substring(t+n)}let a,o;const c=this._document.createElement("canvas");c.width=1,c.height=1;const i=c.getContext("2d");let l=0;const s=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=r(h,976,s.length,s);const d=1482184792;let u=n(h,16);for(a=0,o=s.length-3;a<o;a+=4)u=u-d+n(s,a)|0;a<s.length&&(u=u-d+n(s+"XXX",a)|0),h=r(h,16,4,function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(u));const m=`@font-face {font-family:"${s}";src:url(data:font/opentype;base64,${btoa(h)});}`;this.insertRule(m);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const t of[e.loadedName,s]){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,p.append(e)}this._document.body.append(p),function e(t,n){if(++l>30)return Aae("Load test font never loaded."),void n();i.font="30px "+t,i.fillText(".",0,20),i.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(s,(()=>{p.remove(),t.complete()}))}}class Uoe{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.disableFontFace=!0===t,this.fontExtraProperties=!0===n,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t=this.data,Uint8Array.prototype.toBase64?t.toBase64():btoa(qae(t))});`;var t;let n;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),n}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];const n=this.loadedName+"_path_"+t;let r;try{r=e.get(n)}catch(e){Aae(`getPathGenerator - ignoring character: "${e}".`)}const a=new Path2D(r||"");return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=a}}function Woe(){}function $oe(e){if(e instanceof $ae||e instanceof Bae||e instanceof jae||e instanceof Fae||e instanceof Uae||e instanceof Iae)return e;switch(e instanceof Error||"object"==typeof e&&null!==e||Rae('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new $ae(e.message);case"InvalidPDFException":return new Bae(e.message);case"MissingPDFException":return new jae(e.message);case"PasswordException":return new Fae(e.message,e.code);case"UnexpectedResponseException":return new Uae(e.message,e.status);case"UnknownErrorException":return new Iae(e.message,e.details)}return new Iae(e.message,e.toString())}class qoe{#rn=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",this.#an.bind(this),{signal:this.#rn.signal})}#an({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#on(e);if(e.callback){const t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)n.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");n.reject($oe(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const n=this.sourceName,r=e.sourceName,a=this.comObj;Promise.try(t,e.data).then((function(t){a.postMessage({sourceName:n,targetName:r,callback:1,callbackId:e.callbackId,data:t})}),(function(t){a.postMessage({sourceName:n,targetName:r,callback:2,callbackId:e.callbackId,reason:$oe(t)})}))}else e.streamId?this.#cn(e):t(e.data)}on(e,t){const n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){const r=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){a.reject(e)}return a.promise}sendWithStream(e,t,n,r){const a=this.streamId++,o=this.sourceName,c=this.targetName,i=this.comObj;return new ReadableStream({start:n=>{const l=Promise.withResolvers();return this.streamControllers[a]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},i.postMessage({sourceName:o,targetName:c,action:e,streamId:a,data:t,desiredSize:n.desiredSize},r),l.promise},pull:e=>{const t=Promise.withResolvers();return this.streamControllers[a].pullCall=t,i.postMessage({sourceName:o,targetName:c,stream:6,streamId:a,desiredSize:e.desiredSize}),t.promise},cancel:e=>{Nae(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();return this.streamControllers[a].cancelCall=t,this.streamControllers[a].isClosed=!0,i.postMessage({sourceName:o,targetName:c,stream:1,streamId:a,reason:$oe(e)}),t.promise}},n)}#cn(e){const t=e.streamId,n=this.sourceName,r=e.sourceName,a=this.comObj,o=this,c=this.actionHandler[e.action],i={enqueue(e,o=1,c){if(this.isCancelled)return;const i=this.desiredSize;this.desiredSize-=o,i>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:n,targetName:r,stream:4,streamId:t,chunk:e},c)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:3,streamId:t}),delete o.streamSinks[t])},error(e){Nae(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:5,streamId:t,reason:$oe(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};i.sinkCapability.resolve(),i.ready=i.sinkCapability.promise,this.streamSinks[t]=i,Promise.try(c,e.data,i).then((function(){a.postMessage({sourceName:n,targetName:r,stream:8,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:n,targetName:r,stream:8,streamId:t,reason:$oe(e)})}))}#on(e){const t=e.streamId,n=this.sourceName,r=e.sourceName,a=this.comObj,o=this.streamControllers[t],c=this.streamSinks[t];switch(e.stream){case 8:e.success?o.startCall.resolve():o.startCall.reject($oe(e.reason));break;case 7:e.success?o.pullCall.resolve():o.pullCall.reject($oe(e.reason));break;case 6:if(!c){a.postMessage({sourceName:n,targetName:r,stream:7,streamId:t,success:!0});break}c.desiredSize<=0&&e.desiredSize>0&&c.sinkCapability.resolve(),c.desiredSize=e.desiredSize,Promise.try(c.onPull||Woe).then((function(){a.postMessage({sourceName:n,targetName:r,stream:7,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:n,targetName:r,stream:7,streamId:t,reason:$oe(e)})}));break;case 4:if(Nae(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case 3:if(Nae(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#in(o,t);break;case 5:Nae(o,"error should have stream controller"),o.controller.error($oe(e.reason)),this.#in(o,t);break;case 2:e.success?o.cancelCall.resolve():o.cancelCall.reject($oe(e.reason)),this.#in(o,t);break;case 1:if(!c)break;const i=$oe(e.reason);Promise.try(c.onCancel||Woe,i).then((function(){a.postMessage({sourceName:n,targetName:r,stream:2,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:n,targetName:r,stream:2,streamId:t,reason:$oe(e)})})),c.sinkCapability.reject(i),c.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async#in(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#rn?.abort(),this.#rn=null}}class Goe{#ln=!1;constructor({enableHWA:e=!1}){this.#ln=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#ln})}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Rae("Abstract method `_createCanvas` called.")}}class Yoe{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(t).then((e=>({cMapData:e,isCompressed:this.isCompressed}))).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}async _fetch(e){Rae("Abstract method `_fetch` called.")}}class Koe extends Yoe{async _fetch(e){const t=await aoe(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):Gae(t)}}class Xoe{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,n,r,a){return"none"}destroy(e=!1){}}class Qoe{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetch(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}async _fetch(e){Rae("Abstract method `_fetch` called.")}}class Joe extends Qoe{async _fetch(e){const t=await aoe(e,"arraybuffer");return new Uint8Array(t)}}async function Zoe(e){const t=xt.getBuiltinModule("fs"),n=await t.promises.readFile(e);return new Uint8Array(n)}gae&&Aae("Please use the `legacy` build in Node.js environments.");const ece="Fill",tce="Stroke",nce="Shading";function rce(e,t){if(!t)return;const n=t[2]-t[0],r=t[3]-t[1],a=new Path2D;a.rect(t[0],t[1],n,r),e.clip(a)}class ace{getPattern(){Rae("Abstract method `getPattern` called.")}}class oce extends ace{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,r){let a;if(r===tce||r===ece){const o=t.current.getClippedPathBoundingBox(r,goe(e))||[0,0,0,0],c=Math.ceil(o[2]-o[0])||1,i=Math.ceil(o[3]-o[1])||1,l=t.cachedCanvases.getCanvas("pattern",c,i),s=l.context;s.clearRect(0,0,s.canvas.width,s.canvas.height),s.beginPath(),s.rect(0,0,s.canvas.width,s.canvas.height),s.translate(-o[0],-o[1]),n=Qae.transform(n,[1,0,0,1,o[0],o[1]]),s.transform(...t.baseTransform),this.matrix&&s.transform(...this.matrix),rce(s,this._bbox),s.fillStyle=this._createGradient(s),s.fill(),a=e.createPattern(l.canvas,"no-repeat");const h=new DOMMatrix(n);a.setTransform(h)}else rce(e,this._bbox),a=this._createGradient(e);return a}}function cce(e,t,n,r,a,o,c,i){const l=t.coords,s=t.colors,h=e.data,d=4*e.width;let u;l[n+1]>l[r+1]&&(u=n,n=r,r=u,u=o,o=c,c=u),l[r+1]>l[a+1]&&(u=r,r=a,a=u,u=c,c=i,i=u),l[n+1]>l[r+1]&&(u=n,n=r,r=u,u=o,o=c,c=u);const m=(l[n]+t.offsetX)*t.scaleX,p=(l[n+1]+t.offsetY)*t.scaleY,v=(l[r]+t.offsetX)*t.scaleX,f=(l[r+1]+t.offsetY)*t.scaleY,z=(l[a]+t.offsetX)*t.scaleX,g=(l[a+1]+t.offsetY)*t.scaleY;if(p>=g)return;const y=s[o],M=s[o+1],E=s[o+2],b=s[c],H=s[c+1],V=s[c+2],C=s[i],L=s[i+1],w=s[i+2],k=Math.round(p),x=Math.round(g);let S,T,O,A,R,N,_,D;for(let e=k;e<=x;e++){if(e<f){const t=e<p?0:(p-e)/(p-f);S=m-(m-v)*t,T=y-(y-b)*t,O=M-(M-H)*t,A=E-(E-V)*t}else{let t;t=e>g?1:f===g?0:(f-e)/(f-g),S=v-(v-z)*t,T=b-(b-C)*t,O=H-(H-L)*t,A=V-(V-w)*t}let t;t=e<p?0:e>g?1:(p-e)/(p-g),R=m-(m-z)*t,N=y-(y-C)*t,_=M-(M-L)*t,D=E-(E-w)*t;const n=Math.round(Math.min(S,R)),r=Math.round(Math.max(S,R));let a=d*e+4*n;for(let e=n;e<=r;e++)t=(S-e)/(S-R),t<0?t=0:t>1&&(t=1),h[a++]=T-(T-N)*t|0,h[a++]=O-(O-_)*t|0,h[a++]=A-(A-D)*t|0,h[a++]=255}}function ice(e,t,n){const r=t.coords,a=t.colors;let o,c;switch(t.type){case"lattice":const i=t.verticesPerRow,l=Math.floor(r.length/i)-1,s=i-1;for(o=0;o<l;o++){let t=o*i;for(let o=0;o<s;o++,t++)cce(e,n,r[t],r[t+1],r[t+i],a[t],a[t+1],a[t+i]),cce(e,n,r[t+i+1],r[t+1],r[t+i],a[t+i+1],a[t+1],a[t+i])}break;case"triangles":for(o=0,c=r.length;o<c;o+=3)cce(e,n,r[o],r[o+1],r[o+2],a[o],a[o+1],a[o+2]);break;default:throw new Error("illegal figure")}}class lce extends ace{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){const r=Math.floor(this._bounds[0]),a=Math.floor(this._bounds[1]),o=Math.ceil(this._bounds[2])-r,c=Math.ceil(this._bounds[3])-a,i=Math.min(Math.ceil(Math.abs(o*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(c*e[1]*1.1)),3e3),s=o/i,h=c/l,d={coords:this._coords,colors:this._colors,offsetX:-r,offsetY:-a,scaleX:1/s,scaleY:1/h},u=i+4,m=l+4,p=n.getCanvas("mesh",u,m),v=p.context,f=v.createImageData(i,l);if(t){const e=f.data;for(let n=0,r=e.length;n<r;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(const e of this._figures)ice(f,e,d);return v.putImageData(f,2,2),{canvas:p.canvas,offsetX:r-2*s,offsetY:a-2*h,scaleX:s,scaleY:h}}getPattern(e,t,n,r){let a;if(rce(e,this._bbox),r===nce)a=Qae.singularValueDecompose2dScale(goe(e));else if(a=Qae.singularValueDecompose2dScale(t.baseTransform),this.matrix){const e=Qae.singularValueDecompose2dScale(this.matrix);a=[a[0]*e[0],a[1]*e[1]]}const o=this._createMeshCanvas(a,r===nce?null:this._background,t.cachedCanvases);return r!==nce&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(o.offsetX,o.offsetY),e.scale(o.scaleX,o.scaleY),e.createPattern(o.canvas,"no-repeat")}}class sce extends ace{getPattern(){return"hotpink"}}class hce{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,r,a){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(e){const{bbox:t,operatorList:n,paintType:r,tilingType:a,color:o,canvasGraphicsFactory:c}=this;let{xstep:i,ystep:l}=this;i=Math.abs(i),l=Math.abs(l),Oae("TilingType: "+a);const s=t[0],h=t[1],d=t[2],u=t[3],m=d-s,p=u-h,v=Qae.singularValueDecompose2dScale(this.matrix),f=Qae.singularValueDecompose2dScale(this.baseTransform),z=v[0]*f[0],g=v[1]*f[1];let y=m,M=p,E=!1,b=!1;const H=Math.ceil(i*z),V=Math.ceil(l*g);H>=Math.ceil(m*z)?y=i:E=!0,V>=Math.ceil(p*g)?M=l:b=!0;const C=this.getSizeAndScale(y,this.ctx.canvas.width,z),L=this.getSizeAndScale(M,this.ctx.canvas.height,g),w=e.cachedCanvases.getCanvas("pattern",C.size,L.size),k=w.context,x=c.createCanvasGraphics(k);if(x.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(x,r,o),k.translate(-C.scale*s,-L.scale*h),x.transform(C.scale,0,0,L.scale,0,0),k.save(),this.clipBbox(x,s,h,d,u),x.baseTransform=goe(x.ctx),x.executeOperatorList(n),x.endDrawing(),k.restore(),E||b){const t=w.canvas;E&&(y=i),b&&(M=l);const n=this.getSizeAndScale(y,this.ctx.canvas.width,z),r=this.getSizeAndScale(M,this.ctx.canvas.height,g),a=n.size,o=r.size,c=e.cachedCanvases.getCanvas("pattern-workaround",a,o),d=c.context,u=E?Math.floor(m/i):0,v=b?Math.floor(p/l):0;for(let e=0;e<=u;e++)for(let n=0;n<=v;n++)d.drawImage(t,a*e,o*n,a,o,0,0,a,o);return{canvas:c.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:s,offsetY:h}}return{canvas:w.canvas,scaleX:C.scale,scaleY:L.scale,offsetX:s,offsetY:h}}getSizeAndScale(e,t,n){const r=Math.max(hce.MAX_PATTERN_SIZE,t);let a=Math.ceil(e*n);return a>=r?a=r:n=a/e,{scale:n,size:a}}clipBbox(e,t,n,r,a){const o=r-t,c=a-n;e.ctx.rect(t,n,o,c),e.current.updateRectMinMax(goe(e.ctx),[t,n,r,a]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){const r=e.ctx,a=e.current;switch(t){case 1:const e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,a.fillColor=e.fillStyle,a.strokeColor=e.strokeStyle;break;case 2:const o=Qae.makeHexColor(n[0],n[1],n[2]);r.fillStyle=o,r.strokeStyle=o,a.fillColor=o,a.strokeColor=o;break;default:throw new Wae(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let a=n;r!==nce&&(a=Qae.transform(a,t.baseTransform),this.matrix&&(a=Qae.transform(a,this.matrix)));const o=this.createPatternCanvas(t);let c=new DOMMatrix(a);c=c.translate(o.offsetX,o.offsetY),c=c.scale(1/o.scaleX,1/o.scaleY);const i=e.createPattern(o.canvas,"repeat");return i.setTransform(c),i}}function dce({src:e,srcPos:t=0,dest:n,width:r,height:a,nonBlackColor:o=4294967295,inverseDecode:c=!1}){const i=Kae.isLittleEndian?4278190080:255,[l,s]=c?[o,i]:[i,o],h=r>>3,d=7&r,u=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r<a;r++){for(const r=t+h;t<r;t++){const r=t<u?e[t]:255;n[m++]=128&r?s:l,n[m++]=64&r?s:l,n[m++]=32&r?s:l,n[m++]=16&r?s:l,n[m++]=8&r?s:l,n[m++]=4&r?s:l,n[m++]=2&r?s:l,n[m++]=1&r?s:l}if(0===d)continue;const r=t<u?e[t++]:255;for(let e=0;e<d;e++)n[m++]=r&1<<7-e?s:l}return{srcPos:t,destPos:m}}const uce=16;class mce{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let r;return void 0!==this.cache[e]?(r=this.cache[e],this.canvasFactory.reset(r,t,n)):(r=this.canvasFactory.create(t,n),this.cache[e]=r),r}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function pce(e,t,n,r,a,o,c,i,l,s){const[h,d,u,m,p,v]=goe(e);if(0===d&&0===u){const f=c*h+p,z=Math.round(f),g=i*m+v,y=Math.round(g),M=(c+l)*h+p,E=Math.abs(Math.round(M)-z)||1,b=(i+s)*m+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(Math.sign(h),0,0,Math.sign(m),z,y),e.drawImage(t,n,r,a,o,0,0,E,H),e.setTransform(h,d,u,m,p,v),[E,H]}if(0===h&&0===m){const f=i*u+p,z=Math.round(f),g=c*d+v,y=Math.round(g),M=(i+s)*u+p,E=Math.abs(Math.round(M)-z)||1,b=(c+l)*d+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(u),0,z,y),e.drawImage(t,n,r,a,o,0,0,H,E),e.setTransform(h,d,u,m,p,v),[H,E]}return e.drawImage(t,n,r,a,o,c,i,l,s),[Math.hypot(h,d)*l,Math.hypot(u,m)*s]}class vce{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=yae,this.textMatrixScale=1,this.fontMatrix=Mae,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=Qae.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){const n=Qae.applyTransform(t,e),r=Qae.applyTransform(t.slice(2),e),a=Qae.applyTransform([t[0],t[3]],e),o=Qae.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],r[0],a[0],o[0]),this.minY=Math.min(this.minY,n[1],r[1],a[1],o[1]),this.maxX=Math.max(this.maxX,n[0],r[0],a[0],o[0]),this.maxY=Math.max(this.maxY,n[1],r[1],a[1],o[1])}updateScalingPathMinMax(e,t){Qae.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,r,a,o,c,i,l,s){const h=Qae.bezierBoundingBox(t,n,r,a,o,c,i,l,s);s||this.updateRectMinMax(e,h)}getPathBoundingBox(e=ece,t=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(e===tce){t||Rae("Stroke bounding box must include transform.");const e=Qae.singularValueDecompose2dScale(t),r=e[0]*this.lineWidth/2,a=e[1]*this.lineWidth/2;n[0]-=r,n[1]-=a,n[2]+=r,n[3]+=a}return n}updateClipFromPath(){const e=Qae.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=ece,t=null){return Qae.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function fce(e,t){if(t instanceof ImageData)return void e.putImageData(t,0,0);const n=t.height,r=t.width,a=n%uce,o=(n-a)/uce,c=0===a?o:o+1,i=e.createImageData(r,uce);let l,s=0;const h=t.data,d=i.data;let u,m,p,v;if(t.kind===Lae.GRAYSCALE_1BPP){const t=h.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),v=n.length,f=r+7>>3,z=4294967295,g=Kae.isLittleEndian?4278190080:255;for(u=0;u<c;u++){for(p=u<o?uce:a,l=0,m=0;m<p;m++){const e=t-s;let a=0;const o=e>f?r:8*e-7,c=-8&o;let i=0,d=0;for(;a<c;a+=8)d=h[s++],n[l++]=128&d?z:g,n[l++]=64&d?z:g,n[l++]=32&d?z:g,n[l++]=16&d?z:g,n[l++]=8&d?z:g,n[l++]=4&d?z:g,n[l++]=2&d?z:g,n[l++]=1&d?z:g;for(;a<o;a++)0===i&&(d=h[s++],i=128),n[l++]=d&i?z:g,i>>=1}for(;l<v;)n[l++]=0;e.putImageData(i,0,u*uce)}}else if(t.kind===Lae.RGBA_32BPP){for(m=0,v=r*uce*4,u=0;u<o;u++)d.set(h.subarray(s,s+v)),s+=v,e.putImageData(i,0,m),m+=uce;u<c&&(v=r*a*4,d.set(h.subarray(s,s+v)),e.putImageData(i,0,m))}else{if(t.kind!==Lae.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(p=uce,v=r*p,u=0;u<c;u++){for(u>=o&&(p=a,v=r*p),l=0,m=v;m--;)d[l++]=h[s++],d[l++]=h[s++],d[l++]=h[s++],d[l++]=255;e.putImageData(i,0,u*uce)}}}function zce(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);const n=t.height,r=t.width,a=n%uce,o=(n-a)/uce,c=0===a?o:o+1,i=e.createImageData(r,uce);let l=0;const s=t.data,h=i.data;for(let t=0;t<c;t++){const n=t<o?uce:a;({srcPos:l}=dce({src:s,srcPos:l,dest:h,width:r,height:n,nonBlackColor:0})),e.putImageData(i,0,t*uce)}}function gce(e,t){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)void 0!==e[r]&&(t[r]=e[r]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function yce(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),!gae){const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function Mce(e,t){if(t)return!0;const n=Qae.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);const r=Math.fround((globalThis.devicePixelRatio||1)*roe.PDF_TO_CSS_UNITS);return n[0]<=r&&n[1]<=r}const Ece=["butt","round","square"],bce=["miter","round","bevel"],Hce={},Vce={};class Cce{constructor(e,t,n,r,a,{optionalContentConfig:o,markedContentStack:c=null},i,l){this.ctx=e,this.current=new vce(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=c||[],this.optionalContentConfig=o,this.cachedCanvases=new mce(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=i,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){const a=this.ctx.canvas.width,o=this.ctx.canvas.height,c=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,a,o),this.ctx.fillStyle=c,n){const e=this.cachedCanvases.getCanvas("transparent",a,o);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...goe(this.compositeCtx))}this.ctx.save(),yce(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=goe(this.ctx)}executeOperatorList(e,t,n,r){const a=e.argsArray,o=e.fnArray;let c=t||0;const i=a.length;if(i===c)return c;const l=i-c>10&&"function"==typeof n,s=l?Date.now()+15:0;let h=0;const d=this.commonObjs,u=this.objs;let m;for(;;){if(void 0!==r&&c===r.nextBreakPoint)return r.breakIt(c,n),c;if(m=o[c],m!==kae.dependency)this[m].apply(this,a[c]);else for(const e of a[c]){const t=e.startsWith("g_")?d:u;if(!t.has(e))return t.get(e,n),c}if(c++,c===i)return c;if(l&&++h>10){if(Date.now()>s)return n(),c;h=0}}}#sn(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#sn(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#hn()}#hn(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){const n=e.width??e.displayWidth,r=e.height??e.displayHeight;let a,o,c=Math.max(Math.hypot(t[0],t[1]),1),i=Math.max(Math.hypot(t[2],t[3]),1),l=n,s=r,h="prescale1";for(;c>2&&l>1||i>2&&s>1;){let t=l,n=s;c>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),c/=l/t),i>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,i/=s/n),a=this.cachedCanvases.getCanvas(h,t,n),o=a.context,o.clearRect(0,0,t,n),o.drawImage(e,0,0,l,s,0,0,t,n),e=a.canvas,l=t,s=n,h="prescale1"===h?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:s}}_createMaskCanvas(e){const t=this.ctx,{width:n,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,c=goe(t);let i,l,s,h;if((e.bitmap||e.data)&&e.count>1){const t=e.bitmap||e.data.buffer;l=JSON.stringify(o?c:[c.slice(0,4),a]),i=this._cachedBitmapsMap.get(t),i||(i=new Map,this._cachedBitmapsMap.set(t,i));const n=i.get(l);if(n&&!o)return{canvas:n,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};s=n}s||(h=this.cachedCanvases.getCanvas("maskCanvas",n,r),zce(h.context,e));let d=Qae.transform(c,[1/n,0,0,-1/r,0,0]);d=Qae.transform(d,[1,0,0,1,0,-r]);const[u,m,p,v]=Qae.getAxialAlignedBoundingBox([0,0,n,r],d),f=Math.round(p-u)||1,z=Math.round(v-m)||1,g=this.cachedCanvases.getCanvas("fillCanvas",f,z),y=g.context,M=u,E=m;y.translate(-M,-E),y.transform(...d),s||(s=this._scaleImage(h.canvas,yoe(y)),s=s.img,i&&o&&i.set(l,s)),y.imageSmoothingEnabled=Mce(goe(y),e.interpolate),pce(y,s,0,0,s.width,s.height,0,0,n,r),y.globalCompositeOperation="source-in";const b=Qae.transform(yoe(y),[1,0,0,1,-M,-E]);return y.fillStyle=o?a.getPattern(t,this,b,ece):a,y.fillRect(0,0,n,r),i&&!o&&(this.cachedCanvases.delete("fillCanvas"),i.set(l,g.canvas)),{canvas:g.canvas,offsetX:Math.round(M),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=Ece[e]}setLineJoin(e){this.ctx.lineJoin=bce[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=r.context;const a=this.ctx;a.setTransform(...goe(this.suspendedCtx)),gce(this.suspendedCtx,a),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,r,a,o,c){t.transform(e,n,r,a,o,c),this.__originalTransform(e,n,r,a,o,c)},e.setTransform=function(e,n,r,a,o,c){t.setTransform(e,n,r,a,o,c),this.__originalSetTransform(e,n,r,a,o,c)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,r,a,o,c){t.bezierCurveTo(e,n,r,a,o,c),this.__originalBezierCurveTo(e,n,r,a,o,c)},e.rect=function(e,n,r,a){t.rect(e,n,r,a),this.__originalRect(e,n,r,a)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(a,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),gce(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,r){const a=r[0],o=r[1],c=r[2]-a,i=r[3]-o;0!==c&&0!==i&&(this.genericComposeSMask(t.context,n,c,i,t.subtype,t.backdrop,t.transferMap,a,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,r,a,o,c,i,l,s,h){let d=e.canvas,u=i-s,m=l-h;if(o){const t=Qae.makeHexColor(...o);if(u<0||m<0||u+n>d.width||m+r>d.height){const e=this.cachedCanvases.getCanvas("maskExtension",n,r),a=e.context;a.drawImage(d,-u,-m),a.globalCompositeOperation="destination-atop",a.fillStyle=t,a.fillRect(0,0,n,r),a.globalCompositeOperation="source-over",d=e.canvas,u=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const a=new Path2D;a.rect(u,m,n,r),e.clip(a),e.globalCompositeOperation="destination-atop",e.fillStyle=t,e.fillRect(u,m,n,r),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),"Alpha"===a&&c?t.filter=this.filterFactory.addAlphaFilter(c):"Luminosity"===a&&(t.filter=this.filterFactory.addLuminosityFilter(c));const p=new Path2D;p.rect(i,l,n,r),t.clip(p),t.globalCompositeOperation="destination-in",t.drawImage(d,u,m,n,r,i,l,n,r),t.restore()}save(){this.inSMaskMode?(gce(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),gce(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,r,a,o){this.ctx.transform(e,t,n,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){const r=this.ctx,a=this.current;let o,c,i=a.x,l=a.y;const s=goe(r),h=0===s[0]&&0===s[3]||0===s[1]&&0===s[2],d=h?n.slice(0):null;for(let n=0,u=0,m=e.length;n<m;n++)switch(0|e[n]){case kae.rectangle:i=t[u++],l=t[u++];const e=t[u++],n=t[u++],m=i+e,p=l+n;r.moveTo(i,l),0===e||0===n?r.lineTo(m,p):(r.lineTo(m,l),r.lineTo(m,p),r.lineTo(i,p)),h||a.updateRectMinMax(s,[i,l,m,p]),r.closePath();break;case kae.moveTo:i=t[u++],l=t[u++],r.moveTo(i,l),h||a.updatePathMinMax(s,i,l);break;case kae.lineTo:i=t[u++],l=t[u++],r.lineTo(i,l),h||a.updatePathMinMax(s,i,l);break;case kae.curveTo:o=i,c=l,i=t[u+4],l=t[u+5],r.bezierCurveTo(t[u],t[u+1],t[u+2],t[u+3],i,l),a.updateCurvePathMinMax(s,o,c,t[u],t[u+1],t[u+2],t[u+3],i,l,d),u+=6;break;case kae.curveTo2:o=i,c=l,r.bezierCurveTo(i,l,t[u],t[u+1],t[u+2],t[u+3]),a.updateCurvePathMinMax(s,o,c,i,l,t[u],t[u+1],t[u+2],t[u+3],d),i=t[u+2],l=t[u+3],u+=4;break;case kae.curveTo3:o=i,c=l,i=t[u+2],l=t[u+3],r.bezierCurveTo(t[u],t[u+1],i,l,i,l),a.updateCurvePathMinMax(s,o,c,t[u],t[u+1],i,l,i,l,d),u+=4;break;case kae.closePath:r.closePath()}h&&a.updateScalingPathMinMax(s,d),a.setCurrentPoint(i,l)}closePath(){this.ctx.closePath()}stroke(e=!0){const t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof n&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,yoe(t),tce),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){const t=this.ctx,n=this.current.fillColor;let r=!1;this.current.patternFill&&(t.save(),t.fillStyle=n.getPattern(t,this,yoe(t),ece),r=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),r&&t.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Hce}eoClip(){this.pendingClip=Vce}beginText(){this.current.textMatrix=yae,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const e=this.pendingTextPaths,t=this.ctx;if(void 0===e)return void t.beginPath();const n=new Path2D,r=t.getTransform().invertSelf();for(const{transform:t,x:a,y:o,fontSize:c,path:i}of e)n.addPath(i,new DOMMatrix(t).preMultiplySelf(r).translate(a,o).scale(c,-c));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||Mae,0!==r.fontMatrix[0]&&0!==r.fontMatrix[3]||Aae("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=n.systemFontInfo?.css||`"${a}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const i=n.italic?"italic":"normal";let l=t;t<16?l=16:t>100&&(l=100),this.current.fontSizeScale=t/l,this.ctx.font=`${i} ${c} ${l}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,r,a,o){this.current.textMatrix=[e,t,n,r,a,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#dn(e,t,n){const r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}paintChar(e,t,n,r,a){const o=this.ctx,c=this.current,i=c.font,l=c.textRenderingMode,s=c.fontSize/c.fontSizeScale,h=3&l,d=!!(4&l),u=c.patternFill&&!i.missingFile,m=c.patternStroke&&!i.missingFile;let p;if((i.disableFontFace||d||u||m)&&(p=i.getPathGenerator(this.commonObjs,e)),i.disableFontFace||u||m){if(o.save(),o.translate(t,n),o.scale(s,-s),0===h||2===h)if(r){const e=o.getTransform();o.setTransform(...r),o.fill(this.#dn(p,e,r))}else o.fill(p);if(1===h||2===h)if(a){const e=o.getTransform();o.setTransform(...a),o.stroke(this.#dn(p,e,a))}else o.lineWidth/=s,o.stroke(p);o.restore()}else 0!==h&&2!==h||o.fillText(e,t,n),1!==h&&2!==h||o.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:goe(o),x:t,y:n,fontSize:s,path:p})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return Dae(this,"isFontSubpixelAAEnabled",n)}showText(e){const t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);const r=t.fontSize;if(0===r)return;const a=this.ctx,o=t.fontSizeScale,c=t.charSpacing,i=t.wordSpacing,l=t.fontDirection,s=t.textHScale*l,h=e.length,d=n.vertical,u=d?1:-1,m=n.defaultVMetrics,p=r*t.fontMatrix[0],v=0===t.textRenderingMode&&!n.disableFontFace&&!t.patternFill;let f,z;if(a.save(),a.transform(...t.textMatrix),a.translate(t.x,t.y+t.textRise),l>0?a.scale(s,-1):a.scale(s,1),t.patternFill){a.save();const e=t.fillColor.getPattern(a,this,yoe(a),ece);f=goe(a),a.restore(),a.fillStyle=e}if(t.patternStroke){a.save();const e=t.strokeColor.getPattern(a,this,yoe(a),tce);z=goe(a),a.restore(),a.strokeStyle=e}let g=t.lineWidth;const y=t.textMatrixScale;if(0===y||0===g){const e=3&t.textRenderingMode;1!==e&&2!==e||(g=this.getSinglePixelWidth())}else g/=y;if(1!==o&&(a.scale(o,o),g/=o),a.lineWidth=g,n.isInvalidPDFjsFont){const n=[];let r=0;for(const t of e)n.push(t.unicode),r+=t.width;return a.fillText(n.join(""),0,0),t.x+=r*p*s,a.restore(),void this.compose()}let M,E=0;for(M=0;M<h;++M){const t=e[M];if("number"==typeof t){E+=u*t*r/1e3;continue}let s=!1;const h=(t.isSpace?i:0)+c,g=t.fontChar,y=t.accent;let b,H,V=t.width;if(d){const e=t.vmetric||m,n=-(t.vmetric?e[1]:.5*V)*p,r=e[2]*p;V=e?-e[0]:V,b=n/o,H=(E+r)/o}else b=E/o,H=0;if(n.remeasure&&V>0){const e=1e3*a.measureText(g).width/r*o;if(V<e&&this.isFontSubpixelAAEnabled){const t=V/e;s=!0,a.save(),a.scale(t,1),b/=t}else V!==e&&(b+=(V-e)/2e3*r/o)}if(this.contentVisible&&(t.isInFont||n.missingFile))if(v&&!y)a.fillText(g,b,H);else if(this.paintChar(g,b,H,f,z),y){const e=b+r*y.offset.x/o,t=H-r*y.offset.y/o;this.paintChar(y.fontChar,e,t,f,z)}E+=d?V*p-h*l:V*p+h*l,s&&a.restore()}d?t.y-=E:t.x+=E*s,a.restore(),this.compose()}showType3Text(e){const t=this.ctx,n=this.current,r=n.font,a=n.fontSize,o=n.fontDirection,c=r.vertical?1:-1,i=n.charSpacing,l=n.wordSpacing,s=n.textHScale*o,h=n.fontMatrix||Mae,d=e.length;let u,m,p,v;if(3!==n.textRenderingMode&&0!==a){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(s,o),u=0;u<d;++u){if(m=e[u],"number"==typeof m){v=c*m*a/1e3,this.ctx.translate(v,0),n.x+=v*s;continue}const o=(m.isSpace?l:0)+i,d=r.charProcOperatorList[m.operatorListId];d?(this.contentVisible&&(this.processingType3=m,this.save(),t.scale(a,a),t.transform(...h),this.executeOperatorList(d),this.restore()),p=Qae.applyTransform([m.width,0],h)[0]*a+o,t.translate(p,0),n.x+=p*s):Aae(`Type3 character "${m.operatorListId}" is not available.`)}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,r,a,o){this.ctx.rect(n,r,a-n,o-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){const n=e[1],r=this.baseTransform||goe(this.ctx),a={createCanvasGraphics:e=>new Cce(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new hce(e,n,this.ctx,a,r)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=Qae.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=Qae.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(e){switch(e[0]){case"RadialAxial":return new oce(e);case"Mesh":return new lce(e);case"Dummy":return new sce}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,yoe(t),nce);const r=yoe(t);if(r){const{width:e,height:n}=t.canvas,[a,o,c,i]=Qae.getAxialAlignedBoundingBox([0,0,e,n],r);this.ctx.fillRect(a,o,c-a,i-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Rae("Should not call beginInlineImage")}beginImageData(){Rae("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=goe(this.ctx),t)){const e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(goe(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||Oae("TODO: Support non-isolated groups."),e.knockout&&Aae("Knockout groups not supported.");const n=goe(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=Qae.getAxialAlignedBoundingBox(e.bbox,goe(t));const a=[0,0,t.canvas.width,t.canvas.height];r=Qae.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),c=Math.floor(r[1]),i=Math.max(Math.ceil(r[2])-o,1),l=Math.max(Math.ceil(r[3])-c,1);this.current.startNewPathAndClipBox([0,0,i,l]);let s="groupAt"+this.groupLevel;e.smask&&(s+="_smask_"+this.smaskCounter++%2);const h=this.cachedCanvases.getCanvas(s,i,l),d=h.context;d.translate(-o,-c),d.transform(...n),e.smask?this.smaskStack.push({canvas:h.canvas,context:d,offsetX:o,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,c),t.save()),gce(t,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const e=goe(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);const n=Qae.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,r,a){if(this.#sn(),yce(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const r=t[2]-t[0],o=t[3]-t[1];if(a&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=r,t[3]=o;const[a,c]=Qae.singularValueDecompose2dScale(goe(this.ctx)),{viewportScale:i}=this,l=Math.ceil(r*this.outputScaleX*i),s=Math.ceil(o*this.outputScaleY*i);this.annotationCanvas=this.canvasFactory.create(l,s);const{canvas:h,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,h),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(a,0,0,-c,0,o*c),yce(this.ctx)}else yce(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],r,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new vce(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#hn(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;(e=this.getObject(e.data,e)).count=t;const n=this.ctx,r=this.processingType3;if(r&&(void 0===r.compiled&&(r.compiled=function(e){const{width:t,height:n}=e;if(t>1e3||n>1e3)return null;const r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1;let o,c,i,l=new Uint8Array(a*(n+1));const s=t+7&-8;let h=new Uint8Array(s*n),d=0;for(const t of e.data){let e=128;for(;e>0;)h[d++]=t&e?0:255,e>>=1}let u=0;for(d=0,0!==h[d]&&(l[0]=1,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(l[c]=h[d]?2:1,++u),d++;for(0!==h[d]&&(l[c]=2,++u),o=1;o<n;o++){d=o*s,i=o*a,h[d-s]!==h[d]&&(l[i]=h[d]?1:8,++u);let e=(h[d]?4:0)+(h[d-s]?8:0);for(c=1;c<t;c++)e=(e>>2)+(h[d+1]?4:0)+(h[d-s+1]?8:0),r[e]&&(l[i+c]=r[e],++u),d++;if(h[d-s]!==h[d]&&(l[i+c]=h[d]?2:4,++u),u>1e3)return null}for(d=s*(n-1),i=o*a,0!==h[d]&&(l[i]=8,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(l[i+c]=h[d]?4:8,++u),d++;if(0!==h[d]&&(l[i+c]=4,++u),u>1e3)return null;const m=new Int32Array([0,a,-1,0,-a,0,0,0,1]),p=new Path2D;for(o=0;u&&o<=n;o++){let e=o*a;const n=e+t;for(;e<n&&!l[e];)e++;if(e===n)continue;p.moveTo(e%a,o);const r=e;let c=l[e];do{const t=m[c];do{e+=t}while(!l[e]);const n=l[e];5!==n&&10!==n?(c=n,l[e]=0):(c=n&51*c>>4,l[e]&=c>>2|c<<2),p.lineTo(e%a,e/a|0),l[e]||--u}while(r!==e);--o}return h=null,l=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(p),e.beginPath(),e.restore()}}(e)),r.compiled))return void r.compiled(n);const a=this._createMaskCanvas(e),o=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,a.offsetX,a.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,r=0,a,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const c=this.ctx;c.save();const i=goe(c);c.transform(t,n,r,a,0,0);const l=this._createMaskCanvas(e);c.setTransform(1,0,0,1,l.offsetX-i[4],l.offsetY-i[5]);for(let e=0,s=o.length;e<s;e+=2){const s=Qae.transform(i,[t,n,r,a,o[e],o[e+1]]),[h,d]=Qae.applyTransform([0,0],s);c.drawImage(l.canvas,h,d)}c.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const t=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(const a of e){const{data:e,width:o,height:c,transform:i}=a,l=this.cachedCanvases.getCanvas("maskCanvas",o,c),s=l.context;s.save(),zce(s,this.getObject(e,a)),s.globalCompositeOperation="source-in",s.fillStyle=r?n.getPattern(s,this,yoe(t),ece):n,s.fillRect(0,0,o,c),s.restore(),t.save(),t.transform(...i),t.scale(1,-1),pce(t,l.canvas,0,0,o,c,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const t=this.getObject(e);t?this.paintInlineImageXObject(t):Aae("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,n,r){if(!this.contentVisible)return;const a=this.getObject(e);if(!a)return void Aae("Dependent image isn't ready yet");const o=a.width,c=a.height,i=[];for(let e=0,a=r.length;e<a;e+=2)i.push({transform:[t,0,0,n,r[e],r[e+1]],x:0,y:0,w:o,h:c});this.paintInlineImageXObjectGroup(a,i)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;const{bitmap:t,width:n,height:r}=e,a=this.cachedCanvases.getCanvas("inlineImage",n,r),o=a.context;return o.filter=this.current.transferMaps,o.drawImage(t,0,0),o.filter="none",a.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const t=e.width,n=e.height,r=this.ctx;if(this.save(),!gae){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}let a;if(r.scale(1/t,-1/n),e.bitmap)a=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)a=e;else{const r=this.cachedCanvases.getCanvas("inlineImage",t,n).context;fce(r,e),a=this.applyTransferMapsToCanvas(r)}const o=this._scaleImage(a,yoe(r));r.imageSmoothingEnabled=Mce(goe(r),e.interpolate),pce(r,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;const n=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const t=e.width,n=e.height,a=this.cachedCanvases.getCanvas("inlineImage",t,n).context;fce(a,e),r=this.applyTransferMapsToCanvas(a)}for(const e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),pce(n,r,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){const t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const n=this.ctx;this.pendingClip&&(t||(this.pendingClip===Vce?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=goe(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:n,c:r,d:a}=this.ctx.getTransform();let o,c;if(0===n&&0===r){const n=Math.abs(t),r=Math.abs(a);if(n===r)if(0===e)o=c=1/n;else{const t=n*e;o=c=t<1?1/t:1}else if(0===e)o=1/n,c=1/r;else{const t=n*e,a=r*e;o=t<1?1/t:1,c=a<1?1/a:1}}else{const i=Math.abs(t*a-n*r),l=Math.hypot(t,n),s=Math.hypot(r,a);if(0===e)o=s/i,c=l/i;else{const t=e*i;o=s>t?s/t:1,c=l>t?l/t:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=c}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:n}=this.current,[r,a]=this.getScaleForStroking();if(t.lineWidth=n||1,1===r&&1===a)return void t.stroke();const o=t.getLineDash();if(e&&t.save(),t.scale(r,a),o.length>0){const e=Math.max(r,a);t.setLineDash(o.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(const e in kae)void 0!==Cce.prototype[e]&&(Cce.prototype[kae[e]]=Cce.prototype[e]);class Lce{static#un=null;static#mn="";static get workerPort(){return this.#un}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");this.#un=e}static get workerSrc(){return this.#mn}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");this.#mn=e}}class wce{#pn;#vn;constructor({parsedData:e,rawData:t}){this.#pn=e,this.#vn=t}getRaw(){return this.#vn}get(e){return this.#pn.get(e)??null}getAll(){return Yae(this.#pn)}has(e){return this.#pn.has(e)}}const kce=Symbol("INTERNAL");class xce{#fn=!1;#zn=!1;#gn=!1;#yn=!0;constructor(e,{name:t,intent:n,usage:r,rbGroups:a}){this.#fn=!!(2&e),this.#zn=!!(4&e),this.name=t,this.intent=n,this.usage=r,this.rbGroups=a}get visible(){if(this.#gn)return this.#yn;if(!this.#yn)return!1;const{print:e,view:t}=this.usage;return this.#fn?"OFF"!==t?.viewState:!this.#zn||"OFF"!==e?.printState}_setVisible(e,t,n=!1){e!==kce&&Rae("Internal method `_setVisible` called."),this.#gn=n,this.#yn=t}}class Sce{#Mn=null;#En=new Map;#bn=null;#Hn=null;constructor(e,t=2){if(this.renderingIntent=t,this.name=null,this.creator=null,null!==e){this.name=e.name,this.creator=e.creator,this.#Hn=e.order;for(const n of e.groups)this.#En.set(n.id,new xce(t,n));if("OFF"===e.baseState)for(const e of this.#En.values())e._setVisible(kce,!1);for(const t of e.on)this.#En.get(t)._setVisible(kce,!0);for(const t of e.off)this.#En.get(t)._setVisible(kce,!1);this.#bn=this.getHash()}}#Vn(e){const t=e.length;if(t<2)return!0;const n=e[0];for(let r=1;r<t;r++){const t=e[r];let a;if(Array.isArray(t))a=this.#Vn(t);else{if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;a=this.#En.get(t).visible}switch(n){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===n}isVisible(e){if(0===this.#En.size)return!0;if(!e)return Oae("Optional content group not defined."),!0;if("OCG"===e.type)return this.#En.has(e.id)?this.#En.get(e.id).visible:(Aae(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return this.#Vn(e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!1}return!0}return Aae(`Unknown optional content policy ${e.policy}.`),!0}return Aae(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){const r=this.#En.get(e);if(r){if(n&&t&&r.rbGroups.length)for(const t of r.rbGroups)for(const n of t)n!==e&&this.#En.get(n)?._setVisible(kce,!1,!0);r._setVisible(kce,!!t,!0),this.#Mn=null}else Aae(`Optional content group not found: ${e}`)}setOCGState({state:e,preserveRB:t}){let n;for(const r of e){switch(r){case"ON":case"OFF":case"Toggle":n=r;continue}const e=this.#En.get(r);if(e)switch(n){case"ON":this.setVisibility(r,!0,t);break;case"OFF":this.setVisibility(r,!1,t);break;case"Toggle":this.setVisibility(r,!e.visible,t)}}this.#Mn=null}get hasInitialVisibility(){return null===this.#bn||this.getHash()===this.#bn}getOrder(){return this.#En.size?this.#Hn?this.#Hn.slice():[...this.#En.keys()]:null}getGroups(){return this.#En.size>0?Yae(this.#En):null}getGroup(e){return this.#En.get(e)||null}getHash(){if(null!==this.#Mn)return this.#Mn;const e=new Poe;for(const[t,n]of this.#En)e.update(`${t}:${n.visible}`);return this.#Mn=e.hexdigest()}}class Tce{constructor(e,{disableRange:t=!1,disableStream:n=!1}){Nae(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:a,progressiveDone:o,contentDispositionFilename:c}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=c,a?.length>0){const e=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),e.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),e.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),e.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Nae(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){void 0===e.total?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){Nae(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new Oce(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Ace(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}}class Oce{constructor(e,t,n=!1,r=null){this._stream=e,this._done=n||!1,this._filename=loe(r)?r:null,this._queuedChunks=t||[],this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Ace{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Rce(e,t){const n=new Headers;if(!e||!t||"object"!=typeof t)return n;for(const e in t){const r=t[e];void 0!==r&&n.append(e,r)}return n}function Nce(e){try{return new URL(e).origin}catch{}return null}function _ce({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){const a={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(e.get("Content-Length"),10);return Number.isInteger(o)?(a.suggestedLength=o,o<=2*n||r||!t||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a):a}function Dce(e){const t=e.get("Content-Disposition");if(t){let e=function(e){let t=!0,n=r("filename\\*","i").exec(e);if(n){n=n[1];let e=c(n);return e=unescape(e),e=i(e),e=l(e),o(e)}if(n=function(e){const t=[];let n;const a=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=a.exec(e));){let[,e,r,a]=n;if(e=parseInt(e,10),e in t){if(0===e)break}else t[e]=[r,a]}const o=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=c(r),n&&(r=unescape(r),0===e&&(r=i(r))),o.push(r)}return o.join("")}(e),n)return o(l(n));if(n=r("filename","i").exec(e),n){n=n[1];let e=c(n);return e=l(e),o(e)}function r(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function a(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const r=new TextDecoder(e,{fatal:!0}),a=Gae(n);n=r.decode(a),t=!1}catch{}}return n}function o(e){return t&&/[\x80-\xff]/.test(e)&&(e=a("utf-8",e),t&&(e=a("iso-8859-1",e))),e}function c(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const n=t[e].indexOf('"');-1!==n&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function i(e){const t=e.indexOf("'");return-1===t?e:a(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function l(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(e,t,n,r){if("q"===n||"Q"===n)return a(t,r=(r=r.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{r=atob(r)}catch{}return a(t,r)}))}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(loe(e))return e}return null}function Pce(e,t){return 404===e||0===e&&t.startsWith("file:")?new jae('Missing PDF "'+t+'".'):new Uae(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function Fce(e){return 200===e||206===e}function Ice(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Bce(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(Aae(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class jce{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=Rce(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Nae(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Uce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Wce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class Uce{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;const n=new Headers(e.headers),r=t.url;fetch(r,Ice(n,this._withCredentials,this._abortController)).then((t=>{if(e._responseOrigin=Nce(t.url),!Fce(t.status))throw Pce(t.status,r);this._reader=t.body.getReader(),this._headersCapability.resolve();const n=t.headers,{allowRangeRequests:a,suggestedLength:o}=_ce({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Dce(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $ae("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Bce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class Wce{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;const r=e.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const a=new Headers(e.headers);a.append("Range",`bytes=${t}-${n-1}`);const o=r.url;fetch(o,Ice(a,this._withCredentials,this._abortController)).then((t=>{const n=Nce(t.url);if(n!==e._responseOrigin)throw new Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!Fce(t.status))throw Pce(t.status,o);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Bce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class $ce{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Rce(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const t=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),r.expectedStatus=206):r.expectedStatus=200,t.responseType="arraybuffer",Nae(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=e.onHeadersReceived,r.onDone=e.onDone,r.onError=e.onError,r.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){const n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){const n=this.pendingRequests[e];if(!n)return;const r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==r.readyState)return;if(!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===r.status&&this.isHttp)return void n.onError(r.status);const a=r.status||200;if((200!==a||206!==n.expectedStatus)&&a!==n.expectedStatus)return void n.onError(r.status);const o=function(e){const t=e.response;return"string"!=typeof t?t:Gae(t).buffer}(r);if(206===a){const e=r.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:o}):(Aae('Missing or invalid "Content-Range" header.'),n.onError(0))}else o?n.onDone({begin:0,chunk:o}):n.onError(r.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class qce{constructor(e){this._source=e,this._manager=new $ce(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return Nae(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Gce(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const n=new Yce(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class Gce{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=Nce(t.responseURL);const n=t.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((e=>{const[t,...n]=e.split(": ");return[t,n.join(": ")]})):[]),{allowRangeRequests:a,suggestedLength:o}=_ce({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=Dce(r),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=Pce(e,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Yce{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const e=Nce(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=Pce(e,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Kce=/^[a-z][a-z0-9\-+.]+:/i;class Xce{constructor(e){this.source=e,this.url=function(e){if(Kce.test(e))return new URL(e);const t=xt.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}(e.url),Nae("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Nae(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Qce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Jce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class Qce{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=xt.getBuiltinModule("fs");n.promises.lstat(this._url).then((e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()}),(e=>{"ENOENT"===e.code&&(e=new jae(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new $ae("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Jce{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=e.source;this._isStreamingSupported=!r.disableStream;const a=xt.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Zce=30;class eie{#Cn=Promise.withResolvers();#me=null;#Ln=!1;#wn=!!globalThis.FontInspector?.enabled;#kn=null;#xn=null;#Sn=0;#Tn=0;#On=null;#An=null;#Rn=0;#Nn=0;#_n=Object.create(null);#Dn=[];#Pn=null;#Fn=[];#In=new WeakMap;#Bn=null;static#jn=new Map;static#Un=new Map;static#Wn=new WeakMap;static#$n=null;static#qn=new Set;constructor({textContentSource:e,container:t,viewport:n}){if(e instanceof ReadableStream)this.#Pn=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Pn=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#me=this.#An=t,this.#Nn=n.scale*(globalThis.devicePixelRatio||1),this.#Rn=n.rotation,this.#xn={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:a,pageX:o,pageY:c}=n.rawDims;this.#Bn=[1,0,0,-1,-o,c+a],this.#Tn=r,this.#Sn=a,eie.#Gn(),Moe(t,n),this.#Cn.promise.finally((()=>{eie.#qn.delete(this),this.#xn=null,this.#_n=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=Kae.platform;return Dae(this,"fontFamilyMap",new Map([["sans-serif",(e&&t?"Calibri, ":"")+"sans-serif"],["monospace",(e&&t?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#On.read().then((({value:t,done:n})=>{n?this.#Cn.resolve():(this.#kn??=t.lang,Object.assign(this.#_n,t.styles),this.#Yn(t.items),e())}),this.#Cn.reject)};return this.#On=this.#Pn.getReader(),eie.#qn.add(this),e(),this.#Cn.promise}update({viewport:e,onBefore:t=null}){const n=e.scale*(globalThis.devicePixelRatio||1),r=e.rotation;if(r!==this.#Rn&&(t?.(),this.#Rn=r,Moe(this.#An,{rotation:r})),n!==this.#Nn){t?.(),this.#Nn=n;const e={div:null,properties:null,ctx:eie.#Kn(this.#kn)};for(const t of this.#Fn)e.properties=this.#In.get(t),e.div=t,this.#Xn(e)}}cancel(){const e=new $ae("TextLayer task cancelled.");this.#On?.cancel(e).catch((()=>{})),this.#On=null,this.#Cn.reject(e)}get textDivs(){return this.#Fn}get textContentItemsStr(){return this.#Dn}#Yn(e){if(this.#Ln)return;this.#xn.ctx??=eie.#Kn(this.#kn);const t=this.#Fn,n=this.#Dn;for(const r of e){if(t.length>1e5)return Aae("Ignoring additional textDivs for performance reasons."),void(this.#Ln=!0);if(void 0!==r.str)n.push(r.str),this.#Qn(r);else if("beginMarkedContentProps"===r.type||"beginMarkedContent"===r.type){const e=this.#me;this.#me=document.createElement("span"),this.#me.classList.add("markedContent"),null!==r.id&&this.#me.setAttribute("id",`${r.id}`),e.append(this.#me)}else"endMarkedContent"===r.type&&(this.#me=this.#me.parentNode)}}#Qn(e){const t=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#Fn.push(t);const r=Qae.transform(this.#Bn,e.transform);let a=Math.atan2(r[1],r[0]);const o=this.#_n[e.fontName];o.vertical&&(a+=Math.PI/2);let c=this.#wn&&o.fontSubstitution||o.fontFamily;c=eie.fontFamilyMap.get(c)||c;const i=Math.hypot(r[2],r[3]),l=i*eie.#Jn(c,this.#kn);let s,h;0===a?(s=r[4],h=r[5]-l):(s=r[4]+l*Math.sin(a),h=r[5]-l*Math.cos(a));const d="calc(var(--scale-factor)*",u=t.style;this.#me===this.#An?(u.left=`${(100*s/this.#Tn).toFixed(2)}%`,u.top=`${(100*h/this.#Sn).toFixed(2)}%`):(u.left=`${d}${s.toFixed(2)}px)`,u.top=`${d}${h.toFixed(2)}px)`),u.fontSize=`${d}${(eie.#$n*i).toFixed(2)}px)`,u.fontFamily=c,n.fontSize=i,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#wn&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),0!==a&&(n.angle=a*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(m=!0)}if(m&&(n.canvasWidth=o.vertical?e.height:e.width),this.#In.set(t,n),this.#xn.div=t,this.#xn.properties=n,this.#Xn(this.#xn),n.hasText&&this.#me.append(t),n.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation"),this.#me.append(e)}}#Xn(e){const{div:t,properties:n,ctx:r}=e,{style:a}=t;let o="";if(eie.#$n>1&&(o=`scale(${1/eie.#$n})`),0!==n.canvasWidth&&n.hasText){const{fontFamily:e}=a,{canvasWidth:c,fontSize:i}=n;eie.#Zn(r,i*this.#Nn,e);const{width:l}=r.measureText(t.textContent);l>0&&(o=`scaleX(${c*this.#Nn/l}) ${o}`)}0!==n.angle&&(o=`rotate(${n.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#qn.size>0)){this.#jn.clear();for(const{canvas:e}of this.#Un.values())e.remove();this.#Un.clear()}}static#Kn(e=null){let t=this.#Un.get(e||="");if(!t){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),t=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Un.set(e,t),this.#Wn.set(t,{size:0,family:""})}return t}static#Zn(e,t,n){const r=this.#Wn.get(e);t===r.size&&n===r.family||(e.font=`${t}px ${n}`,r.size=t,r.family=n)}static#Gn(){if(null!==this.#$n)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#$n=e.getBoundingClientRect().height,e.remove()}static#Jn(e,t){const n=this.#jn.get(e);if(n)return n;const r=this.#Kn(t);r.canvas.width=r.canvas.height=Zce,this.#Zn(r,Zce,e);const a=r.measureText("");let o=a.fontBoundingBoxAscent,c=Math.abs(a.fontBoundingBoxDescent);if(o){const t=o/(o+c);return this.#jn.set(e,t),r.canvas.width=r.canvas.height=0,t}r.strokeStyle="red",r.clearRect(0,0,Zce,Zce),r.strokeText("g",0,0);let i=r.getImageData(0,0,Zce,Zce).data;c=0;for(let e=i.length-1-3;e>=0;e-=4)if(i[e]>0){c=Math.ceil(e/4/Zce);break}r.clearRect(0,0,Zce,Zce),r.strokeText("A",0,Zce),i=r.getImageData(0,0,Zce,Zce).data,o=0;for(let e=0,t=i.length;e<t;e+=4)if(i[e]>0){o=Zce-Math.floor(e/4/Zce);break}r.canvas.width=r.canvas.height=0;const l=o?o/(o+c):.8;return this.#jn.set(e,l),l}}class tie{static textContent(e){const t=[],n={items:t,styles:Object.create(null)};return function e(n){if(!n)return;let r=null;const a=n.name;if("#text"===a)r=n.value;else{if(!tie.shouldBuildText(a))return;n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value)}if(null!==r&&t.push({str:r}),n.children)for(const t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}const nie=65536,rie=gae?class extends Goe{_createCanvas(e,t){return xt.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}:class extends Goe{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){const n=this._document.createElement("canvas");return n.width=e,n.height=t,n}},aie=gae?class extends Yoe{async _fetch(e){return Zoe(e)}}:Koe,oie=gae?class extends Xoe{}:class extends Xoe{#er;#tr;#nr;#rr;#ar;#or;#y=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#rr=e,this.#ar=t}get#E(){return this.#tr||=new Map}get#cr(){return this.#or||=new Map}get#ir(){if(!this.#nr){const e=this.#ar.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const n=this.#ar.createElementNS(noe,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#nr=this.#ar.createElementNS(noe,"defs"),e.append(n),n.append(this.#nr),this.#ar.body.append(e)}return this.#nr}#lr(e){if(1===e.length){const t=e[0],n=new Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;const r=n.join(",");return[r,r,r]}const[t,n,r]=e,a=new Array(256),o=new Array(256),c=new Array(256);for(let e=0;e<256;e++)a[e]=t[e]/255,o[e]=n[e]/255,c[e]=r[e]/255;return[a.join(","),o.join(","),c.join(",")]}#sr(e){if(void 0===this.#er){this.#er="";const e=this.#ar.URL;e!==this.#ar.baseURI&&(ioe(e)?Aae('#createUrl: ignore "data:"-URL for performance reasons.'):this.#er=e.split("#",1)[0])}return`url(${this.#er}#${e})`}addFilter(e){if(!e)return"none";let t=this.#E.get(e);if(t)return t;const[n,r,a]=this.#lr(e),o=1===e.length?n:`${n}${r}${a}`;if(t=this.#E.get(o),t)return this.#E.set(e,t),t;const c=`g_${this.#rr}_transfer_map_${this.#y++}`,i=this.#sr(c);this.#E.set(e,i),this.#E.set(o,i);const l=this.#hr(c);return this.#dr(n,r,a,l),i}addHCMFilter(e,t){const n=`${e}-${t}`,r="base";let a=this.#cr.get(r);if(a?.key===n)return a.url;if(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#cr.set(r,a)),!e||!t)return a.url;const o=this.#ur(e);e=Qae.makeHexColor(...o);const c=this.#ur(t);if(t=Qae.makeHexColor(...c),this.#ir.style.color="","#000000"===e&&"#ffffff"===t||e===t)return a.url;const i=new Array(256);for(let e=0;e<=255;e++){const t=e/255;i[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const l=i.join(","),s=`g_${this.#rr}_hcm_filter`,h=a.filter=this.#hr(s);this.#dr(l,l,l,h),this.#mr(h);const d=(e,t)=>{const n=o[e]/255,r=c[e]/255,a=new Array(t+1);for(let e=0;e<=t;e++)a[e]=n+e/t*(r-n);return a.join(",")};return this.#dr(d(0,5),d(1,5),d(2,5),h),a.url=this.#sr(s),a.url}addAlphaFilter(e){let t=this.#E.get(e);if(t)return t;const[n]=this.#lr([e]),r=`alpha_${n}`;if(t=this.#E.get(r),t)return this.#E.set(e,t),t;const a=`g_${this.#rr}_alpha_map_${this.#y++}`,o=this.#sr(a);this.#E.set(e,o),this.#E.set(r,o);const c=this.#hr(a);return this.#pr(n,c),o}addLuminosityFilter(e){let t,n,r=this.#E.get(e||"luminosity");if(r)return r;if(e?([t]=this.#lr([e]),n=`luminosity_${t}`):n="luminosity",r=this.#E.get(n),r)return this.#E.set(e,r),r;const a=`g_${this.#rr}_luminosity_map_${this.#y++}`,o=this.#sr(a);this.#E.set(e,o),this.#E.set(n,o);const c=this.#hr(a);return this.#vr(c),e&&this.#pr(t,c),o}addHighlightHCMFilter(e,t,n,r,a){const o=`${t}-${n}-${r}-${a}`;let c=this.#cr.get(e);if(c?.key===o)return c.url;if(c?(c.filter?.remove(),c.key=o,c.url="none",c.filter=null):(c={key:o,url:"none",filter:null},this.#cr.set(e,c)),!t||!n)return c.url;const[i,l]=[t,n].map(this.#ur.bind(this));let s=Math.round(.2126*i[0]+.7152*i[1]+.0722*i[2]),h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[r,a].map(this.#ur.bind(this));h<s&&([s,h,d,u]=[h,s,u,d]),this.#ir.style.color="";const m=(e,t,n)=>{const r=new Array(256),a=(h-s)/n,o=e/255,c=(t-e)/(255*n);let i=0;for(let e=0;e<=n;e++){const t=Math.round(s+e*a),n=o+e*c;for(let e=i;e<=t;e++)r[e]=n;i=t+1}for(let e=i;e<256;e++)r[e]=r[i-1];return r.join(",")},p=`g_${this.#rr}_hcm_${e}_filter`,v=c.filter=this.#hr(p);return this.#mr(v),this.#dr(m(d[0],u[0],5),m(d[1],u[1],5),m(d[2],u[2],5),v),c.url=this.#sr(p),c.url}destroy(e=!1){e&&this.#or?.size||(this.#nr?.parentNode.parentNode.remove(),this.#nr=null,this.#tr?.clear(),this.#tr=null,this.#or?.clear(),this.#or=null,this.#y=0)}#vr(e){const t=this.#ar.createElementNS(noe,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(t)}#mr(e){const t=this.#ar.createElementNS(noe,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#hr(e){const t=this.#ar.createElementNS(noe,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#ir.append(t),t}#fr(e,t,n){const r=this.#ar.createElementNS(noe,t);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)}#dr(e,t,n,r){const a=this.#ar.createElementNS(noe,"feComponentTransfer");r.append(a),this.#fr(a,"feFuncR",e),this.#fr(a,"feFuncG",t),this.#fr(a,"feFuncB",n)}#pr(e,t){const n=this.#ar.createElementNS(noe,"feComponentTransfer");t.append(n),this.#fr(n,"feFuncA",e)}#ur(e){return this.#ir.style.color=e,zoe(getComputedStyle(this.#ir).getPropertyValue("color"))}},cie=gae?class extends Qoe{async _fetch(e){return Zoe(e)}}:Joe;function iie(e={}){"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new sie,{docId:n}=t,r=e.url?function(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(gae&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,a=e.data?function(e){if(gae&&void 0!==wL&&e instanceof wL)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return Gae(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,o=e.httpHeaders||null,c=!0===e.withCredentials,i=e.password??null,l=e.range instanceof hie?e.range:null,s=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:nie;let h=e.worker instanceof pie?e.worker:null;const d=e.verbosity,u="string"!=typeof e.docBaseUrl||ioe(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,p=!1!==e.cMapPacked,v=e.CMapReaderFactory||aie,f="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,z=e.StandardFontDataFactory||cie,g=!0!==e.stopAtErrors,y=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,M=!1!==e.isEvalSupported,E="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!gae,b="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!gae&&(Kae.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,V="boolean"==typeof e.disableFontFace?e.disableFontFace:gae,C=!0===e.fontExtraProperties,L=!0===e.enableXfa,w=e.ownerDocument||globalThis.document,k=!0===e.disableRange,x=!0===e.disableStream,S=!0===e.disableAutoFetch,T=!0===e.pdfBug,O=e.CanvasFactory||rie,A=e.FilterFactory||oie,R=!0===e.enableHWA,N=l?l.length:e.length??NaN,_="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!gae&&!V,D="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===Koe&&z===Joe&&m&&f&&uoe(m,document.baseURI)&&uoe(f,document.baseURI);!function(e){Number.isInteger(e)&&(Sae=e)}(d);const P={canvasFactory:new O({ownerDocument:w,enableHWA:R}),filterFactory:new A({docId:n,ownerDocument:w}),cMapReaderFactory:D?null:new v({baseUrl:m,isCompressed:p}),standardFontDataFactory:D?null:new z({baseUrl:f})};if(!h){const e={verbosity:d,port:Lce.workerPort};h=e.port?pie.fromPort(e):new pie(e),t._worker=h}const F={docId:n,apiVersion:"4.10.38",data:a,password:i,disableAutoFetch:S,rangeChunkSize:s,length:N,docBaseUrl:u,enableXfa:L,evaluatorOptions:{maxImageSize:y,disableFontFace:V,ignoreErrors:g,isEvalSupported:M,isOffscreenCanvasSupported:E,isImageDecoderSupported:b,canvasMaxAreaInBytes:H,fontExtraProperties:C,useSystemFonts:_,cMapUrl:D?m:null,standardFontDataUrl:D?f:null}},I={disableFontFace:V,fontExtraProperties:C,ownerDocument:w,pdfBug:T,styleElement:null,loadingParams:{disableAutoFetch:S,enableXfa:L}};return h.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const e=h.messageHandler.sendWithPromise("GetDocRequest",F,a?[a.buffer]:null);let i;if(l)i=new Tce(l,{disableRange:k,disableStream:x});else if(!a){if(!r)throw new Error("getDocument - no `url` parameter provided.");let e;if(gae)if(uoe(r)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=jce}else e=Xce;else e=uoe(r)?jce:qce;i=new e({url:r,length:N,httpHeaders:o,withCredentials:c,rangeChunkSize:s,disableRange:k,disableStream:x})}return e.then((e=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const r=new qoe(n,e,h.port),a=new vie(r,t,i,I,P);t._transport=a,r.send("Ready",null)}))})).catch(t._capability.reject),t}function lie(e){return"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}class sie{static#rr=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+sie.#rr++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}}class hie{constructor(e,t,n=!1,r=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(const n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(const t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Rae("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class die{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Dae(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class uie{#zr=null;#gr=!1;constructor(e,t,n,r=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=r?new doe:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new zie,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}={}){return new ooe({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:a})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Dae(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:r=bae.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:c=null,annotationCanvasMap:i=null,pageColors:l=null,printAnnotationStorage:s=null,isEditing:h=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(n,r,s,h),{renderingIntent:u,cacheKey:m}=d;this.#gr=!1,this.#yr(),c||=this._transport.getOptionalContentConfig(u);let p=this._intentStates.get(m);p||(p=Object.create(null),this._intentStates.set(m,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const v=!!(4&u);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const f=e=>{p.renderTasks.delete(z),(this._maybeCleanupAfterRender||v)&&(this.#gr=!0),this.#Mr(!v),e?(z.capability.reject(e),this._abortOperatorList({intentState:p,reason:e instanceof Error?e:new Error(e)})):z.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},z=new yie({callback:f,params:{canvasContext:e,viewport:t,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:i,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:l});(p.renderTasks||=new Set).add(z);const g=z.task;return Promise.all([p.displayReadyCapability.promise,c]).then((([e,t])=>{if(this.destroyed)f();else{if(this._stats?.time("Rendering"),!(t.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");z.initializeGraphics({transparency:e,optionalContentConfig:t}),z.operatorListChanged()}})).catch(f),g}getOperatorList({intent:e="display",annotationMode:t=bae.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){const a=this._transport.getRenderingIntent(e,t,n,r,!0);let o,c=this._intentStates.get(a.cacheKey);return c||(c=Object.create(null),this._intentStates.set(a.cacheKey,c)),c.opListReadCapability||(o=Object.create(null),o.operatorListChanged=function(){c.operatorList.lastChunk&&(c.opListReadCapability.resolve(c.operatorList),c.renderTasks.delete(o))},c.opListReadCapability=Promise.withResolvers(),(c.renderTasks||=new Set).add(o),c.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(a)),c.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>tie.textContent(e)));const t=this.streamTextContent(e);return new Promise((function(e,n){const r=t.getReader(),a={items:[],styles:Object.create(null),lang:null};!function t(){r.read().then((function({value:n,done:r}){r?e(a):(a.lang??=n.lang,Object.assign(a.styles,n.styles),a.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#gr=!1,this.#yr(),Promise.all(e)}cleanup(e=!1){this.#gr=!0;const t=this.#Mr(!1);return e&&t&&(this._stats&&=new doe),t}#Mr(e=!1){if(this.#yr(),!this.#gr||this.destroyed)return!1;if(e)return this.#zr=setTimeout((()=>{this.#zr=null,this.#Mr(!1)}),5e3),!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#gr=!1,!0}#yr(){this.#zr&&(clearTimeout(this.#zr),this.#zr=null)}_startRenderPage(e,t){const n=this._intentStates.get(t);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#Mr(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){const{map:a,transfer:o}=n,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:a,modifiedIds:r},o).getReader(),i=this._intentStates.get(t);i.streamReader=c;const l=()=>{c.read().then((({value:e,done:t})=>{t?i.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,i),l())}),(e=>{if(i.streamReader=null,!this._transport.destroyed){if(i.operatorList){i.operatorList.lastChunk=!0;for(const e of i.renderTasks)e.operatorListChanged();this.#Mr(!0)}if(i.displayReadyCapability)i.displayReadyCapability.reject(e);else{if(!i.opListReadCapability)throw e;i.opListReadCapability.reject(e)}}}))};l()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof coe){let n=100;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new $ae(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(const[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}class mie{#Er=new Map;#br=Promise.resolve();postMessage(e,t){const n={data:structuredClone(e,t?{transfer:t}:null)};this.#br.then((()=>{for(const[e]of this.#Er)e.call(this,n)}))}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){const{signal:a}=n;if(a.aborted)return void Aae("LoopbackPort - cannot use an `aborted` signal.");const o=()=>this.removeEventListener(e,t);r=()=>a.removeEventListener("abort",o),a.addEventListener("abort",o)}this.#Er.set(t,r)}removeEventListener(e,t){const n=this.#Er.get(t);n?.(),this.#Er.delete(t)}terminate(){for(const[,e]of this.#Er)e?.();this.#Er.clear()}}class pie{static#Hr=0;static#Vr=!1;static#Cr;static{gae&&(this.#Vr=!0,Lce.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch{return!1}const r=new URL(t,n);return n.origin===r.origin},this._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:n=Tae()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(pie.#Cr?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");return(pie.#Cr||=new WeakMap).set(t,this),void this._initializeFromPort(t)}this._initialize()}get promise(){return this._readyCapability.promise}#Lr(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new qoe("main","worker",e),this._messageHandler.on("ready",(function(){})),this.#Lr()}_initialize(){if(pie.#Vr||pie.#wr)return void this._setupFakeWorker();let{workerSrc:e}=pie;try{pie._isSameOrigin(window.location.href,e)||(e=pie._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),n=new qoe("main","worker",t),r=()=>{a.abort(),n.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;t.addEventListener("error",(()=>{this._webWorker||r()}),{signal:a.signal}),n.on("test",(e=>{a.abort(),!this.destroyed&&e?(this._messageHandler=n,this._port=t,this._webWorker=t,this.#Lr()):r()})),n.on("ready",(e=>{if(a.abort(),this.destroyed)r();else try{o()}catch{this._setupFakeWorker()}}));const o=()=>{const e=new Uint8Array;n.send("test",e,[e.buffer])};return void o()}catch{Oae("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){pie.#Vr||(Aae("Setting up fake worker."),pie.#Vr=!0),pie._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const t=new mie;this._port=t;const n="fake"+pie.#Hr++,r=new qoe(n+"_worker",n,t);e.setup(r,t),this._messageHandler=new qoe(n,n+"_worker",t),this.#Lr()})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,pie.#Cr?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const t=this.#Cr?.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new pie(e)}static get workerSrc(){if(Lce.workerSrc)return Lce.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#wr(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Dae(this,"_setupFakeWorkerGlobal",(async()=>this.#wr?this.#wr:(await import(this.workerSrc)).WorkerMessageHandler)())}}class vie{#kr=new Map;#xr=new Map;#Sr=new Map;#Tr=new Map;#Or=null;constructor(e,t,n,r,a){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new zie,this.fontLoader=new joe({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ar(e,t=null){const n=this.#kr.get(e);if(n)return n;const r=this.messageHandler.sendWithPromise(e,t);return this.#kr.set(e,r),r}get annotationStorage(){return Dae(this,"annotationStorage",new Ioe)}getRenderingIntent(e,t=bae.ENABLE,n=null,r=!1,a=!1){let o=2,c=Foe;switch(e){case"any":o=1;break;case"display":break;case"print":o=4;break;default:Aae(`getRenderingIntent - invalid intent: ${e}`)}const i=4&o&&n instanceof Boe?n:this.annotationStorage;switch(t){case bae.DISABLE:o+=64;break;case bae.ENABLE:break;case bae.ENABLE_FORMS:o+=16;break;case bae.ENABLE_STORAGE:o+=32,c=i.serializable;break;default:Aae(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(o+=128),a&&(o+=256);const{ids:l,hash:s}=i.modifiedIds;return{renderingIntent:o,cacheKey:[o,c.hash,s].join("_"),annotationStorageSerializable:c,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Or?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of this.#xr.values())e.push(t._destroy());this.#xr.clear(),this.#Sr.clear(),this.#Tr.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#kr.clear(),this.filterFactory.destroy(),eie.cleanup(),this._networkStream?.cancelAllRequests(new $ae("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{Nae(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():(Nae(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(async e=>{await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:a}=this._fullReader;return n&&r||(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:a}})),e.on("GetRangeReader",((e,t)=>{Nae(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():(Nae(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new die(e,this))})),e.on("DocException",(e=>{t._capability.reject($oe(e))})),e.on("PasswordRequest",(e=>{this.#Or=Promise.withResolvers();try{if(!t.onPassword)throw $oe(e);const n=e=>{e instanceof Error?this.#Or.reject(e):this.#Or.resolve({password:e})};t.onPassword(n,e.code)}catch(e){this.#Or.reject(e)}return this.#Or.promise})),e.on("DataLoaded",(e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||this.#xr.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,r])=>{if(this.destroyed)return null;if(this.commonObjs.has(t))return null;switch(n){case"Font":const{disableFontFace:a,fontExtraProperties:o,pdfBug:c}=this._params;if("error"in r){const e=r.error;Aae(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}const i=c&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,l=new Uoe(r,{disableFontFace:a,fontExtraProperties:o,inspectFont:i});this.fontLoader.bind(l).catch((()=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!o&&l.data&&(l.data=null),this.commonObjs.resolve(t,l)}));break;case"CopyLocalImage":const{imageRef:s}=r;Nae(s,"The imageRef must be defined.");for(const e of this.#xr.values())for(const[,n]of e.objs)if(n?.ref===s)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,r);break;default:throw new Error(`Got unknown common object type ${n}`)}return null})),e.on("obj",(([e,t,n,r])=>{if(this.destroyed)return;const a=this.#xr.get(t);if(!a.objs.has(e))if(0!==a._intentStates.size)switch(n){case"Image":a.objs.resolve(e,r),r?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(e,r);break;default:throw new Error(`Got unknown object type ${n}`)}else r?.bitmap?.close()})),e.on("DocProgress",(e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)})),e.on("FetchStandardFontData",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Aae("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,n=this.#Sr.get(t);if(n)return n;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#Tr.set(n.refStr,e);const r=new uie(t,n,this,this._params.pdfBug);return this.#xr.set(t,r),r}));return this.#Sr.set(t,r),r}getPageIndex(e){return lie(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#Ar("GetFieldObjects")}hasJSActions(){return this.#Ar("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Ar("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#Ar("GetOptionalContentConfig").then((t=>new Sce(t,e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=this.#kr.get(e);if(t)return t;const n=this.messageHandler.sendWithPromise(e,null).then((e=>({info:e[0],metadata:e[1]?new wce(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#kr.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#xr.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#kr.clear(),this.filterFactory.destroy(!0),eie.cleanup()}}cachedPageNumber(e){if(!lie(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#Tr.get(t)??null}}const fie=Symbol("INITIAL_DATA");class zie{#Rr=Object.create(null);#Nr(e){return this.#Rr[e]||={...Promise.withResolvers(),data:fie}}get(e,t=null){if(t){const n=this.#Nr(e);return n.promise.then((()=>t(n.data))),null}const n=this.#Rr[e];if(!n||n.data===fie)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){const t=this.#Rr[e];return!!t&&t.data!==fie}delete(e){const t=this.#Rr[e];return!(!t||t.data===fie||(delete this.#Rr[e],0))}resolve(e,t=null){const n=this.#Nr(e);n.data=t,n.resolve()}clear(){for(const e in this.#Rr){const{data:t}=this.#Rr[e];t?.bitmap?.close()}this.#Rr=Object.create(null)}*[Symbol.iterator](){for(const e in this.#Rr){const{data:t}=this.#Rr[e];t!==fie&&(yield[e,t])}}}class gie{#_r=null;constructor(e){this.#_r=e,this.onContinue=null}get promise(){return this.#_r.capability.promise}cancel(e=0){this.#_r.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this.#_r.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this.#_r;return e.form||e.canvas&&t?.size>0}}class yie{#Dr=null;static#Pr=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:a,operatorList:o,pageIndex:c,canvasFactory:i,filterFactory:l,useRequestAnimationFrame:s=!1,pdfBug:h=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=c,this.canvasFactory=i,this.filterFactory=l,this._pdfBug=h,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===s&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new gie(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(yie.#Pr.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");yie.#Pr.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:r,transform:a,background:o}=this.params;this.gfx=new Cce(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Dr&&(window.cancelAnimationFrame(this.#Dr),this.#Dr=null),yie.#Pr.delete(this._canvas),this.callback(e||new coe(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Dr=window.requestAnimationFrame((()=>{this.#Dr=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),yie.#Pr.delete(this._canvas),this.callback())))}}const Mie="4.10.38",Eie="f9bea397f";function bie(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function Hie(e){return Math.max(0,Math.min(255,255*e))}class Vie{static CMYK_G([e,t,n,r]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=Hie(e),e,e]}static G_HTML([e]){const t=bie(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(Hie)}static RGB_HTML(e){return`#${e.map(bie).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return["RGB",1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[Hie(1-Math.min(1,e+r)),Hie(1-Math.min(1,n+r)),Hie(1-Math.min(1,t+r))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){const r=1-e,a=1-t,o=1-n;return["CMYK",r,a,o,Math.min(r,a,o)]}}class Cie{create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),n||(r.setAttribute("width",`${e}px`),r.setAttribute("height",`${t}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Rae("Abstract method `_createSVG` called.")}}class Lie extends Cie{_createSVG(e){return document.createElementNS(noe,e)}}class wie{static setupStorage(e,t,n,r,a){const o=r.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==o.value&&(e.textContent=o.value),"print"===a)break;e.addEventListener("input",(e=>{r.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(o.value===n.attributes.xfaOn?e.setAttribute("checked",!0):o.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===a)break;e.addEventListener("change",(e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==o.value&&e.setAttribute("value",o.value),"print"===a)break;e.addEventListener("input",(e=>{r.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==o.value){e.setAttribute("value",o.value);for(const e of n.children)e.attributes.value===o.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected}e.addEventListener("input",(e=>{const n=e.target.options,a=-1===n.selectedIndex?"":n[n.selectedIndex].value;r.setValue(t,{value:a})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:a}){const{attributes:o}=t,c=e instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${r}`);for(const[t,n]of Object.entries(o))if(null!=n)switch(t){case"class":n.length&&e.setAttribute(t,n.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",n);break;case"style":Object.assign(e.style,n);break;case"textContent":e.textContent=n;break;default:(!c||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,n)}c&&a.addLinkAttributes(e,o.href,o.newWindow),n&&o.dataId&&this.setupStorage(e,o.dataId,t,n)}static render(e){const t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,a=e.intent||"display",o=document.createElement(r.name);r.attributes&&this.setAttributes({html:o,element:r,intent:a,linkService:n});const c="richText"!==a,i=e.div;if(i.append(o),e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;i.style.transform=t}c&&i.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===r.children.length){if(r.value){const e=document.createTextNode(r.value);o.append(e),c&&tie.shouldBuildText(r.name)&&l.push(e)}return{textDivs:l}}const s=[[r,-1,o]];for(;s.length>0;){const[e,r,o]=s.at(-1);if(r+1===e.children.length){s.pop();continue}const i=e.children[++s.at(-1)[1]];if(null===i)continue;const{name:h}=i;if("#text"===h){const e=document.createTextNode(i.value);l.push(e),o.append(e);continue}const d=i?.attributes?.xmlns?document.createElementNS(i.attributes.xmlns,h):document.createElement(h);if(o.append(d),i.attributes&&this.setAttributes({html:d,element:i,storage:t,intent:a,linkService:n}),i.children?.length>0)s.push([i,-1,d]);else if(i.value){const e=document.createTextNode(i.value);c&&tie.shouldBuildText(h)&&l.push(e),d.append(e)}}for(const e of i.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const kie=1e3,xie=new WeakSet;function Sie(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Tie{static create(e){switch(e.data.annotationType){case 2:return new Aie(e);case 1:return new Rie(e);case 20:switch(e.data.fieldType){case"Tx":return new _ie(e);case"Btn":return e.data.radioButton?new Fie(e):e.data.checkBox?new Pie(e):new Iie(e);case"Ch":return new Bie(e);case"Sig":return new Die(e)}return new Nie(e);case 16:return new jie(e);case 3:return new Wie(e);case 4:return new $ie(e);case 5:return new qie(e);case 6:return new Gie(e);case 8:return new Yie(e);case 14:return new Xie(e);case 15:return new Qie(e);case 7:return new Kie(e);case 9:return new Jie(e);case 10:return new Zie(e);case 11:return new ele(e);case 12:return new tle(e);case 13:return new nle(e);case 17:return new rle(e);default:return new Oie(e)}}}class Oie{#Fr=null;#Ir=!1;#Br=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Oie._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#Fr||={rect:this.data.rect.slice(0)};const{rect:t}=e;t&&this.#jr(t),this.#Br?.popup.updateEdited(e)}resetEdited(){this.#Fr&&(this.#jr(this.#Fr.rect),this.#Br?.popup.resetEdited(),this.#Fr=null)}#jr(e){const{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:o,pageX:c,pageY:i}}}}=this;n?.splice(0,4,...e);const{width:l,height:s}=Sie(e);t.left=100*(e[0]-c)/a+"%",t.top=100*(o-e[3]+i)/o+"%",0===r?(t.width=100*l/a+"%",t.height=100*s/o+"%"):this.setRotation(r)}_createContainer(e){const{data:t,parent:{page:n,viewport:r}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",t.id),this instanceof Nie||(a.tabIndex=kie);const{style:o}=a;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(a.title=t.alternativeText),t.noRotate&&a.classList.add("norotate"),!t.rect||this instanceof jie){const{rotation:e}=t;return t.hasOwnCanvas||0===e||this.setRotation(e,a),a}const{width:c,height:i}=Sie(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){const t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;o.borderRadius=t}else if(this instanceof Fie){const e=`calc(${c}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;o.borderRadius=e}switch(t.borderStyle.style){case 1:o.borderStyle="solid";break;case 2:o.borderStyle="dashed";break;case 3:Aae("Unimplemented border style: beveled");break;case 4:Aae("Unimplemented border style: inset");break;case 5:o.borderBottomStyle="solid"}const r=t.borderColor||null;r?(this.#Ir=!0,o.borderColor=Qae.makeHexColor(0|r[0],0|r[1],0|r[2])):o.borderWidth=0}const l=Qae.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:s,pageHeight:h,pageX:d,pageY:u}=r.rawDims;o.left=100*(l[0]-d)/s+"%",o.top=100*(l[1]-u)/h+"%";const{rotation:m}=t;return t.hasOwnCanvas||0===m?(o.width=100*c/s+"%",o.height=100*i/h+"%"):this.setRotation(m,a),a}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:a,height:o}=Sie(this.data.rect);let c,i;e%180==0?(c=100*a/n,i=100*o/r):(c=100*o/n,i=100*a/r),t.style.width=`${c}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(e,t,n)=>{const r=n.detail[e],a=r[0],o=r.slice(1);n.target.style[t]=Vie[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[t]:Vie[`${a}_rgb`](o)})};return Dae(this,"_commonActions",{display:e=>{const{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const n=this._commonActions;for(const r of Object.keys(t.detail)){const a=e[r]||n[r];a?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const n=this._commonActions;for(const[r,a]of Object.entries(t)){const o=n[r];o&&(o({detail:{[r]:a},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,n,r,a]=this.data.rect.map((e=>Math.fround(e)));if(8===e.length){const[o,c,i,l]=e.subarray(2,6);if(r===o&&a===c&&t===i&&n===l)return}const{style:o}=this.container;let c;if(this.#Ir){const{borderColor:e,borderWidth:t}=o;o.borderWidth=0,c=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add("hasBorder")}const i=r-t,l=a-n,{svgFactory:s}=this,h=s.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0);const d=s.createElement("defs");h.append(d);const u=s.createElement("clipPath"),m=`clippath_${this.data.id}`;u.setAttribute("id",m),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let n=2,r=e.length;n<r;n+=8){const r=e[n],o=e[n+1],h=e[n+2],d=e[n+3],m=s.createElement("rect"),p=(h-t)/i,v=(a-o)/l,f=(r-h)/i,z=(o-d)/l;m.setAttribute("x",p),m.setAttribute("y",v),m.setAttribute("width",f),m.setAttribute("height",z),u.append(m),c?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${v}" width="${f}" height="${z}"/>`)}this.#Ir&&(c.push("</g></svg>')"),o.backgroundImage=c.join("")),this.container.append(h),this.container.style.clipPath=`url(#${m})`}_createPopup(){const{data:e}=this,t=this.#Br=new jie({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){Rae("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const n=[];if(this._fieldObjects){const r=this._fieldObjects[e];if(r)for(const{page:e,id:a,exportValues:o}of r){if(-1===e)continue;if(a===t)continue;const r="string"==typeof o?o:null,c=document.querySelector(`[data-element-id="${a}"]`);!c||xie.has(c)?n.push({id:a,exportValue:r,domElement:c}):Aae(`_getElementsByName - element not allowed: ${a}`)}return n}for(const r of document.getElementsByName(e)){const{exportValue:e}=r,a=r.getAttribute("data-element-id");a!==t&&xie.has(r)&&n.push({id:a,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})}))}}class Aie extends Oie{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action),r=!0):e.attachment?(this.#Ur(n,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(this.#Wr(n,e.setOCGState),r=!0):e.dest?(this._bindLink(n,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(n),this.container}#$r(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&this.#$r()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#$r()}#Ur(e,t,n=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#$r()}#Wr(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#$r()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(t.actions)){const a=n.get(r);a&&(e[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:r}}),!1))}e.onclick||(e.onclick=()=>!1),this.#$r()}_bindResetFormAction(e,t){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),this.#$r(),!this._fieldObjects)return Aae('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{n?.();const{fields:e,refs:r,include:a}=t,o=[];if(0!==e.length||0!==r.length){const t=new Set(r);for(const n of e){const e=this._fieldObjects[n]||[];for(const{id:n}of e)t.add(n)}for(const e of Object.values(this._fieldObjects))for(const n of e)t.has(n.id)===a&&o.push(n)}else for(const e of Object.values(this._fieldObjects))o.push(...e);const c=this.annotationStorage,i=[];for(const e of o){const{id:t}=e;switch(i.push(t),e.type){case"text":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{const n=e.defaultValue===e.exportValues;c.setValue(t,{value:n});break}case"combobox":case"listbox":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${t}"]`);n&&(xie.has(n)?n.dispatchEvent(new Event("resetform")):Aae(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:i,name:"ResetForm"}}),!1}}}class Rie extends Oie{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Nie extends Oie{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&("CANVAS"===e.previousSibling?.nodeName&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return Kae.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,a){n.includes("mouse")?e.addEventListener(n,(e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(n,(e=>{if("blur"===n){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===n){if(t.focused)return;t.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(e)}})}))}_setEventListeners(e,t,n,r){for(const[a,o]of n)("Action"===o||this.data.actions?.[o])&&("Focus"!==o&&"Blur"!==o||(t||={focused:!1}),this._setEventListener(e,t,a,o,r),"Focus"!==o||this.data.actions?.Blur?"Blur"!==o||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":Qae.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const{fontColor:t}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,r=e.style;let a;const o=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(Eae*n))||1);a=Math.min(n,o(t/Eae))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(n,o(e/Eae))}r.fontSize=`calc(${a}px * var(--scale-factor))`,r.color=Qae.makeHexColor(t[0],t[1],t[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class _ie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,r){const a=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=n),a.setValue(o.id,{[r]:n})}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const r=e.getValue(t,{value:this.data.fieldValue});let a=r.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&a.length>o&&(a=a.slice(0,o));let c=r.formattedValue||this.data.textContent?.join("\n")||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const i={userValue:a,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=c??a,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",c??a),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),xie.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=kie,this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",(r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,"value",r.target.value,"value"),i.formattedValue=null})),n.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue??"";n.value=i.userValue=t,i.formattedValue=null}));let l=e=>{const{formattedValue:t}=i;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",(e=>{if(i.focused)return;const{target:t}=e;i.userValue&&(t.value=i.userValue),i.lastCommittedValue=t.value,i.commitKey=1,this.data.actions?.Focus||(i.focused=!0)})),n.addEventListener("updatefromsandbox",(n=>{this.showElementAndHideCanvas(n.target);const r={value(n){i.userValue=n.detail.value??"",e.setValue(t,{value:i.userValue.toString()}),n.target.value=i.userValue},formattedValue(n){const{formattedValue:r}=n.detail;i.formattedValue=r,null!=r&&n.target!==document.activeElement&&(n.target.value=r),e.setValue(t,{formattedValue:r})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{const{charLimit:r}=n.detail,{target:a}=n;if(0===r)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",r);let o=i.userValue;!o||o.length<=r||(o=o.slice(0,r),a.value=i.userValue=o,e.setValue(t,{value:o}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(r,n)})),n.addEventListener("keydown",(e=>{i.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(i.commitKey=3):n=2,-1===n)return;const{value:r}=e.target;i.lastCommittedValue!==r&&(i.lastCommittedValue=r,i.userValue=r,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));const r=l;l=null,n.addEventListener("blur",(e=>{if(!i.focused||!e.relatedTarget)return;this.data.actions?.Blur||(i.focused=!1);const{value:n}=e.target;i.userValue=n,i.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:i.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),r(e)})),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",(e=>{i.lastCommittedValue=null;const{data:n,target:r}=e,{value:a,selectionStart:o,selectionEnd:c}=r;let l=o,s=c;switch(e.inputType){case"deleteWordBackward":{const e=a.substring(0,o).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{const e=a.substring(o).match(/^[^\w]*\w*/);e&&(s+=e[0].length);break}case"deleteContentBackward":o===c&&(l-=1);break;case"deleteContentForward":o===c&&(s+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:l,selEnd:s}})})),this._setEventListeners(n,i,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(l&&n.addEventListener("blur",l),this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Die extends Nie{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class Pie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,n=t.id;let r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof r&&(r="Off"!==r,e.setValue(n,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const a=document.createElement("input");return xie.add(a),a.setAttribute("data-element-id",n),a.disabled=t.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=t.fieldName,r&&a.setAttribute("checked",!0),a.setAttribute("exportValue",t.exportValue),a.tabIndex=kie,a.addEventListener("change",(r=>{const{name:a,checked:o}=r.target;for(const r of this._getElementsByName(a,n)){const n=o&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:o})})),a.addEventListener("resetform",(e=>{const n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",(t=>{const r={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Fie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,n=t.id;let r=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof r&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(const r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});const a=document.createElement("input");if(xie.add(a),a.setAttribute("data-element-id",n),a.disabled=t.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=t.fieldName,r&&a.setAttribute("checked",!0),a.tabIndex=kie,a.addEventListener("change",(t=>{const{name:r,checked:a}=t.target;for(const t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:a})})),a.addEventListener("resetform",(e=>{const n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){const r=t.buttonValue;a.addEventListener("updatefromsandbox",(t=>{const a={value:t=>{const a=r===t.detail.value;for(const r of this._getElementsByName(t.target.name)){const t=a&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}};this._dispatchEventFromSandbox(a,t)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Iie extends Aie{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class Bie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement("select");xie.add(r),r.setAttribute("data-element-id",t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=kie;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue;for(const e of r.options)e.selected=e.value===t}));for(const e of this.data.options){const t=document.createElement("option");t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),a=!1),r.append(t)}let o=null;if(a){const e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),r.prepend(e),o=()=>{e.remove(),r.removeEventListener("input",o),o=null},r.addEventListener("input",o)}const c=e=>{const t=e?"value":"textContent",{options:n,multiple:a}=r;return a?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]};let i=c(!1);const l=e=>{const t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",(n=>{const a={value(n){o?.();const a=n.detail.value,l=new Set(Array.isArray(a)?a:[a]);for(const e of r.options)e.selected=l.has(e.value);e.setValue(t,{value:c(!0)}),i=c(!1)},multipleSelection(e){r.multiple=!0},remove(n){const a=r.options,o=n.detail.remove;a[o].selected=!1,r.remove(o),a.length>0&&-1===Array.prototype.findIndex.call(a,(e=>e.selected))&&(a[0].selected=!0),e.setValue(t,{value:c(!0),items:l(n)}),i=c(!1)},clear(n){for(;0!==r.length;)r.remove(0);e.setValue(t,{value:null,items:[]}),i=c(!1)},insert(n){const{index:a,displayValue:o,exportValue:s}=n.detail.insert,h=r.children[a],d=document.createElement("option");d.textContent=o,d.value=s,h?h.before(d):r.append(d),e.setValue(t,{value:c(!0),items:l(n)}),i=c(!1)},items(n){const{items:a}=n.detail;for(;0!==r.length;)r.remove(0);for(const e of a){const{displayValue:t,exportValue:n}=e,a=document.createElement("option");a.textContent=t,a.value=n,r.append(a)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:c(!0),items:l(n)}),i=c(!1)},indices(n){const r=new Set(n.detail.indices);for(const e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:c(!0)}),i=c(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(a,n)})),r.addEventListener("input",(n=>{const r=c(!0),a=c(!1);e.setValue(t,{value:r}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,change:a,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):r.addEventListener("input",(function(n){e.setValue(t,{value:c(!0)})})),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class jie extends Oie{constructor(e){const{data:t,elements:n}=e;super(e,{isRenderable:Oie._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new Uie({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const n of this.elements)n.popup=e,n.container.ariaHasPopup="dialog",t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.map((e=>`${toe}${e}`)).join(",")),this.container}}class Uie{#qr=this.#Gr.bind(this);#Yr=this.#Kr.bind(this);#Xr=this.#Qr.bind(this);#Jr=this.#Zr.bind(this);#ea=null;#me=null;#ta=null;#na=null;#ra=null;#aa=null;#oa=null;#ca=!1;#ia=null;#L=null;#la=null;#sa=null;#ha=null;#Fr=null;#da=!1;constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:a,contentsObj:o,richText:c,parent:i,rect:l,parentRect:s,open:h}){this.#me=e,this.#ha=r,this.#ta=o,this.#sa=c,this.#aa=i,this.#ea=t,this.#la=l,this.#oa=s,this.#ra=n,this.#na=voe.toDateObject(a),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(const e of this.trigger)e.addEventListener("click",this.#Jr),e.addEventListener("mouseenter",this.#Xr),e.addEventListener("mouseleave",this.#Yr),e.classList.add("popupTriggerArea");for(const e of n)e.container?.addEventListener("keydown",this.#qr);this.#me.hidden=!0,h&&this.#Zr()}render(){if(this.#ia)return;const e=this.#ia=document.createElement("div");if(e.className="popup",this.#ea){const t=e.style.outlineColor=Qae.makeHexColor(...this.#ea);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`;else{const t=.7;e.style.backgroundColor=Qae.makeHexColor(...this.#ea.map((e=>Math.floor(t*(255-e)+e))))}}const t=document.createElement("span");t.className="header";const n=document.createElement("h1");if(t.append(n),({dir:n.dir,str:n.textContent}=this.#ha),e.append(t),this.#na){const e=document.createElement("span");e.classList.add("popupDate"),e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),e.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#na.valueOf()})),t.append(e)}const r=this.#ua;if(r)wie.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(this.#ta);e.append(t)}this.#me.append(e)}get#ua(){const e=this.#sa,t=this.#ta;return!e?.str||t?.str&&t.str!==e.str?null:this.#sa.html||null}get#ma(){return this.#ua?.attributes?.style?.fontSize||0}get#pa(){return this.#ua?.attributes?.style?.color||null}#va(e){const t=[],n={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},r={style:{color:this.#pa,fontSize:this.#ma?`calc(${this.#ma}px * var(--scale-factor))`:""}};for(const n of e.split("\n"))t.push({name:"span",value:n,attributes:r});return n}_formatContents({str:e,dir:t}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;const r=e.split(/(?:\r\n?|\n)/);for(let e=0,t=r.length;e<t;++e){const a=r[e];n.append(document.createTextNode(a)),e<t-1&&n.append(document.createElement("br"))}return n}#Gr(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&this.#ca)&&this.#Zr()}updateEdited({rect:e,popupContent:t}){this.#Fr||={contentsObj:this.#ta,richText:this.#sa},e&&(this.#L=null),t&&(this.#sa=this.#va(t),this.#ta=null),this.#ia?.remove(),this.#ia=null}resetEdited(){this.#Fr&&(({contentsObj:this.#ta,richText:this.#sa}=this.#Fr),this.#Fr=null,this.#ia?.remove(),this.#ia=null,this.#L=null)}#fa(){if(null!==this.#L)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:a}}}=this.#aa;let o=!!this.#oa,c=o?this.#oa:this.#la;for(const e of this.#ra)if(!c||null!==Qae.intersect(e.data.rect,c)){c=e.data.rect,o=!0;break}const i=Qae.normalizeRect([c[0],e[3]-c[1]+e[1],c[2],e[3]-c[3]+e[1]]),l=o?c[2]-c[0]+5:0,s=i[0]+l,h=i[1];this.#L=[100*(s-r)/t,100*(h-a)/n];const{style:d}=this.#me;d.left=`${this.#L[0]}%`,d.top=`${this.#L[1]}%`}#Zr(){this.#ca=!this.#ca,this.#ca?(this.#Qr(),this.#me.addEventListener("click",this.#Jr),this.#me.addEventListener("keydown",this.#qr)):(this.#Kr(),this.#me.removeEventListener("click",this.#Jr),this.#me.removeEventListener("keydown",this.#qr))}#Qr(){this.#ia||this.render(),this.isVisible?this.#ca&&this.#me.classList.add("focused"):(this.#fa(),this.#me.hidden=!1,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)+1e3)}#Kr(){this.#me.classList.remove("focused"),!this.#ca&&this.isVisible&&(this.#me.hidden=!0,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)-1e3)}forceHide(){this.#da=this.isVisible,this.#da&&(this.#me.hidden=!0)}maybeShow(){this.#da&&(this.#ia||this.#Qr(),this.#da=!1,this.#me.hidden=!1)}get isVisible(){return!1===this.#me.hidden}}class Wie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Hae.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const t of this.textContent){const n=document.createElement("span");n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class $ie extends Oie{#za=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:t,height:n}=Sie(e.rect),r=this.svgFactory.create(t,n,!0),a=this.#za=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#za}addHighlightArea(){this.container.classList.add("highlightArea")}}class qie extends Oie{#ga=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:t,height:n}=Sie(e.rect),r=this.svgFactory.create(t,n,!0),a=e.borderStyle.width,o=this.#ga=this.svgFactory.createElement("svg:rect");return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",t-a),o.setAttribute("height",n-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ga}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gie extends Oie{#ya=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:t,height:n}=Sie(e.rect),r=this.svgFactory.create(t,n,!0),a=e.borderStyle.width,o=this.#ya=this.svgFactory.createElement("svg:ellipse");return o.setAttribute("cx",t/2),o.setAttribute("cy",n/2),o.setAttribute("rx",t/2-a/2),o.setAttribute("ry",n/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ya}addHighlightArea(){this.container.classList.add("highlightArea")}}class Yie extends Oie{#Ma=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:t,borderStyle:n,popupRef:r}}=this;if(!t)return this.container;const{width:a,height:o}=Sie(e),c=this.svgFactory.create(a,o,!0);let i=[];for(let n=0,r=t.length;n<r;n+=2){const r=t[n]-e[0],a=e[3]-t[n+1];i.push(`${r},${a}`)}i=i.join(" ");const l=this.#Ma=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",i),l.setAttribute("stroke-width",n.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),c.append(l),this.container.append(c),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Ma}addHighlightArea(){this.container.classList.add("highlightArea")}}class Kie extends Yie{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Xie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Qie extends Oie{#Ea=null;#ba=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Hae.HIGHLIGHT:Hae.INK}#Ha(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:t,inkLists:n,borderStyle:r,popupRef:a}}=this,{transform:o,width:c,height:i}=this.#Ha(t,e),l=this.svgFactory.create(c,i,!0),s=this.#Ea=this.svgFactory.createElement("svg:g");l.append(s),s.setAttribute("stroke-width",r.width||1),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("stroke-miterlimit",10),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),s.setAttribute("transform",o);for(let e=0,t=n.length;e<t;e++){const t=this.svgFactory.createElement(this.svgElementName);this.#ba.push(t),t.setAttribute("points",n[e].join(",")),s.append(t)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:t,points:n,rect:r}=e,a=this.#Ea;if(t>=0&&a.setAttribute("stroke-width",t||1),n)for(let e=0,t=this.#ba.length;e<t;e++)this.#ba[e].setAttribute("points",n[e].join(","));if(r){const{transform:e,width:t,height:n}=this.#Ha(this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("transform",e)}}getElementsToTriggerPopup(){return this.#ba}addHighlightArea(){this.container.classList.add("highlightArea")}}class Jie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Hae.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Zie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ele extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class tle extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class nle extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Hae.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class rle extends Oie{#Va=null;constructor(e){super(e,{isRenderable:!0});const{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...t})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let n;t.hasAppearance||0===t.fillAlpha?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)),n.addEventListener("dblclick",this.#Ca.bind(this)),this.#Va=n;const{isMac:r}=Kae.platform;return e.addEventListener("keydown",(e=>{"Enter"===e.key&&(r?e.metaKey:e.ctrlKey)&&this.#Ca()})),!t.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return this.#Va}addHighlightArea(){this.container.classList.add("highlightArea")}#Ca(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ale{#La=null;#wa=null;#ka=new Map;#xa=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:a,viewport:o,structTreeLayer:c}){this.div=e,this.#La=t,this.#wa=n,this.#xa=c||null,this.page=a,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#ka.size>0}async#Sa(e,t){const n=e.firstChild||e,r=n.id=`${toe}${t}`,a=await(this.#xa?.getAriaAttributes(r));if(a)for(const[e,t]of a)n.setAttribute(e,t);this.div.append(e),this.#La?.moveElementInDOM(this.div,e,n,!1)}async render(e){const{annotations:t}=e,n=this.div;Moe(n,this.viewport);const r=new Map,a={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new Lie,annotationStorage:e.annotationStorage||new Ioe,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=16===e.annotationType;if(t){const t=r.get(e.id);if(!t)continue;a.elements=t}else{const{width:t,height:n}=Sie(e.rect);if(t<=0||n<=0)continue}a.data=e;const n=Tie.create(a);if(!n.isRenderable)continue;if(!t&&e.popupRef){const t=r.get(e.popupRef);t?t.push(n):r.set(e.popupRef,[n])}const o=n.render();e.hidden&&(o.style.visibility="hidden"),await this.#Sa(o,e.id),n._isEditable&&(this.#ka.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#Ta()}update({viewport:e}){const t=this.div;this.viewport=e,Moe(t,{rotation:e.rotation}),this.#Ta(),t.hidden=!1}#Ta(){if(!this.#wa)return;const e=this.div;for(const[t,n]of this.#wa){const r=e.querySelector(`[data-annotation-id="${t}"]`);if(!r)continue;n.className="annotationContent";const{firstChild:a}=r;a?"CANVAS"===a.nodeName?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):r.append(n)}this.#wa.clear()}getEditableAnnotations(){return Array.from(this.#ka.values())}getEditableAnnotation(e){return this.#ka.get(e)}}const ole=/\r\n?|\n/g;class cle extends Aoe{#ea;#Oa="";#Aa=`${this.id}-editor`;#Ra=null;#ma;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const e=cle.prototype,t=e=>e.isEmpty(),n=Soe.TRANSLATE_SMALL,r=Soe.TRANSLATE_BIG;return Dae(this,"_keyboardManager",new koe([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:t}]]))}static _type="freetext";static _editorType=Hae.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"}),this.#ea=e.color||cle._defaultColor||Aoe._defaultLineColor,this.#ma=e.fontSize||cle._defaultFontSize}static initialize(e,t){Aoe.initialize(e,t);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case Vae.FREETEXT_SIZE:cle._defaultFontSize=t;break;case Vae.FREETEXT_COLOR:cle._defaultColor=t}}updateParams(e,t){switch(e){case Vae.FREETEXT_SIZE:this.#Na(t);break;case Vae.FREETEXT_COLOR:this.#_a(t)}}static get defaultPropertiesToUpdate(){return[[Vae.FREETEXT_SIZE,cle._defaultFontSize],[Vae.FREETEXT_COLOR,cle._defaultColor||Aoe._defaultLineColor]]}get propertiesToUpdate(){return[[Vae.FREETEXT_SIZE,this.#ma],[Vae.FREETEXT_COLOR,this.#ea]]}#Na(e){const t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#ma)*this.parentScale),this.#ma=e,this.#Da()},n=this.#ma;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#_a(e){const t=e=>{this.#ea=this.editorDiv.style.color=e},n=this.#ea;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-cle._internalPadding*e,-(cle._internalPadding+this.#ma)*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Hae.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Ra=new AbortController;const e=this._uiManager.combinedSignal(this.#Ra);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Aa),this._isDraggable=!0,this.#Ra?.abort(),this.#Ra=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Pa(){const e=[];this.editorDiv.normalize();let t=null;for(const n of this.editorDiv.childNodes)t?.nodeType===Node.TEXT_NODE&&"BR"===n.nodeName||(e.push(cle.#Fa(n)),t=n);return e.join("\n")}#Da(){const[e,t]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,r=t.style.display,a=t.classList.contains("hidden");t.classList.remove("hidden"),t.style.display="hidden",e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle("hidden",a)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=this.#Oa,t=this.#Oa=this.#Pa().trimEnd();if(e===t)return;const n=e=>{this.#Oa=e,e?(this.#Ia(),this._uiManager.rebuild(this),this.#Da()):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#Da()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){cle._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Aa),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#ma}px * var(--scale-factor))`,n.color=this.#ea,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Voe(this,this.div,["dblclick","keydown"]),this.width){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:a}=this._initialData;let[o,c]=this.getInitialTranslation();[o,c]=this.pageTranslationToScreen(o,c);const[i,l]=this.pageDimensions,[s,h]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=e+(a[0]-s)/i,u=t+this.height-(a[1]-h)/l;break;case 90:d=e+(a[0]-s)/i,u=t-(a[1]-h)/l,[o,c]=[c,-o];break;case 180:d=e-this.width+(a[0]-s)/i,u=t-(a[1]-h)/l,[o,c]=[-o,-c];break;case 270:d=e+(a[0]-s-this.height*l)/i,u=t+(a[1]-h-this.width*i)/l,[o,c]=[-c,o]}this.setAt(d*n,u*r,o,c)}else this.setAt(e*n,t*r,this.width*n,this.height*r);this.#Ia(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Fa(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(ole,"")}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,{types:n}=t;if(1===n.length&&"text/plain"===n[0])return;e.preventDefault();const r=cle.#Ba(t.getData("text")||"").replaceAll(ole,"\n");if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes("\n"))return o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),void a.collapseToStart();const{startContainer:c,startOffset:i}=o,l=[],s=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(s.push(c.nodeValue.slice(i).replaceAll(ole,"")),e!==this.editorDiv){let t=l;for(const n of this.editorDiv.childNodes)n!==e?t.push(cle.#Fa(n)):t=s}l.push(c.nodeValue.slice(0,i).replaceAll(ole,""))}else if(c===this.editorDiv){let e=l,t=0;for(const n of this.editorDiv.childNodes)t++===i&&(e=s),e.push(cle.#Fa(n))}this.#Oa=`${l.join("\n")}${r}${s.join("\n")}`,this.#Ia();const h=new Range;let d=l.reduce(((e,t)=>e+t.length),0);for(const{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue.length;if(d<=t){h.setStart(e,d),h.setEnd(e,d);break}d-=t}a.removeAllRanges(),a.addRange(h)}#Ia(){if(this.editorDiv.replaceChildren(),this.#Oa)for(const e of this.#Oa.split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#ja(){return this.#Oa.replaceAll(" "," ")}static#Ba(e){return e.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(e,t,n){let r=null;if(e instanceof Wie){const{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:a,rotation:o,id:c,popupRef:i},textContent:l,textPosition:s,parent:{page:{pageNumber:h}}}=e;if(!l||0===l.length)return null;r=e={annotationType:Hae.FREETEXT,color:Array.from(n),fontSize:t,value:l.join("\n"),position:s,pageIndex:h-1,rect:a.slice(0),rotation:o,id:c,deleted:!1,popupRef:i}}const a=await super.deserialize(e,t,n);return a.#ma=e.fontSize,a.#ea=Qae.makeHexColor(...e.color),a.#Oa=cle.#Ba(e.value),a.annotationElementId=e.id||null,a._initialData=r,a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const t=cle._internalPadding*this.parentScale,n=this.getRect(t,t),r=Aoe._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#ea),a={annotationType:Hae.FREETEXT,color:r,fontSize:this.#ma,value:this.#ja(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!this.#Ua(a)?null:(a.id=this.annotationElementId,a)}#Ua(e){const{value:t,fontSize:n,color:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some(((e,t)=>e!==r[t]))||e.pageIndex!==a}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(this.deleted)return t;const{style:n}=t;n.fontSize=`calc(${this.#ma}px * var(--scale-factor))`,n.color=this.#ea,t.replaceChildren();for(const e of this.#Oa.split("\n")){const n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),t.append(n)}const r=cle._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(r,r),popupContent:this.#Oa}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class ile{static PRECISION=1e-4;toSVGPath(){Rae("Abstract method `toSVGPath` must be implemented.")}get box(){Rae("Abstract getter `box` must be implemented.")}serialize(e,t){Rae("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,a,o){o||=new Float32Array(e.length);for(let c=0,i=e.length;c<i;c+=2)o[c]=t+e[c]*r,o[c+1]=n+e[c+1]*a;return o}static _rescaleAndSwap(e,t,n,r,a,o){o||=new Float32Array(e.length);for(let c=0,i=e.length;c<i;c+=2)o[c]=t+e[c+1]*r,o[c+1]=n+e[c]*a;return o}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let a=0,o=e.length;a<o;a+=2)r[a]=t+e[a],r[a+1]=n+e[a+1];return r}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,r,a){switch(a){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,a,o){return[(e+5*n)/6,(t+5*r)/6,(5*n+a)/6,(5*r+o)/6,(n+a)/2,(r+o)/2]}}class lle{#Wa;#$a=[];#qa;#Ga;#Ya=[];#Ka=new Float32Array(18);#Xa;#Qa;#Ja;#Za;#eo;#to;#no=[];static#ro=8;static#ao=2;static#oo=lle.#ro+lle.#ao;constructor({x:e,y:t},n,r,a,o,c=0){this.#Wa=n,this.#to=a*r,this.#Ga=o,this.#Ka.set([NaN,NaN,NaN,NaN,e,t],6),this.#qa=c,this.#Za=lle.#ro*r,this.#Ja=lle.#oo*r,this.#eo=r,this.#no.push(e,t)}isEmpty(){return isNaN(this.#Ka[8])}#co(){const e=this.#Ka.subarray(4,6),t=this.#Ka.subarray(16,18),[n,r,a,o]=this.#Wa;return[(this.#Xa+(e[0]-t[0])/2-n)/a,(this.#Qa+(e[1]-t[1])/2-r)/o,(this.#Xa+(t[0]-e[0])/2-n)/a,(this.#Qa+(t[1]-e[1])/2-r)/o]}add({x:e,y:t}){this.#Xa=e,this.#Qa=t;const[n,r,a,o]=this.#Wa;let[c,i,l,s]=this.#Ka.subarray(8,12);const h=e-l,d=t-s,u=Math.hypot(h,d);if(u<this.#Ja)return!1;const m=u-this.#Za,p=m/u,v=p*h,f=p*d;let z=c,g=i;c=l,i=s,l+=v,s+=f,this.#no?.push(e,t);const y=v/m,M=-f/m*this.#to,E=y*this.#to;return this.#Ka.set(this.#Ka.subarray(2,8),0),this.#Ka.set([l+M,s+E],4),this.#Ka.set(this.#Ka.subarray(14,18),12),this.#Ka.set([l-M,s-E],16),isNaN(this.#Ka[6])?(0===this.#Ya.length&&(this.#Ka.set([c+M,i+E],2),this.#Ya.push(NaN,NaN,NaN,NaN,(c+M-n)/a,(i+E-r)/o),this.#Ka.set([c-M,i-E],14),this.#$a.push(NaN,NaN,NaN,NaN,(c-M-n)/a,(i-E-r)/o)),this.#Ka.set([z,g,c,i,l,s],6),!this.isEmpty()):(this.#Ka.set([z,g,c,i,l,s],6),Math.abs(Math.atan2(g-i,z-c)-Math.atan2(f,v))<Math.PI/2?([c,i,l,s]=this.#Ka.subarray(2,6),this.#Ya.push(NaN,NaN,NaN,NaN,((c+l)/2-n)/a,((i+s)/2-r)/o),[c,i,z,g]=this.#Ka.subarray(14,18),this.#$a.push(NaN,NaN,NaN,NaN,((z+c)/2-n)/a,((g+i)/2-r)/o),!0):([z,g,c,i,l,s]=this.#Ka.subarray(0,6),this.#Ya.push(((z+5*c)/6-n)/a,((g+5*i)/6-r)/o,((5*c+l)/6-n)/a,((5*i+s)/6-r)/o,((c+l)/2-n)/a,((i+s)/2-r)/o),[l,s,c,i,z,g]=this.#Ka.subarray(12,18),this.#$a.push(((z+5*c)/6-n)/a,((g+5*i)/6-r)/o,((5*c+l)/6-n)/a,((5*i+s)/6-r)/o,((c+l)/2-n)/a,((i+s)/2-r)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const e=this.#Ya,t=this.#$a;if(isNaN(this.#Ka[6])&&!this.isEmpty())return this.#io();const n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#lo(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return this.#so(n),n.join(" ")}#io(){const[e,t,n,r]=this.#Wa,[a,o,c,i]=this.#co();return`M${(this.#Ka[2]-e)/n} ${(this.#Ka[3]-t)/r} L${(this.#Ka[4]-e)/n} ${(this.#Ka[5]-t)/r} L${a} ${o} L${c} ${i} L${(this.#Ka[16]-e)/n} ${(this.#Ka[17]-t)/r} L${(this.#Ka[14]-e)/n} ${(this.#Ka[15]-t)/r} Z`}#so(e){const t=this.#$a;e.push(`L${t[4]} ${t[5]} Z`)}#lo(e){const[t,n,r,a]=this.#Wa,o=this.#Ka.subarray(4,6),c=this.#Ka.subarray(16,18),[i,l,s,h]=this.#co();e.push(`L${(o[0]-t)/r} ${(o[1]-n)/a} L${i} ${l} L${s} ${h} L${(c[0]-t)/r} ${(c[1]-n)/a}`)}newFreeDrawOutline(e,t,n,r,a,o){return new sle(e,t,n,r,a,o)}getOutlines(){const e=this.#Ya,t=this.#$a,n=this.#Ka,[r,a,o,c]=this.#Wa,i=new Float32Array((this.#no?.length??0)+2);for(let e=0,t=i.length-2;e<t;e+=2)i[e]=(this.#no[e]-r)/o,i[e+1]=(this.#no[e+1]-a)/c;if(i[i.length-2]=(this.#Xa-r)/o,i[i.length-1]=(this.#Qa-a)/c,isNaN(n[6])&&!this.isEmpty())return this.#ho(i);const l=new Float32Array(this.#Ya.length+24+this.#$a.length);let s=e.length;for(let t=0;t<s;t+=2)isNaN(e[t])?l[t]=l[t+1]=NaN:(l[t]=e[t],l[t+1]=e[t+1]);s=this.#do(l,s);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)isNaN(t[e+n])?(l[s]=l[s+1]=NaN,s+=2):(l[s]=t[e+n],l[s+1]=t[e+n+1],s+=2);return this.#uo(l,s),this.newFreeDrawOutline(l,i,this.#Wa,this.#eo,this.#qa,this.#Ga)}#ho(e){const t=this.#Ka,[n,r,a,o]=this.#Wa,[c,i,l,s]=this.#co(),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(t[2]-n)/a,(t[3]-r)/o,NaN,NaN,NaN,NaN,(t[4]-n)/a,(t[5]-r)/o,NaN,NaN,NaN,NaN,c,i,NaN,NaN,NaN,NaN,l,s,NaN,NaN,NaN,NaN,(t[16]-n)/a,(t[17]-r)/o,NaN,NaN,NaN,NaN,(t[14]-n)/a,(t[15]-r)/o],0),this.newFreeDrawOutline(h,e,this.#Wa,this.#eo,this.#qa,this.#Ga)}#uo(e,t){const n=this.#$a;return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+6}#do(e,t){const n=this.#Ka.subarray(4,6),r=this.#Ka.subarray(16,18),[a,o,c,i]=this.#Wa,[l,s,h,d]=this.#co();return e.set([NaN,NaN,NaN,NaN,(n[0]-a)/c,(n[1]-o)/i,NaN,NaN,NaN,NaN,l,s,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(r[0]-a)/c,(r[1]-o)/i],t),t+24}}class sle extends ile{#Wa;#mo=new Float32Array(4);#qa;#Ga;#no;#eo;#po;constructor(e,t,n,r,a,o){super(),this.#po=e,this.#no=t,this.#Wa=n,this.#eo=r,this.#qa=a,this.#Ga=o,this.lastPoint=[NaN,NaN],this.#vo(o);const[c,i,l,s]=this.#mo;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-c)/l,e[t+1]=(e[t+1]-i)/s;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-c)/l,t[e+1]=(t[e+1]-i)/s}toSVGPath(){const e=[`M${this.#po[4]} ${this.#po[5]}`];for(let t=6,n=this.#po.length;t<n;t+=6)isNaN(this.#po[t])?e.push(`L${this.#po[t+4]} ${this.#po[t+5]}`):e.push(`C${this.#po[t]} ${this.#po[t+1]} ${this.#po[t+2]} ${this.#po[t+3]} ${this.#po[t+4]} ${this.#po[t+5]}`);return e.push("Z"),e.join(" ")}serialize([e,t,n,r],a){const o=n-e,c=r-t;let i,l;switch(a){case 0:i=ile._rescale(this.#po,e,r,o,-c),l=ile._rescale(this.#no,e,r,o,-c);break;case 90:i=ile._rescaleAndSwap(this.#po,e,t,o,c),l=ile._rescaleAndSwap(this.#no,e,t,o,c);break;case 180:i=ile._rescale(this.#po,n,t,-o,c),l=ile._rescale(this.#no,n,t,-o,c);break;case 270:i=ile._rescaleAndSwap(this.#po,n,r,-o,-c),l=ile._rescaleAndSwap(this.#no,n,r,-o,-c)}return{outline:Array.from(i),points:[Array.from(l)]}}#vo(e){const t=this.#po;let n=t[4],r=t[5],a=n,o=r,c=n,i=r,l=n,s=r;const h=e?Math.max:Math.min;for(let e=6,d=t.length;e<d;e+=6){if(isNaN(t[e]))a=Math.min(a,t[e+4]),o=Math.min(o,t[e+5]),c=Math.max(c,t[e+4]),i=Math.max(i,t[e+5]),s<t[e+5]?(l=t[e+4],s=t[e+5]):s===t[e+5]&&(l=h(l,t[e+4]));else{const d=Qae.bezierBoundingBox(n,r,...t.slice(e,e+6));a=Math.min(a,d[0]),o=Math.min(o,d[1]),c=Math.max(c,d[2]),i=Math.max(i,d[3]),s<d[3]?(l=d[2],s=d[3]):s===d[3]&&(l=h(l,d[2]))}n=t[e+4],r=t[e+5]}const d=this.#mo;d[0]=a-this.#qa,d[1]=o-this.#qa,d[2]=c-a+2*this.#qa,d[3]=i-o+2*this.#qa,this.lastPoint=[l,s]}get box(){return this.#mo}newOutliner(e,t,n,r,a,o=0){return new lle(e,t,n,r,a,o)}getNewOutline(e,t){const[n,r,a,o]=this.#mo,[c,i,l,s]=this.#Wa,h=a*l,d=o*s,u=n*l+c,m=r*s+i,p=this.newOutliner({x:this.#no[0]*h+u,y:this.#no[1]*d+m},this.#Wa,this.#eo,e,this.#Ga,t??this.#qa);for(let e=2;e<this.#no.length;e+=2)p.add({x:this.#no[e]*h+u,y:this.#no[e+1]*d+m});return p.getOutlines()}}class hle{#Wa;#fo;#zo=[];#go=[];constructor(e,t=0,n=0,r=!0){let a=1/0,o=-1/0,c=1/0,i=-1/0;const l=10**-4;for(const{x:n,y:r,width:s,height:h}of e){const e=Math.floor((n-t)/l)*l,d=Math.ceil((n+s+t)/l)*l,u=Math.floor((r-t)/l)*l,m=Math.ceil((r+h+t)/l)*l,p=[e,u,m,!0],v=[d,u,m,!1];this.#zo.push(p,v),a=Math.min(a,e),o=Math.max(o,d),c=Math.min(c,u),i=Math.max(i,m)}const s=o-a+2*n,h=i-c+2*n,d=a-n,u=c-n,m=this.#zo.at(r?-1:-2),p=[m[0],m[2]];for(const e of this.#zo){const[t,n,r]=e;e[0]=(t-d)/s,e[1]=(n-u)/h,e[2]=(r-u)/h}this.#Wa=new Float32Array([d,u,s,h]),this.#fo=p}getOutlines(){this.#zo.sort(((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]));const e=[];for(const t of this.#zo)t[3]?(e.push(...this.#yo(t)),this.#Mo(t)):(this.#Eo(t),e.push(...this.#yo(t)));return this.#bo(e)}#bo(e){const t=[],n=new Set;for(const n of e){const[e,r,a]=n;t.push([e,r,n],[e,a,n])}t.sort(((e,t)=>e[1]-t[1]||e[0]-t[0]));for(let e=0,r=t.length;e<r;e+=2){const r=t[e][2],a=t[e+1][2];r.push(a),a.push(r),n.add(r),n.add(a)}const r=[];let a;for(;n.size>0;){const e=n.values().next().value;let[t,o,c,i,l]=e;n.delete(e);let s=t,h=o;for(a=[t,c],r.push(a);;){let e;if(n.has(i))e=i;else{if(!n.has(l))break;e=l}n.delete(e),[t,o,c,i,l]=e,s!==t&&(a.push(s,h,t,h===o?o:c),s=t),h=h===o?c:o}a.push(s,h)}return new dle(r,this.#Wa,this.#fo)}#Ho(e){const t=this.#go;let n=0,r=t.length-1;for(;n<=r;){const a=n+r>>1,o=t[a][0];if(o===e)return a;o<e?n=a+1:r=a-1}return r+1}#Mo([,e,t]){const n=this.#Ho(e);this.#go.splice(n,0,[e,t])}#Eo([,e,t]){const n=this.#Ho(e);for(let r=n;r<this.#go.length;r++){const[n,a]=this.#go[r];if(n!==e)break;if(n===e&&a===t)return void this.#go.splice(r,1)}for(let r=n-1;r>=0;r--){const[n,a]=this.#go[r];if(n!==e)break;if(n===e&&a===t)return void this.#go.splice(r,1)}}#yo(e){const[t,n,r]=e,a=[[t,n,r]],o=this.#Ho(r);for(let e=0;e<o;e++){const[n,r]=this.#go[e];for(let e=0,o=a.length;e<o;e++){const[,c,i]=a[e];if(!(r<=c||i<=n))if(c>=n)if(i>r)a[e][1]=r;else{if(1===o)return[];a.splice(e,1),e--,o--}else a[e][2]=n,i>r&&a.push([t,r,i])}}return a}}class dle extends ile{#Wa;#Vo;constructor(e,t,n){super(),this.#Vo=e,this.#Wa=t,this.lastPoint=n}toSVGPath(){const e=[];for(const t of this.#Vo){let[n,r]=t;e.push(`M${n} ${r}`);for(let a=2;a<t.length;a+=2){const o=t[a],c=t[a+1];o===n?(e.push(`V${c}`),r=c):c===r&&(e.push(`H${o}`),n=o)}e.push("Z")}return e.join(" ")}serialize([e,t,n,r],a){const o=[],c=n-e,i=r-t;for(const t of this.#Vo){const n=new Array(t.length);for(let a=0;a<t.length;a+=2)n[a]=e+t[a]*c,n[a+1]=r-t[a+1]*i;o.push(n)}return o}get box(){return this.#Wa}get classNamesForOutlining(){return["highlightOutline"]}}class ule extends lle{newFreeDrawOutline(e,t,n,r,a,o){return new mle(e,t,n,r,a,o)}}class mle extends sle{newOutliner(e,t,n,r,a,o=0){return new ule(e,t,n,r,a,o)}}class ple{#Co=null;#Lo=null;#wo;#ko=null;#xo=!1;#So=!1;#o=null;#To;#Oo=null;#v=null;#Ao;static#Ro=null;static get _keyboardManager(){return Dae(this,"_keyboardManager",new koe([[["Escape","mac+Escape"],ple.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ple.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ple.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ple.prototype._moveToPrevious],[["Home","mac+Home"],ple.prototype._moveToBeginning],[["End","mac+End"],ple.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#So=!1,this.#Ao=Vae.HIGHLIGHT_COLOR,this.#o=e):(this.#So=!0,this.#Ao=Vae.HIGHLIGHT_DEFAULT_COLOR),this.#v=e?._uiManager||t,this.#To=this.#v._eventBus,this.#wo=e?.color||this.#v?.highlightColors.values().next().value||"#FFFF98",ple.#Ro||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const e=this.#Co=document.createElement("button");e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const t=this.#v._signal;e.addEventListener("click",this.#No.bind(this),{signal:t}),e.addEventListener("keydown",this.#Gr.bind(this),{signal:t});const n=this.#Lo=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#wo,e.append(n),e}renderMainDropdown(){const e=this.#ko=this.#_o();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#_o(){const e=document.createElement("div"),t=this.#v._signal;e.addEventListener("contextmenu",moe,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[n,r]of this.#v.highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",r),a.title=n,a.setAttribute("data-l10n-id",ple.#Ro[n]);const o=document.createElement("span");a.append(o),o.className="swatch",o.style.backgroundColor=r,a.setAttribute("aria-selected",r===this.#wo),a.addEventListener("click",this.#Do.bind(this,r),{signal:t}),e.append(a)}return e.addEventListener("keydown",this.#Gr.bind(this),{signal:t}),e}#Do(e,t){t.stopPropagation(),this.#To.dispatch("switchannotationeditorparams",{source:this,type:this.#Ao,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#Co)return void this.#No(e);const t=e.target.getAttribute("data-color");t&&this.#Do(t,e)}_moveToNext(e){this.#Po?e.target!==this.#Co?e.target.nextSibling?.focus():this.#ko.firstChild?.focus():this.#No(e)}_moveToPrevious(e){e.target!==this.#ko?.firstChild&&e.target!==this.#Co?(this.#Po||this.#No(e),e.target.previousSibling?.focus()):this.#Po&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){this.#Po?this.#ko.firstChild?.focus():this.#No(e)}_moveToEnd(e){this.#Po?this.#ko.lastChild?.focus():this.#No(e)}#Gr(e){ple._keyboardManager.exec(this,e)}#No(e){if(this.#Po)return void this.hideDropdown();if(this.#xo=0===e.detail,this.#Oo||(this.#Oo=new AbortController,window.addEventListener("pointerdown",this.#s.bind(this),{signal:this.#v.combinedSignal(this.#Oo)})),this.#ko)return void this.#ko.classList.remove("hidden");const t=this.#ko=this.#_o();this.#Co.append(t)}#s(e){this.#ko?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#ko?.classList.add("hidden"),this.#Oo?.abort(),this.#Oo=null}get#Po(){return this.#ko&&!this.#ko.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#So||(this.#Po?(this.hideDropdown(),this.#Co.focus({preventScroll:!0,focusVisible:this.#xo})):this.#o?.unselect())}updateColor(e){if(this.#Lo&&(this.#Lo.style.backgroundColor=e),!this.#ko)return;const t=this.#v.highlightColors.values();for(const n of this.#ko.children)n.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#Co?.remove(),this.#Co=null,this.#Lo=null,this.#ko?.remove(),this.#ko=null}}class vle extends Aoe{#Fo=null;#Io=0;#Bo;#jo=null;#a=null;#Uo=null;#Wo=null;#$o=0;#qo=null;#Go=null;#y=null;#Yo=!1;#fo=null;#Ko;#Xo=null;#Qo="";#to;#Jo="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Hae.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const e=vle.prototype;return Dae(this,"_keyboardManager",new koe([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"}),this.color=e.color||vle._defaultColor,this.#to=e.thickness||vle._defaultThickness,this.#Ko=e.opacity||vle._defaultOpacity,this.#Bo=e.boxes||null,this.#Jo=e.methodOfCreation||"",this.#Qo=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#Yo=!0,this.#Zo(e),this.#ec()):this.#Bo&&(this.#Fo=e.anchorNode,this.#Io=e.anchorOffset,this.#Wo=e.focusNode,this.#$o=e.focusOffset,this.#tc(),this.#ec(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Yo?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#to,methodOfCreation:this.#Jo}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#tc(){const e=new hle(this.#Bo,.001);this.#Go=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Go.box;const t=new hle(this.#Bo,.0025,.001,"ltr"===this._uiManager.direction);this.#Uo=t.getOutlines();const{lastPoint:n}=this.#Uo;this.#fo=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#Zo({highlightOutlines:e,highlightId:t,clipPathId:n}){if(this.#Go=e,this.#Uo=e.getNewOutline(this.#to/2+1.5,.0025),t>=0)this.#y=t,this.#jo=n,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#Xo=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},!0);else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:vle.#nc(this.#Go.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Xo,{bbox:vle.#nc(this.#Uo.box,t),path:{d:this.#Uo.toSVGPath()}})}const[r,a,o,c]=e.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=o,this.height=c;break;case 90:{const[e,t]=this.parentDimensions;this.x=a,this.y=1-r,this.width=o*t/e,this.height=c*e/t;break}case 180:this.x=1-r,this.y=1-a,this.width=o,this.height=c;break;case 270:{const[e,t]=this.parentDimensions;this.x=1-a,this.y=r,this.width=o*t/e,this.height=c*e/t;break}}const{lastPoint:i}=this.#Uo;this.#fo=[(i[0]-r)/o,(i[1]-a)/c]}static initialize(e,t){Aoe.initialize(e,t),vle._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case Vae.HIGHLIGHT_DEFAULT_COLOR:vle._defaultColor=t;break;case Vae.HIGHLIGHT_THICKNESS:vle._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#fo}updateParams(e,t){switch(e){case Vae.HIGHLIGHT_COLOR:this.#_a(t);break;case Vae.HIGHLIGHT_THICKNESS:this.#rc(t)}}static get defaultPropertiesToUpdate(){return[[Vae.HIGHLIGHT_DEFAULT_COLOR,vle._defaultColor],[Vae.HIGHLIGHT_THICKNESS,vle._defaultThickness]]}get propertiesToUpdate(){return[[Vae.HIGHLIGHT_COLOR,this.color||vle._defaultColor],[Vae.HIGHLIGHT_THICKNESS,this.#to||vle._defaultThickness],[Vae.HIGHLIGHT_FREE,this.#Yo]]}#_a(e){const t=(e,t)=>{this.color=e,this.#Ko=t,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:e,"fill-opacity":t}}),this.#a?.updateColor(e)},n=this.color,r=this.#Ko;this.addCommands({cmd:t.bind(this,e,vle._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#rc(e){const t=this.#to,n=e=>{this.#to=e,this.#ac(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#a=new ple({editor:this}),e.addColorPicker(this.#a)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#oc())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#oc())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#cc(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#cc():e&&(this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#ac(e){if(!this.#Yo)return;this.#Zo({highlightOutlines:this.#Go.getNewOutline(e/2)}),this.fixAndSetPosition();const[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#cc(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Xo),this.#Xo=null)}#ec(e=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#jo}=e.drawLayer.draw({bbox:this.#Go.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Ko},rootClass:{highlight:!0,free:this.#Yo},path:{d:this.#Go.toSVGPath()}},!1,!0)),this.#Xo=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Yo},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},this.#Yo),this.#qo&&(this.#qo.style.clipPath=this.#jo))}static#nc([e,t,n,r],a){switch(a){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(e){const{drawLayer:t}=this.parent;let n;this.#Yo?(e=(e-this.rotation+360)%360,n=vle.#nc(this.#Go.box,e)):n=vle.#nc([this.x,this.y,this.width,this.height],e),t.updateProperties(this.#y,{bbox:n,root:{"data-main-rotation":e}}),t.updateProperties(this.#Xo,{bbox:vle.#nc(this.#Uo.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();this.#Qo&&(e.setAttribute("aria-label",this.#Qo),e.setAttribute("role","mark")),this.#Yo?e.classList.add("free"):this.div.addEventListener("keydown",this.#ic.bind(this),{signal:this._uiManager._signal});const t=this.#qo=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#jo;const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),Voe(this,this.#qo,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1}})}#ic(e){vle._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#lc(!0);break;case 1:case 3:this.#lc(!1)}}#lc(e){if(!this.#Fo)return;const t=window.getSelection();e?t.setPosition(this.#Fo,this.#Io):t.setPosition(this.#Wo,this.#$o)}select(){super.select(),this.#Xo&&this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Xo&&(this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{selected:!1}}),this.#Yo||this.#lc(!1))}get _mustFixPosition(){return!this.#Yo}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#Xo,{rootClass:{hidden:!e}}))}#oc(){return this.#Yo?this.rotation:0}#sc(){if(this.#Yo)return null;const[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,a=this.#Bo,o=new Float32Array(8*a.length);let c=0;for(const{x:i,y:l,width:s,height:h}of a){const a=i*e+n,d=(1-l)*t+r;o[c]=o[c+4]=a,o[c+1]=o[c+3]=d,o[c+2]=o[c+6]=a+s*e,o[c+5]=o[c+7]=d-h*t,c+=8}return o}#hc(e){return this.#Go.serialize(e,this.#oc())}static startHighlighting(e,t,{target:n,x:r,y:a}){const{x:o,y:c,width:i,height:l}=n.getBoundingClientRect(),s=new AbortController,h=e.combinedSignal(s),d=t=>{s.abort(),this.#dc(e,t)};window.addEventListener("blur",d,{signal:h}),window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("pointerdown",poe,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",moe,{signal:h}),n.addEventListener("pointermove",this.#uc.bind(this,e),{signal:h}),this._freeHighlight=new ule({x:r,y:a},[o,c,i,l],e.scale,this._defaultThickness/2,t,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#uc(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#dc(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(e,t,n){let r=null;if(e instanceof Jie){const{data:{quadPoints:t,rect:n,rotation:a,id:o,color:c,opacity:i,popupRef:l},parent:{page:{pageNumber:s}}}=e;r=e={annotationType:Hae.HIGHLIGHT,color:Array.from(c),opacity:i,quadPoints:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:a,id:o,deleted:!1,popupRef:l}}else if(e instanceof Qie){const{data:{inkLists:t,rect:n,rotation:a,id:o,color:c,borderStyle:{rawWidth:i},popupRef:l},parent:{page:{pageNumber:s}}}=e;r=e={annotationType:Hae.HIGHLIGHT,color:Array.from(c),thickness:i,inkLists:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:a,id:o,deleted:!1,popupRef:l}}const{color:a,quadPoints:o,inkLists:c,opacity:i}=e,l=await super.deserialize(e,t,n);l.color=Qae.makeHexColor(...a),l.#Ko=i||1,c&&(l.#to=e.thickness),l.annotationElementId=e.id||null,l._initialData=r;const[s,h]=l.pageDimensions,[d,u]=l.pageTranslation;if(o){const e=l.#Bo=[];for(let t=0;t<o.length;t+=8)e.push({x:(o[t]-d)/s,y:1-(o[t+1]-u)/h,width:(o[t+2]-o[t])/s,height:(o[t+1]-o[t+5])/h});l.#tc(),l.#ec(),l.rotate(l.rotation)}else if(c){l.#Yo=!0;const e=c[0],n={x:e[0]-d,y:h-(e[1]-u)},r=new ule(n,[0,0,s,h],1,l.#to/2,!0,.001);for(let t=0,a=e.length;t<a;t+=2)n.x=e[t]-d,n.y=h-(e[t+1]-u),r.add(n);const{id:a,clipPathId:o}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#Zo({highlightOutlines:r.getOutlines(),highlightId:a,clipPathId:o}),l.#ec()}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const t=this.getRect(0,0),n=Aoe._colorManager.convert(this.color),r={annotationType:Hae.HIGHLIGHT,color:n,opacity:this.#Ko,thickness:this.#to,quadPoints:this.#sc(),outlines:this.#hc(t),pageIndex:this.pageIndex,rect:t,rotation:this.#oc(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Ua(r)?null:(r.id=this.annotationElementId,r)}#Ua(e){const{color:t}=this._initialData;return e.color.some(((e,n)=>e!==t[n]))}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class fle{#mc=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,n]of Object.entries(e))this.updateProperty(t,n)}updateSVGProperty(e,t){this.#mc[e]=t}toSVGProperties(){const e=this.#mc;return this.#mc=Object.create(null),{root:e}}reset(){this.#mc=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Rae("Not implemented")}}class zle extends Aoe{#pc=null;#vc;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#fc=null;static#zc=null;static#gc=null;static#yc=NaN;static#Mc=null;static#Ec=null;static#bc=NaN;static _INNER_MARGIN=3;constructor(e){super(e),this.#vc=e.mustBeCommitted||!1,e.drawOutlines&&(this.#Hc(e),this.#ec())}#Hc({drawOutlines:e,drawId:t,drawingOptions:n}){this.#pc=e,this._drawingOptions||=n,t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=this.#Vc(e,this.parent),this.#Cc(e.box)}#Vc(e,t){const{id:n}=t.drawLayer.draw(zle._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){const n=new Set(Object.keys(e));for(const[r,a]of Object.entries(t))n.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){Rae("Not implemented")}static get typesMap(){Rae("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t),this._currentParent&&(zle.#fc.updateProperty(n,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:t}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){const r=this._drawingOptions,a=r[t],o=e=>{r.updateProperty(t,e);const n=this.#pc.updateProperty(t,e);n&&this.#Cc(n),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:o.bind(this,n),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties(this.#pc.getPathResizingSVGProperties(this.#Lc()),{bbox:this.#wc()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties(this.#pc.getPathResizedSVGProperties(this.#Lc()),{bbox:this.#wc()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#wc(e,t)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties(this.#pc.getPathTranslatedSVGProperties(this.#Lc(),this.parentDimensions),{bbox:this.#wc()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#vc&&(this.#vc=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#cc(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.#Cc(this.#pc.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#cc()):e&&(this._uiManager.addShouldRescale(this),this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),t&&this.select()}#cc(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ec(e=this.parent){null!==this._drawId&&this.parent===e||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Vc(this.#pc,e)):this.parent.drawLayer.updateParent(this._drawId,e.drawLayer))}#kc([e,t,n,r]){const{parentDimensions:[a,o],rotation:c}=this;switch(c){case 90:return[t,1-e,n*(o/a),r*(a/o)];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,n*(o/a),r*(a/o)];default:return[e,t,n,r]}}#Lc(){const{x:e,y:t,width:n,height:r,parentDimensions:[a,o],rotation:c}=this;switch(c){case 90:return[1-t,e,n*(a/o),r*(o/a)];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,n*(a/o),r*(o/a)];default:return[e,t,n,r]}}#Cc(e){if([this.x,this.y,this.width,this.height]=this.#kc(e),this.div){this.fixAndSetPosition();const[e,t]=this.parentDimensions;this.setDims(this.width*e,this.height*t)}this._onResized()}#wc(){const{x:e,y:t,width:n,height:r,rotation:a,parentRotation:o,parentDimensions:[c,i]}=this;switch((4*a+o)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-n*(c/i),r*(i/c),n*(c/i)];case 5:return[1-t,e,n*(c/i),r*(i/c)];case 6:return[1-e-r*(i/c),1-t,r*(i/c),n*(c/i)];case 7:return[t-n*(c/i),1-e-r*(i/c),n*(c/i),r*(i/c)];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-r*(i/c),t,r*(i/c),n*(c/i)];case 13:return[1-t-n*(c/i),e-r*(i/c),n*(c/i),r*(i/c)];case 14:return[1-e,1-t-n*(c/i),r*(i/c),n*(c/i)];case 15:return[t,1-e,n*(c/i),r*(i/c)];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties({bbox:this.#wc()},this.#pc.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Cc(this.#pc.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const t=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal";const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,t,n,r,a){Rae("Not implemented")}static startDrawing(e,t,n,r){const{target:a,offsetX:o,offsetY:c,pointerId:i,pointerType:l}=r;if(zle.#Mc&&zle.#Mc!==l)return;const{viewport:{rotation:s}}=e,{width:h,height:d}=a.getBoundingClientRect(),u=zle.#zc=new AbortController,m=e.combinedSignal(u);zle.#yc||=i,zle.#Mc??=l,window.addEventListener("pointerup",(e=>{zle.#yc===e.pointerId?this._endDraw(e):zle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointercancel",(e=>{zle.#yc===e.pointerId?this._currentParent.endDrawingSession():zle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointerdown",(e=>{zle.#Mc===e.pointerType&&((zle.#Ec||=new Set).add(e.pointerId),zle.#fc.isCancellable()&&(zle.#fc.removeLastElement(),zle.#fc.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",moe,{signal:m}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),a.addEventListener("touchmove",(e=>{e.timeStamp===zle.#bc&&poe(e)}),{signal:m}),e.toggleDrawing(),t._editorUndoBar?.hide(),zle.#fc?e.drawLayer.updateProperties(this._currentDrawId,zle.#fc.startNew(o,c,h,d,s)):(t.updateUIForDefaultProperties(this),zle.#fc=this.createDrawerInstance(o,c,h,d,s),zle.#gc=this.getDefaultDrawingOptions(),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(zle.#gc.toSVGProperties(),zle.#fc.defaultSVGProperties),!0,!1)))}static _drawMove(e){if(zle.#bc=-1,!zle.#fc)return;const{offsetX:t,offsetY:n,pointerId:r}=e;zle.#yc===r&&(zle.#Ec?.size>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,zle.#fc.add(t,n)),zle.#bc=e.timeStamp,poe(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,zle.#fc=null,zle.#gc=null,zle.#Mc=null,zle.#bc=NaN),zle.#zc&&(zle.#zc.abort(),zle.#zc=null,zle.#yc=NaN,zle.#Ec=null)}static _endDraw(e){const t=this._currentParent;if(t)if(t.toggleDrawing(!0),this._cleanup(!1),e&&t.drawLayer.updateProperties(this._currentDrawId,zle.#fc.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=zle.#fc,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:Vae.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(e){const t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(Vae.DRAW_STEP),!zle.#fc.isEmpty()){const{pageDimensions:[n,r],scale:a}=t,o=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:zle.#fc.getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:zle.#gc,mustBeCommitted:!e});return this._cleanup(!0),o}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,a,o){Rae("Not implemented")}static async deserialize(e,t,n){const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:c}}=t.viewport,i=this.deserializeDraw(o,c,r,a,this._INNER_MARGIN,e),l=await super.deserialize(e,t,n);return l.createDrawingOptions(e),l.#Hc({drawOutlines:i}),l.#ec(),l.onScaleChanging(),l.rotate(),l}serializeDraw(e){const[t,n]=this.pageTranslation,[r,a]=this.pageDimensions;return this.#pc.serialize([t,n,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class gle{#Ka=new Float64Array(6);#za;#xc;#Rn;#to;#no;#Sc="";#Tc=0;#Vo=new yle;#Oc;#Ac;constructor(e,t,n,r,a,o){this.#Oc=n,this.#Ac=r,this.#Rn=a,this.#to=o,[e,t]=this.#Rc(e,t);const c=this.#za=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t],this.#xc=[{line:c,points:this.#no}],this.#Ka.set(c,0)}updateProperty(e,t){"stroke-width"===e&&(this.#to=t)}#Rc(e,t){return ile._normalizePoint(e,t,this.#Oc,this.#Ac,this.#Rn)}isEmpty(){return!this.#xc||0===this.#xc.length}isCancellable(){return this.#no.length<=10}add(e,t){[e,t]=this.#Rc(e,t);const[n,r,a,o]=this.#Ka.subarray(2,6),c=e-a,i=t-o;return Math.hypot(this.#Oc*c,this.#Ac*i)<=2?null:(this.#no.push(e,t),isNaN(n)?(this.#Ka.set([a,o,e,t],2),this.#za.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#Ka[0])&&this.#za.splice(6,6),this.#Ka.set([n,r,a,o,e,t],0),this.#za.push(...ile.createBezierPoints(n,r,a,o,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(2===this.#no.length?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,a){this.#Oc=n,this.#Ac=r,this.#Rn=a,[e,t]=this.#Rc(e,t);const o=this.#za=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t];const c=this.#xc.at(-1);return c&&(c.line=new Float32Array(c.line),c.points=new Float32Array(c.points)),this.#xc.push({line:o,points:this.#no}),this.#Ka.set(o,0),this.#Tc=0,this.toSVGPath(),null}getLastElement(){return this.#xc.at(-1)}setLastElement(e){return this.#xc?(this.#xc.push(e),this.#za=e.line,this.#no=e.points,this.#Tc=0,{path:{d:this.toSVGPath()}}):this.#Vo.setLastElement(e)}removeLastElement(){if(!this.#xc)return this.#Vo.removeLastElement();this.#xc.pop(),this.#Sc="";for(let e=0,t=this.#xc.length;e<t;e++){const{line:t,points:n}=this.#xc[e];this.#za=t,this.#no=n,this.#Tc=0,this.toSVGPath()}return{path:{d:this.#Sc}}}toSVGPath(){const e=ile.svgRound(this.#za[4]),t=ile.svgRound(this.#za[5]);if(2===this.#no.length)return this.#Sc=`${this.#Sc} M ${e} ${t} Z`,this.#Sc;if(this.#no.length<=6){const n=this.#Sc.lastIndexOf("M");this.#Sc=`${this.#Sc.slice(0,n)} M ${e} ${t}`,this.#Tc=6}if(4===this.#no.length){const e=ile.svgRound(this.#za[10]),t=ile.svgRound(this.#za[11]);return this.#Sc=`${this.#Sc} L ${e} ${t}`,this.#Tc=12,this.#Sc}const n=[];0===this.#Tc&&(n.push(`M ${e} ${t}`),this.#Tc=6);for(let e=this.#Tc,t=this.#za.length;e<t;e+=6){const[t,r,a,o,c,i]=this.#za.slice(e,e+6).map(ile.svgRound);n.push(`C${t} ${r} ${a} ${o} ${c} ${i}`)}return this.#Sc+=n.join(" "),this.#Tc=this.#za.length,this.#Sc}getOutlines(e,t,n,r){const a=this.#xc.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#Vo.build(this.#xc,e,t,n,this.#Rn,this.#to,r),this.#Ka=null,this.#za=null,this.#xc=null,this.#Sc=null,this.#Vo}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class yle extends ile{#mo;#Nc=0;#qa;#xc;#Oc;#Ac;#_c;#Rn;#to;build(e,t,n,r,a,o,c){this.#Oc=t,this.#Ac=n,this.#_c=r,this.#Rn=a,this.#to=o,this.#qa=c??0,this.#xc=e,this.#Dc()}setLastElement(e){return this.#xc.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#xc.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:t}of this.#xc)if(e.push(`M${ile.svgRound(t[4])} ${ile.svgRound(t[5])}`),6!==t.length)if(12!==t.length)for(let n=6,r=t.length;n<r;n+=6){const[r,a,o,c,i,l]=t.subarray(n,n+6).map(ile.svgRound);e.push(`C${r} ${a} ${o} ${c} ${i} ${l}`)}else e.push(`L${ile.svgRound(t[10])} ${ile.svgRound(t[11])}`);else e.push("Z");return e.join("")}serialize([e,t,n,r],a){const o=[],c=[],[i,l,s,h]=this.#Pc();let d,u,m,p,v,f,z,g,y;switch(this.#Rn){case 0:y=ile._rescale,d=e,u=t+r,m=n,p=-r,v=e+i*n,f=t+(1-l-h)*r,z=e+(i+s)*n,g=t+(1-l)*r;break;case 90:y=ile._rescaleAndSwap,d=e,u=t,m=n,p=r,v=e+l*n,f=t+i*r,z=e+(l+h)*n,g=t+(i+s)*r;break;case 180:y=ile._rescale,d=e+n,u=t,m=-n,p=r,v=e+(1-i-s)*n,f=t+l*r,z=e+(1-i)*n,g=t+(l+h)*r;break;case 270:y=ile._rescaleAndSwap,d=e+n,u=t+r,m=-n,p=-r,v=e+(1-l-h)*n,f=t+(1-i-s)*r,z=e+(1-l)*n,g=t+(1-i)*r}for(const{line:e,points:t}of this.#xc)o.push(y(e,d,u,m,p,a?new Array(e.length):null)),c.push(y(t,d,u,m,p,a?new Array(t.length):null));return{lines:o,points:c,rect:[v,f,z,g]}}static deserialize(e,t,n,r,a,{paths:{lines:o,points:c},rotation:i,thickness:l}){const s=[];let h,d,u,m,p;switch(i){case 0:p=ile._rescale,h=-e/n,d=t/r+1,u=1/n,m=-1/r;break;case 90:p=ile._rescaleAndSwap,h=-t/r,d=-e/n,u=1/r,m=1/n;break;case 180:p=ile._rescale,h=e/n+1,d=-t/r,u=-1/n,m=1/r;break;case 270:p=ile._rescaleAndSwap,h=t/r+1,d=e/n+1,u=-1/r,m=-1/n}if(!o){o=[];for(const e of c){const t=e.length;if(2===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const n=new Float32Array(3*(t-2));o.push(n);let[r,a,c,i]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,a],0);for(let o=4;o<t;o+=2){const t=e[o],l=e[o+1];n.set(ile.createBezierPoints(r,a,c,i,t,l),3*(o-2)),[r,a,c,i]=[c,i,t,l]}}}for(let e=0,t=o.length;e<t;e++)s.push({line:p(o[e].map((e=>e??NaN)),h,d,u,m),points:p(c[e].map((e=>e??NaN)),h,d,u,m)});const v=new yle;return v.build(s,n,r,1,i,l,a),v}#Fc(e=this.#to){const t=this.#qa+e/2*this.#_c;return this.#Rn%180==0?[t/this.#Oc,t/this.#Ac]:[t/this.#Ac,t/this.#Oc]}#Pc(){const[e,t,n,r]=this.#mo,[a,o]=this.#Fc(0);return[e+a,t+o,n-2*a,r-2*o]}#Dc(){const e=this.#mo=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:t}of this.#xc){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6){const[r,a]=t.subarray(n,n+2);e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],a),e[2]=Math.max(e[2],r),e[3]=Math.max(e[3],a)}continue}let n=t[4],r=t[5];for(let a=6,o=t.length;a<o;a+=6){const[o,c,i,l,s,h]=t.subarray(a,a+6);Qae.bezierBoundingBox(n,r,o,c,i,l,s,h,e),n=s,r=h}}const[t,n]=this.#Fc();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-n)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+n)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#mo}updateProperty(e,t){return"stroke-width"===e?this.#rc(t):null}#rc(e){const[t,n]=this.#Fc();this.#to=e;const[r,a]=this.#Fc(),[o,c]=[r-t,a-n],i=this.#mo;return i[0]-=o,i[1]-=c,i[2]+=2*o,i[3]+=2*c,i}updateParentDimensions([e,t],n){const[r,a]=this.#Fc();this.#Oc=e,this.#Ac=t,this.#_c=n;const[o,c]=this.#Fc(),i=o-r,l=c-a,s=this.#mo;return s[0]-=i,s[1]-=l,s[2]+=2*i,s[3]+=2*l,s}updateRotation(e){return this.#Nc=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#mo.map(ile.svgRound).join(" ")}get defaultProperties(){const[e,t]=this.#mo;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`}}}get rotationTransform(){const[,,e,t]=this.#mo;let n=0,r=0,a=0,o=0,c=0,i=0;switch(this.#Nc){case 90:r=t/e,a=-e/t,c=e;break;case 180:n=-1,o=-1,c=e,i=t;break;case 270:r=-t/e,a=e/t,i=t;break;default:return""}return`matrix(${n} ${r} ${a} ${o} ${ile.svgRound(c)} ${ile.svgRound(i)})`}getPathResizingSVGProperties([e,t,n,r]){const[a,o]=this.#Fc(),[c,i,l,s]=this.#mo;if(Math.abs(l-a)<=ile.PRECISION||Math.abs(s-o)<=ile.PRECISION){const a=e+n/2-(c+l/2),o=t+r/2-(i+s/2);return{path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`,transform:`${this.rotationTransform} translate(${a} ${o})`}}}const h=(n-2*a)/(l-2*a),d=(r-2*o)/(s-2*o),u=l/n,m=s/r;return{path:{"transform-origin":`${ile.svgRound(c)} ${ile.svgRound(i)}`,transform:`${this.rotationTransform} scale(${u} ${m}) translate(${ile.svgRound(a)} ${ile.svgRound(o)}) scale(${h} ${d}) translate(${ile.svgRound(-a)} ${ile.svgRound(-o)})`}}}getPathResizedSVGProperties([e,t,n,r]){const[a,o]=this.#Fc(),c=this.#mo,[i,l,s,h]=c;if(c[0]=e,c[1]=t,c[2]=n,c[3]=r,Math.abs(s-a)<=ile.PRECISION||Math.abs(h-o)<=ile.PRECISION){const a=e+n/2-(i+s/2),o=t+r/2-(l+h/2);for(const{line:e,points:t}of this.#xc)ile._translate(e,a,o,e),ile._translate(t,a,o,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(n-2*a)/(s-2*a),u=(r-2*o)/(h-2*o),m=-d*(i+a)+e+a,p=-u*(l+o)+t+o;if(1!==d||1!==u||0!==m||0!==p)for(const{line:e,points:t}of this.#xc)ile._rescale(e,m,p,d,u,e),ile._rescale(t,m,p,d,u,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){const[r,a]=n,o=this.#mo,c=e-o[0],i=t-o[1];if(this.#Oc===r&&this.#Ac===a)for(const{line:e,points:t}of this.#xc)ile._translate(e,c,i,e),ile._translate(t,c,i,t);else{const e=this.#Oc/r,t=this.#Ac/a;this.#Oc=r,this.#Ac=a;for(const{line:n,points:r}of this.#xc)ile._rescale(n,c,i,e,t,n),ile._rescale(r,c,i,e,t,r);o[2]*=e,o[3]*=t}return o[0]=e,o[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`}}}get defaultSVGProperties(){const e=this.#mo;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ile.svgRound(e[0])} ${ile.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Mle extends fle{#Ic;constructor(e){super(),this.#Ic=e,super.updateProperties({fill:"none",stroke:Aoe._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){"stroke-width"===e&&(t??=this["stroke-width"],t*=this.#Ic.realScale),super.updateSVGProperty(e,t)}clone(){const e=new Mle(this.#Ic);return e.updateAll(this),e}}class Ele extends zle{static _type="ink";static _editorType=Hae.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(e,t){Aoe.initialize(e,t),this._defaultDrawingOptions=new Mle(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return Dae(this,"typesMap",new Map([[Vae.INK_THICKNESS,"stroke-width"],[Vae.INK_COLOR,"stroke"],[Vae.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,n,r,a){return new gle(e,t,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,n,r,a,o){return yle.deserialize(e,t,n,r,a,o)}static async deserialize(e,t,n){let r=null;if(e instanceof Qie){const{data:{inkLists:t,rect:n,rotation:a,id:o,color:c,opacity:i,borderStyle:{rawWidth:l},popupRef:s},parent:{page:{pageNumber:h}}}=e;r=e={annotationType:Hae.INK,color:Array.from(c),thickness:l,opacity:i,paths:{points:t},boxes:null,pageIndex:h-1,rect:n.slice(0),rotation:a,id:o,deleted:!1,popupRef:s}}const a=await super.deserialize(e,t,n);return a.annotationElementId=e.id||null,a._initialData=r,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Ele.getDefaultDrawingOptions({stroke:Qae.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:t,points:n,rect:r}=this.serializeDraw(e),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":c}}=this,i={annotationType:Hae.INK,color:Aoe._colorManager.convert(a),opacity:o,thickness:c,paths:{lines:t,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?i:this.annotationElementId&&!this.#Ua(i)?null:(i.id=this.annotationElementId,i)}#Ua(e){const{color:t,thickness:n,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some(((e,n)=>e!==t[n]))||e.thickness!==n||e.opacity!==r||e.pageIndex!==a}renderAnnotationElement(e){const{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:t}),null}}class ble extends Aoe{#Bc=null;#jc=null;#Uc=null;#Wc=null;#$c=null;#qc="";#Gc=null;#Yc=null;#Kc=!1;#Xc=!1;static _type="stamp";static _editorType=Hae.STAMP;constructor(e){super({...e,name:"stampEditor"}),this.#Wc=e.bitmapUrl,this.#$c=e.bitmapFile}static initialize(e,t){Aoe.initialize(e,t)}static get supportedTypes(){return Dae(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((e=>`image/${e}`)))}static get supportedTypesStr(){return Dae(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(Hae.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#Qc(e,t=!1){e?(this.#Bc=e.bitmap,t||(this.#jc=e.id,this.#Kc=e.isSvg),e.file&&(this.#qc=e.file.name),this.#Jc()):this.remove()}#Zc(){if(this.#Uc=null,this._uiManager.enableWaiting(!1),this.#Gc){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Bc)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Bc){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,c=await n.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const i=c.output;return await this.setGuessedAltText(i),t&&!this.hasAltTextData()&&(this.altTextData={alt:i,decorative:!1}),i}#ei(){if(this.#jc)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#jc).then((e=>this.#Qc(e,!0))).finally((()=>this.#Zc()));if(this.#Wc){const e=this.#Wc;return this.#Wc=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromUrl(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}if(this.#$c){const e=this.#$c;return this.#$c=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromFile(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}const e=document.createElement("input");e.type="file",e.accept=ble.supportedTypesStr;const t=this._uiManager._signal;this.#Uc=new Promise((n=>{e.addEventListener("change",(async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qc(t)}else this.remove();n()}),{signal:t}),e.addEventListener("cancel",(()=>{this.remove(),n()}),{signal:t})})).finally((()=>this.#Zc())),e.click()}remove(){this.#jc&&(this.#Bc=null,this._uiManager.imageManager.deleteId(this.#jc),this.#Gc?.remove(),this.#Gc=null,this.#Yc&&(clearTimeout(this.#Yc),this.#Yc=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#jc&&null===this.#Gc&&this.#ei(),this.isAttachedToDOM||this.parent.add(this))):this.#jc&&this.#ei()}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#Uc||this.#Bc||this.#Wc||this.#$c||this.#jc)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Bc?this.#Jc():this.#ei(),this.width&&!this.annotationElementId){const[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#Yc&&clearTimeout(this.#Yc),this.#Yc=setTimeout((()=>{this.#Yc=null,this.#ti()}),200))}#Jc(){const{div:e}=this;let{width:t,height:n}=this.#Bc;const[r,a]=this.pageDimensions,o=.75;if(this.width)t=this.width*r,n=this.height*a;else if(t>o*r||n>o*a){const e=Math.min(o*r/t,o*a/n);t*=e,n*=e}const[c,i]=this.parentDimensions;this.setDims(t*c/r,n*i/a),this._uiManager.enableWaiting(!1);const l=this.#Gc=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=t/r,this.height=n/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),this.#ti(),this.#Xc||(this.parent.addUndoableEditor(this),this.#Xc=!0),this._reportTelemetry({action:"inserted_image"}),this.#qc&&l.setAttribute("aria-label",this.#qc)}copyCanvas(e,t,n=!1){e||(e=224);const{width:r,height:a}=this.#Bc,o=new Eoe;let c=this.#Bc,i=r,l=a,s=null;if(t){if(r>t||a>t){const e=Math.min(t/r,t/a);i=Math.floor(r*e),l=Math.floor(a*e)}s=document.createElement("canvas");const e=s.width=Math.ceil(i*o.sx),n=s.height=Math.ceil(l*o.sy);this.#Kc||(c=this.#ni(e,n));const h=s.getContext("2d");h.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const m=15,p=m*o.sx,v=m*o.sy,f=new OffscreenCanvas(2*p,2*v),z=f.getContext("2d");z.fillStyle=d,z.fillRect(0,0,2*p,2*v),z.fillStyle=u,z.fillRect(0,0,p,v),z.fillRect(p,v,p,v),h.fillStyle=h.createPattern(f,"repeat"),h.fillRect(0,0,e,n),h.drawImage(c,0,0,c.width,c.height,0,0,e,n)}let h=null;if(n){let t,n;if(o.symmetric&&c.width<e&&c.height<e)t=c.width,n=c.height;else if(c=this.#Bc,r>e||a>e){const o=Math.min(e/r,e/a);t=Math.floor(r*o),n=Math.floor(a*o),this.#Kc||(c=this.#ni(t,n))}const i=new OffscreenCanvas(t,n).getContext("2d",{willReadFrequently:!0});i.drawImage(c,0,0,c.width,c.height,0,0,t,n),h={width:t,height:n,data:i.getImageData(0,0,t,n).data}}return{canvas:s,width:i,height:l,imageData:h}}#ni(e,t){const{width:n,height:r}=this.#Bc;let a=n,o=r,c=this.#Bc;for(;a>2*e||o>2*t;){const n=a,r=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const i=new OffscreenCanvas(a,o);i.getContext("2d").drawImage(c,0,0,n,r,0,0,a,o),c=i.transferToImageBitmap()}return c}#ti(){const[e,t]=this.parentDimensions,{width:n,height:r}=this,a=new Eoe,o=Math.ceil(n*e*a.sx),c=Math.ceil(r*t*a.sy),i=this.#Gc;if(!i||i.width===o&&i.height===c)return;i.width=o,i.height=c;const l=this.#Kc?this.#Bc:this.#ni(o,c),s=i.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(l,0,0,l.width,l.height,0,0,o,c)}getImageForAltText(){return this.#Gc}#ri(e){if(e){if(this.#Kc){const e=this._uiManager.imageManager.getSvgUrl(this.#jc);if(e)return e}const e=document.createElement("canvas");return({width:e.width,height:e.height}=this.#Bc),e.getContext("2d").drawImage(this.#Bc,0,0),e.toDataURL()}if(this.#Kc){const[e,t]=this.pageDimensions,n=Math.round(this.width*e*roe.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*roe.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(n,r);return a.getContext("2d").drawImage(this.#Bc,0,0,this.#Bc.width,this.#Bc.height,0,0,n,r),a.transferToImageBitmap()}return structuredClone(this.#Bc)}static async deserialize(e,t,n){let r=null;if(e instanceof nle){const{data:{rect:a,rotation:o,id:c,structParent:i,popupRef:l},container:s,parent:{page:{pageNumber:h}}}=e,d=s.querySelector("canvas"),u=n.imageManager.getFromCanvas(s.id,d);d.remove();const m=(await t._structTree.getAriaAttributes(`${toe}${c}`))?.get("aria-label")||"";r=e={annotationType:Hae.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:h-1,rect:a.slice(0),rotation:o,id:c,deleted:!1,accessibilityData:{decorative:!1,altText:m},isSvg:!1,structParent:i,popupRef:l}}const a=await super.deserialize(e,t,n),{rect:o,bitmap:c,bitmapUrl:i,bitmapId:l,isSvg:s,accessibilityData:h}=e;l&&n.imageManager.isValidId(l)?(a.#jc=l,c&&(a.#Bc=c)):a.#Wc=i,a.#Kc=s;const[d,u]=a.pageDimensions;return a.width=(o[2]-o[0])/d,a.height=(o[3]-o[1])/u,a.annotationElementId=e.id||null,h&&(a.altTextData=h),a._initialData=r,a.#Xc=!!r,a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n={annotationType:Hae.STAMP,bitmapId:this.#jc,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Kc,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#ri(!0),n.accessibilityData=this.serializeAltText(!0),n;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(n.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const e=this.#Ua(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,null===t)return n;t.stamps||=new Map;const o=this.#Kc?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#jc)){if(this.#Kc){const e=t.stamps.get(this.#jc);o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=this.#ri(!1))}}else t.stamps.set(this.#jc,{area:o,serialized:n}),n.bitmap=this.#ri(!1);return n}#Ua(e){const{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,a=(e.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}}class Hle{#La;#ai=!1;#oi=null;#ci=null;#ii=null;#li=new Map;#si=!1;#hi=!1;#di=!1;#ui=null;#mi=null;#pi=null;#vi=null;#v;static _initialized=!1;static#B=new Map([cle,Ele,ble,vle].map((e=>[e._editorType,e])));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:r,accessibilityManager:a,annotationLayer:o,drawLayer:c,textLayer:i,viewport:l,l10n:s}){const h=[...Hle.#B.values()];if(!Hle._initialized){Hle._initialized=!0;for(const t of h)t.initialize(s,e)}e.registerEditorTypes(h),this.#v=e,this.pageIndex=t,this.div=n,this.#La=a,this.#oi=o,this.viewport=l,this.#pi=i,this.drawLayer=c,this._structTree=r,this.#v.addLayer(this)}get isEmpty(){return 0===this.#li.size}get isInvisible(){return this.isEmpty&&this.#v.getMode()===Hae.NONE}updateToolbar(e){this.#v.updateToolbar(e)}updateMode(e=this.#v.getMode()){switch(this.#fi(),e){case Hae.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Hae.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Hae.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const n of Hle.#B.values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#pi?.div}setEditingState(e){this.#v.setEditingState(e)}addCommands(e){this.#v.addCommands(e)}cleanUndoStack(e){this.#v.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#oi?.div.classList.toggle("disabled",!e)}async enable(){this.#di=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const t of this.#li.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#v.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!this.#oi)return void(this.#di=!1);const t=this.#oi.getEditableAnnotations();for(const n of t){if(n.hide(),this.#v.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;const t=await this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}this.#di=!1}disable(){this.#hi=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const n of this.#li.values())n.disableEditing(),n.annotationElementId&&(null===n.serialize()?(t.set(n.annotationElementId,n),this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()):e.set(n.annotationElementId,n));if(this.#oi){const n=this.#oi.getEditableAnnotations();for(const r of n){const{id:n}=r.data;if(this.#v.isDeletedAnnotationElement(n))continue;let a=t.get(n);a?(a.resetAnnotationElement(r),a.show(!1),r.show()):(a=e.get(n),a&&(this.#v.addChangedExistingAnnotation(a),a.renderAnnotationElement(r)&&a.show(!1)),r.show())}}this.#fi(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const e of Hle.#B.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#hi=!1}getEditableAnnotation(e){return this.#oi?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#v.getActive()!==e&&this.#v.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#pi?.div&&!this.#vi){this.#vi=new AbortController;const e=this.#v.combinedSignal(this.#vi);this.#pi.div.addEventListener("pointerdown",this.#zi.bind(this),{signal:e}),this.#pi.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#pi?.div&&this.#vi&&(this.#vi.abort(),this.#vi=null,this.#pi.div.classList.remove("highlighting"))}#zi(e){this.#v.unselectAll();const{target:t}=e;if(t===this.#pi.div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent"))&&this.#pi.div.contains(t)){const{isMac:t}=Kae.platform;if(0!==e.button||e.ctrlKey&&t)return;this.#v.showAllEditors("highlight",!0,!0),this.#pi.div.classList.add("free"),this.toggleDrawing(),vle.startHighlighting(this,"ltr"===this.#v.direction,{target:this.#pi.div,x:e.x,y:e.y}),this.#pi.div.addEventListener("pointerup",(()=>{this.#pi.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#v._signal}),e.preventDefault()}}enableClick(){if(this.#ci)return;this.#ci=new AbortController;const e=this.#v.combinedSignal(this.#ci);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){this.#ci?.abort(),this.#ci=null}attach(e){this.#li.set(e.id,e);const{annotationElementId:t}=e;t&&this.#v.isDeletedAnnotationElement(t)&&this.#v.removeDeletedAnnotationElement(e)}detach(e){this.#li.delete(e.id),this.#La?.removePointerInTextLayer(e.contentDiv),!this.#hi&&e.annotationElementId&&this.#v.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#v.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#v.addDeletedAnnotationElement(e.annotationElementId),Aoe.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),this.#v.addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#di),this.#v.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!this.#ii&&(e._focusEventsAllowed=!1,this.#ii=setTimeout((()=>{this.#ii=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this.#v._signal}),t.focus())}),0)),e._structTreeParentId=this.#La?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#v.getId()}get#gi(){return Hle.#B.get(this.#v.getMode())}combinedSignal(e){return this.#v.combinedSignal(e)}#yi(e){const t=this.#gi;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#gi?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#v.updateToolbar(e),this.#v.updateMode(e);const{offsetX:n,offsetY:r}=this.#Mi(),a=this.getNextId(),o=this.#yi({parent:this,id:a,x:n,y:r,uiManager:this.#v,isCentered:!0,...t});o&&this.add(o)}async deserialize(e){return await(Hle.#B.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#v))||null}createAndAddNewEditor(e,t,n={}){const r=this.getNextId(),a=this.#yi({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#v,isCentered:t,...n});return a&&this.add(a),a}#Mi(){const{x:e,y:t,width:n,height:r}=this.div.getBoundingClientRect(),a=Math.max(0,e),o=Math.max(0,t),c=(a+Math.min(window.innerWidth,e+n))/2-e,i=(o+Math.min(window.innerHeight,t+r))/2-t,[l,s]=this.viewport.rotation%180==0?[c,i]:[i,c];return{offsetX:l,offsetY:s}}addNewEditor(){this.createAndAddNewEditor(this.#Mi(),!0)}setSelected(e){this.#v.setSelected(e)}toggleSelected(e){this.#v.toggleSelected(e)}unselect(e){this.#v.unselect(e)}pointerup(e){const{isMac:t}=Kae.platform;0!==e.button||e.ctrlKey&&t||e.target===this.div&&this.#si&&(this.#si=!1,this.#gi?.isDrawer&&this.#gi.supportMultipleDrawings||(this.#ai?this.#v.getMode()!==Hae.STAMP?this.createAndAddNewEditor(e,!1):this.#v.unselectAll():this.#ai=!0))}pointerdown(e){if(this.#v.getMode()===Hae.HIGHLIGHT&&this.enableTextSelection(),this.#si)return void(this.#si=!1);const{isMac:t}=Kae.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(this.#si=!0,this.#gi?.isDrawer)return void this.startDrawingSession(e);const n=this.#v.getActive();this.#ai=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus(),this.#ui)return void this.#gi.startDrawing(this,this.#v,!1,e);this.#v.setCurrentDrawingSession(this),this.#ui=new AbortController;const t=this.#v.combinedSignal(this.#ui);this.div.addEventListener("blur",(({relatedTarget:e})=>{e&&!this.div.contains(e)&&(this.#mi=null,this.commitOrRemove())}),{signal:t}),this.#gi.startDrawing(this,this.#v,!1,e)}pause(e){if(e){const{activeElement:e}=document;this.div.contains(e)&&(this.#mi=e)}else this.#mi&&setTimeout((()=>{this.#mi?.focus(),this.#mi=null}),0)}endDrawingSession(e=!1){return this.#ui?(this.#v.setCurrentDrawingSession(null),this.#ui.abort(),this.#ui=null,this.#mi=null,this.#gi.endDrawing(e)):null}findNewParent(e,t,n){const r=this.#v.findParent(t,n);return null!==r&&r!==this&&(r.changeParent(e),!0)}commitOrRemove(){return!!this.#ui&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#ui&&this.#gi.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#v.getActive()?.parent===this&&(this.#v.commitOrRemove(),this.#v.setActiveEditor(null)),this.#ii&&(clearTimeout(this.#ii),this.#ii=null);for(const e of this.#li.values())this.#La?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#li.clear(),this.#v.removeLayer(this)}#fi(){for(const e of this.#li.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,Moe(this.div,e);for(const e of this.#v.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:e}){this.#v.commitOrRemove(),this.#fi();const t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Moe(this.div,{rotation:n}),t!==n)for(const e of this.#li.values())e.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#v.viewParameters.realScale}}class Vle{#aa=null;#y=0;#Ei=new Map;#bi=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(this.#aa){if(this.#aa!==e){if(this.#Ei.size>0)for(const t of this.#Ei.values())t.remove(),e.append(t);this.#aa=e}}else this.#aa=e}static get _svgFactory(){return Dae(this,"_svgFactory",new Lie)}static#Hi(e,[t,n,r,a]){const{style:o}=e;o.top=100*n+"%",o.left=100*t+"%",o.width=100*r+"%",o.height=100*a+"%"}#Vi(){const e=Vle._svgFactory.create(1,1,!0);return this.#aa.append(e),e.setAttribute("aria-hidden",!0),e}#Ci(e,t){const n=Vle._svgFactory.createElement("clipPath");e.append(n);const r=`clip_${t}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");const a=Vle._svgFactory.createElement("use");return n.append(a),a.setAttribute("href",`#${t}`),a.classList.add("clip"),r}#Li(e,t){for(const[n,r]of Object.entries(t))null===r?e.removeAttribute(n):e.setAttribute(n,r)}draw(e,t=!1,n=!1){const r=this.#y++,a=this.#Vi(),o=Vle._svgFactory.createElement("defs");a.append(o);const c=Vle._svgFactory.createElement("path");o.append(c);const i=`path_p${this.pageIndex}_${r}`;c.setAttribute("id",i),c.setAttribute("vector-effect","non-scaling-stroke"),t&&this.#bi.set(r,c);const l=n?this.#Ci(o,i):null,s=Vle._svgFactory.createElement("use");return a.append(s),s.setAttribute("href",`#${i}`),this.updateProperties(a,e),this.#Ei.set(r,a),{id:r,clipPathId:`url(#${l})`}}drawOutline(e,t){const n=this.#y++,r=this.#Vi(),a=Vle._svgFactory.createElement("defs");r.append(a);const o=Vle._svgFactory.createElement("path");a.append(o);const c=`path_p${this.pageIndex}_${n}`;let i;if(o.setAttribute("id",c),o.setAttribute("vector-effect","non-scaling-stroke"),t){const e=Vle._svgFactory.createElement("mask");a.append(e),i=`mask_p${this.pageIndex}_${n}`,e.setAttribute("id",i),e.setAttribute("maskUnits","objectBoundingBox");const t=Vle._svgFactory.createElement("rect");e.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const r=Vle._svgFactory.createElement("use");e.append(r),r.setAttribute("href",`#${c}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}const l=Vle._svgFactory.createElement("use");r.append(l),l.setAttribute("href",`#${c}`),i&&l.setAttribute("mask",`url(#${i})`);const s=l.cloneNode();return r.append(s),l.classList.add("mainOutline"),s.classList.add("secondaryOutline"),this.updateProperties(r,e),this.#Ei.set(n,r),n}finalizeDraw(e,t){this.#bi.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const{root:n,bbox:r,rootClass:a,path:o}=t,c="number"==typeof e?this.#Ei.get(e):e;if(c){if(n&&this.#Li(c,n),r&&Vle.#Hi(c,r),a){const{classList:e}=c;for(const[t,n]of Object.entries(a))e.toggle(t,n)}if(o){const e=c.firstChild.firstChild;this.#Li(e,o)}}}updateParent(e,t){if(t===this)return;const n=this.#Ei.get(e);n&&(t.#aa.append(n),this.#Ei.delete(e),t.#Ei.set(e,n))}remove(e){this.#bi.delete(e),null!==this.#aa&&(this.#Ei.get(e).remove(),this.#Ei.delete(e))}destroy(){this.#aa=null;for(const e of this.#Ei.values())e.remove();this.#Ei.clear(),this.#bi.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:hle};var Cle=zae.GlobalWorkerOptions,Lle=zae.TextLayer,wle=zae.getDocument;function kle(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}kle('.messageBar{--closing-button-icon:url(images/messageBar_closingButton.svg);--message-bar-close-button-color:var(--text-primary-color);--message-bar-close-button-color-hover:var(--text-primary-color);--message-bar-close-button-border-radius:4px;--message-bar-close-button-border:none;--message-bar-close-button-hover-bg-color:#15141a24;--message-bar-close-button-active-bg-color:#15141a36;--message-bar-close-button-focus-bg-color:#15141a12}@media (prefers-color-scheme:dark){.messageBar{--message-bar-close-button-hover-bg-color:#fbfbfe24;--message-bar-close-button-active-bg-color:#fbfbfe36;--message-bar-close-button-focus-bg-color:#fbfbfe12}}@media screen and (forced-colors:active){.messageBar{--message-bar-close-button-color:ButtonText;--message-bar-close-button-border:1px solid ButtonText;--message-bar-close-button-hover-bg-color:ButtonText;--message-bar-close-button-active-bg-color:ButtonText;--message-bar-close-button-focus-bg-color:ButtonText;--message-bar-close-button-color-hover:HighlightText}}.messageBar{align-items:center;background:var(--message-bar-bg-color);border:1px solid var(--message-bar-border-color);border-radius:4px;color:var(--message-bar-fg-color);display:flex;flex-direction:column;gap:8px;justify-content:center;padding:8px 8px 8px 16px;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none}.messageBar>div{align-items:flex-start;align-self:stretch;display:flex;gap:8px}:is(.messageBar>div):before{background-color:var(--message-bar-icon-color);content:"";display:inline-block;flex-shrink:0;height:16px;-webkit-mask-image:var(--message-bar-icon);mask-image:var(--message-bar-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}.messageBar button{cursor:pointer}:is(.messageBar button):focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}.messageBar .closeButton{align-items:center;background:none;border:var(--message-bar-close-button-border);border-radius:var(--message-bar-close-button-border-radius);display:flex;height:32px;justify-content:center;width:32px}:is(.messageBar .closeButton):before{background-color:var(--message-bar-close-button-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--closing-button-icon);mask-image:var(--closing-button-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.messageBar .closeButton):is(:hover,:active,:focus):before{background-color:var(--message-bar-close-button-color-hover)}:is(.messageBar .closeButton):hover{background-color:var(--message-bar-close-button-hover-bg-color)}:is(.messageBar .closeButton):active{background-color:var(--message-bar-close-button-active-bg-color)}:is(.messageBar .closeButton):focus{background-color:var(--message-bar-close-button-focus-bg-color)}:is(.messageBar .closeButton)>span{display:inline-block;height:0;overflow:hidden;width:0}#editorUndoBar{--text-primary-color:#15141a;--message-bar-icon:url(images/secondaryToolbarButton-documentProperties.svg);--message-bar-icon-color:#0060df;--message-bar-bg-color:#deeafc;--message-bar-fg-color:var(--text-primary-color);--message-bar-border-color:#00000014;--undo-button-bg-color:#15141a12;--undo-button-bg-color-hover:#15141a24;--undo-button-bg-color-active:#15141a36;--undo-button-fg-color:var(--message-bar-fg-color);--undo-button-fg-color-hover:var(--undo-button-fg-color);--undo-button-fg-color-active:var(--undo-button-fg-color);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color)}@media (prefers-color-scheme:dark){#editorUndoBar{--text-primary-color:#fbfbfe;--message-bar-icon-color:#73a7f3;--message-bar-bg-color:#003070;--message-bar-border-color:#ffffff14;--undo-button-bg-color:#ffffff14;--undo-button-bg-color-hover:#ffffff24;--undo-button-bg-color-active:#ffffff36}}@media screen and (forced-colors:active){#editorUndoBar{--text-primary-color:CanvasText;--message-bar-icon-color:CanvasText;--message-bar-bg-color:Canvas;--message-bar-border-color:CanvasText;--undo-button-bg-color:ButtonText;--undo-button-bg-color-hover:SelectedItem;--undo-button-bg-color-active:SelectedItem;--undo-button-fg-color:ButtonFace;--undo-button-fg-color-hover:SelectedItemText;--undo-button-fg-color-active:SelectedItemText;--focus-ring-color:CanvasText}}#editorUndoBar{cursor:default;font:menu;font-size:15px;left:50%;padding-block:8px;padding-inline:16px 8px;position:fixed;top:50px;transform:translateX(-50%);z-index:10}#editorUndoBar button{cursor:pointer}#editorUndoBar #editorUndoBarUndoButton{background-color:var(--undo-button-bg-color);border:none;border-radius:4px;color:var(--undo-button-fg-color);font-weight:590;height:32px;line-height:19.5px;margin-inline-start:8px;padding:4px 16px}:is(#editorUndoBar #editorUndoBarUndoButton):hover{background-color:var(--undo-button-bg-color-hover);color:var(--undo-button-fg-color-hover)}:is(#editorUndoBar #editorUndoBarUndoButton):active{background-color:var(--undo-button-bg-color-active);color:var(--undo-button-fg-color-active)}#editorUndoBar>div{align-items:center}.dialog{--dialog-bg-color:#fff;--dialog-border-color:#fff;--dialog-shadow:0 2px 14px 0 #3a394433;--text-primary-color:#15141a;--text-secondary-color:#5b5b66;--hover-filter:brightness(0.9);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color);--link-fg-color:#0060df;--link-hover-fg-color:#0250bb;--separator-color:#f0f0f4;--textarea-border-color:#8f8f9d;--textarea-bg-color:#fff;--textarea-fg-color:var(--text-secondary-color);--radio-bg-color:#f0f0f4;--radio-checked-bg-color:#fbfbfe;--radio-border-color:#8f8f9d;--radio-checked-border-color:#0060df;--button-secondary-bg-color:#f0f0f4;--button-secondary-fg-color:var(--text-primary-color);--button-secondary-border-color:var(--button-secondary-bg-color);--button-secondary-hover-bg-color:var(--button-secondary-bg-color);--button-secondary-hover-fg-color:var(--button-secondary-fg-color);--button-secondary-hover-border-color:var(--button-secondary-hover-bg-color);--button-primary-bg-color:#0060df;--button-primary-fg-color:#fbfbfe;--button-primary-border-color:var(--button-primary-bg-color);--button-primary-hover-bg-color:var(--button-primary-bg-color);--button-primary-hover-fg-color:var(--button-primary-fg-color);--button-primary-hover-border-color:var(--button-primary-hover-bg-color)}@media (prefers-color-scheme:dark){.dialog{--dialog-bg-color:#1c1b22;--dialog-border-color:#1c1b22;--dialog-shadow:0 2px 14px 0 #15141a;--text-primary-color:#fbfbfe;--text-secondary-color:#cfcfd8;--focus-ring-color:#0df;--hover-filter:brightness(1.4);--link-fg-color:#0df;--link-hover-fg-color:#80ebff;--separator-color:#52525e;--textarea-bg-color:#42414d;--radio-bg-color:#2b2a33;--radio-checked-bg-color:#15141a;--radio-checked-border-color:#0df;--button-secondary-bg-color:#2b2a33;--button-primary-bg-color:#0df;--button-primary-fg-color:#15141a}}@media screen and (forced-colors:active){.dialog{--dialog-bg-color:Canvas;--dialog-border-color:CanvasText;--dialog-shadow:none;--text-primary-color:CanvasText;--text-secondary-color:CanvasText;--hover-filter:none;--focus-ring-color:ButtonBorder;--link-fg-color:LinkText;--link-hover-fg-color:LinkText;--separator-color:CanvasText;--textarea-border-color:ButtonBorder;--textarea-bg-color:Field;--textarea-fg-color:ButtonText;--radio-bg-color:ButtonFace;--radio-checked-bg-color:ButtonFace;--radio-border-color:ButtonText;--radio-checked-border-color:ButtonText;--button-secondary-bg-color:ButtonFace;--button-secondary-fg-color:ButtonText;--button-secondary-border-color:ButtonText;--button-secondary-hover-bg-color:AccentColor;--button-secondary-hover-fg-color:AccentColorText;--button-primary-bg-color:ButtonText;--button-primary-fg-color:ButtonFace;--button-primary-hover-bg-color:AccentColor;--button-primary-hover-fg-color:AccentColorText}}.dialog{background:var(--dialog-bg-color);border:1px solid var(--dialog-border-color);border-radius:4px;box-shadow:var(--dialog-shadow);color:var(--text-primary-color);font:message-box;font-size:13px;font-weight:400;line-height:150%;padding:12px 16px}:is(.dialog .mainContainer) :focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}:is(.dialog .mainContainer) .title{align-items:flex-start;display:flex;flex-direction:column;gap:12px;justify-content:flex-end;width:auto}:is(:is(.dialog .mainContainer) .title)>span{font-size:13px;font-style:normal;font-weight:590;line-height:150%}:is(.dialog .mainContainer) .dialogSeparator{border-bottom:none;border-top:1px solid var(--separator-color);height:0;margin-block:4px;width:100%}:is(.dialog .mainContainer) .dialogButtonsGroup{align-self:flex-end;display:flex;gap:12px}:is(.dialog .mainContainer) .radio{align-items:flex-start;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog .mainContainer) .radio)>.radioButton{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--radio-bg-color);border:1px solid var(--radio-border-color);border-radius:50%;box-sizing:border-box;height:16px;width:16px}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):hover{filter:var(--hover-filter)}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):checked{background-color:var(--radio-checked-bg-color);border:4px solid var(--radio-checked-border-color)}:is(:is(.dialog .mainContainer) .radio)>.radioLabel{align-items:flex-start;align-self:stretch;display:flex;gap:10px;padding-inline-start:24px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioLabel)>span{color:var(--text-secondary-color);flex:1 0 0;font-size:11px}:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton)){border:1px solid;border-radius:4px;font:menu;font-weight:600;height:32px;padding:4px 16px;width:auto}:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{cursor:pointer;filter:var(--hover-filter)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-secondary-bg-color);border-color:var(--button-secondary-border-color);color:var(--button-secondary-fg-color)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-secondary-hover-bg-color);border-color:var(--button-secondary-hover-border-color);color:var(--button-secondary-hover-fg-color)}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-primary-bg-color);border-color:var(--button-primary-border-color);color:var(--button-primary-fg-color);opacity:1}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-primary-hover-bg-color);border-color:var(--button-primary-hover-border-color);color:var(--button-primary-hover-fg-color)}:is(.dialog .mainContainer) a{color:var(--link-fg-color)}:is(:is(.dialog .mainContainer) a):hover{color:var(--link-hover-fg-color)}:is(.dialog .mainContainer) textarea{background:var(--textarea-bg-color);border:1px solid var(--textarea-border-color);border-radius:4px;box-sizing:border-box;color:var(--textarea-fg-color);font:inherit;margin:0;padding:8px;resize:none}:is(:is(.dialog .mainContainer) textarea):focus{border-color:#0000;outline-offset:0}:is(:is(.dialog .mainContainer) textarea):disabled{opacity:.4;pointer-events:none}:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#ffebcd;--message-bar-fg-color:#15141a;--message-bar-border-color:#00000014;--message-bar-icon:url(images/messageBar_warning.svg);--message-bar-icon-color:#cd411e}@media (prefers-color-scheme:dark){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#5a3100;--message-bar-fg-color:#fbfbfe;--message-bar-border-color:#ffffff14;--message-bar-icon-color:#e49c49}}@media screen and (forced-colors:active){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:HighlightText;--message-bar-fg-color:CanvasText;--message-bar-border-color:CanvasText;--message-bar-icon-color:CanvasText}}:is(.dialog .mainContainer) .messageBar{align-self:stretch}:is(:is(:is(.dialog .mainContainer) .messageBar)>div):before,:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{margin-block:4px}:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{align-items:flex-start;display:flex;flex:1 0 0;flex-direction:column;gap:8px}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .title{font-size:13px;font-weight:590}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .description{font-size:13px}:is(.dialog .mainContainer) .toggler{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(.dialog .mainContainer) .toggler)>.togglerLabel{-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;caret-color:CanvasText;forced-color-adjust:none;inset:0;line-height:1;opacity:1;overflow:clip;position:absolute;text-align:initial;transform-origin:0 0;z-index:0}.textLayer.highlighting{touch-action:none}.textLayer :is(span,br){color:#0000;cursor:text;position:absolute;transform-origin:0 0;white-space:pre}.textLayer .markedContent span:not(.markedContent),.textLayer>:not(.markedContent){z-index:1}.textLayer span.markedContent{height:0;top:0}.textLayer span[role=img]{cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer .highlight{--highlight-bg-color:#b400aa40;--highlight-selected-bg-color:#00640040;--highlight-backdrop-filter:none;--highlight-selected-backdrop-filter:none}@media screen and (forced-colors:active){.textLayer .highlight{--highlight-bg-color:#0000;--highlight-selected-bg-color:#0000;--highlight-backdrop-filter:var(--hcm-highlight-filter);--highlight-selected-backdrop-filter:var(\n --hcm-highlight-selected-filter\n )}}.textLayer .highlight{-webkit-backdrop-filter:var(--highlight-backdrop-filter);backdrop-filter:var(--highlight-backdrop-filter);background-color:var(--highlight-bg-color);border-radius:4px;margin:-1px;padding:1px}.appended:is(.textLayer .highlight){position:static}.begin:is(.textLayer .highlight){border-radius:4px 0 0 4px}.end:is(.textLayer .highlight){border-radius:0 4px 4px 0}.middle:is(.textLayer .highlight){border-radius:0}.selected:is(.textLayer .highlight){-webkit-backdrop-filter:var(--highlight-selected-backdrop-filter);backdrop-filter:var(--highlight-selected-backdrop-filter);background-color:var(--highlight-selected-bg-color)}.textLayer ::-moz-selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer ::selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer br::-moz-selection{background:#0000}.textLayer br::selection{background:#0000}.textLayer .endOfContent{cursor:default;display:block;inset:100% 0 0;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:0}.textLayer.selecting .endOfContent{top:0}.annotationLayer{--annotation-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--input-focus-border-color:Highlight;--input-focus-outline:1px solid Canvas;--input-unfocused-border-color:#0000;--input-disabled-border-color:#0000;--input-hover-border-color:#000;--link-outline:none}@media screen and (forced-colors:active){.annotationLayer{--input-focus-border-color:CanvasText;--input-unfocused-border-color:ActiveText;--input-disabled-border-color:GrayText;--input-hover-border-color:Highlight;--link-outline:1.5px solid LinkText}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid selectedItem}.annotationLayer .linkAnnotation{outline:var(--link-outline)}:is(.annotationLayer .linkAnnotation):hover{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter)}:is(.annotationLayer .linkAnnotation)>a:hover{background:none!important;box-shadow:none;opacity:0!important}.annotationLayer .popupAnnotation .popup{background-color:ButtonFace!important;color:ButtonText!important;outline:calc(1.5px*var(--scale-factor)) solid CanvasText!important}.annotationLayer .highlightArea:hover:after{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter);content:"";height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.annotationLayer .popupAnnotation.focused .popup{outline:calc(3px*var(--scale-factor)) solid Highlight!important}}.annotationLayer{left:0;pointer-events:none;position:absolute;top:0;transform-origin:0 0}.annotationLayer[data-main-rotation="90"] .norotate{transform:rotate(270deg) translateX(-100%)}.annotationLayer[data-main-rotation="180"] .norotate{transform:rotate(180deg) translate(-100%,-100%)}.annotationLayer[data-main-rotation="270"] .norotate{transform:rotate(90deg) translateY(-100%)}.annotationLayer.disabled .popup,.annotationLayer.disabled section{pointer-events:none}.annotationLayer .annotationContent{height:100%;pointer-events:none;position:absolute;width:100%}.freetext:is(.annotationLayer .annotationContent){background:#0000;border:none;font:10px sans-serif;inset:0;line-height:1.35;overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationLayer section{box-sizing:border-box;pointer-events:auto;position:absolute;text-align:initial;transform-origin:0 0}:is(.annotationLayer section):has(div.annotationContent) canvas.annotationContent{display:none}.textLayer.selecting~.annotationLayer section{pointer-events:none}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton)>a{font-size:1em;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton):not(.hasBorder)>a:hover{background-color:#ff0;box-shadow:0 2px 10px #ff0;opacity:.2}.annotationLayer .linkAnnotation.hasBorder:hover{background-color:#ff03}.annotationLayer .hasBorder{background-size:100% 100%}.annotationLayer .textAnnotation img{cursor:pointer;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input,.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .textWidgetAnnotation :is(input,textarea){background-image:var(--annotation-unfocused-field-background);border:2px solid var(--input-unfocused-border-color);box-sizing:border-box;font:calc(9px*var(--scale-factor)) sans-serif;height:100%;margin:0;vertical-align:top;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select option{padding:0}.annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}.annotationLayer .textWidgetAnnotation textarea{resize:none}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .textWidgetAnnotation [disabled]:is(input,textarea){background:none;border:2px solid var(--input-disabled-border-color);cursor:not-allowed}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border-radius:2px}.annotationLayer .choiceWidgetAnnotation select:focus,.annotationLayer .textWidgetAnnotation :is(input,textarea):focus{background:none;border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) :focus{background-color:initial;background-image:none}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{background-color:CanvasText;content:"";display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{height:80%;left:45%;width:1px}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;height:50%;left:25%;top:25%;width:50%}.annotationLayer .textWidgetAnnotation input.comb{font-family:monospace;padding-left:2px;padding-right:0}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{height:100%;width:100%}.annotationLayer .popupAnnotation{font-size:calc(9px*var(--scale-factor));height:auto;max-width:45%;pointer-events:none;position:absolute;width:-moz-max-content;width:max-content}.annotationLayer .popup{word-wrap:break-word;background-color:#ff9;border-radius:calc(2px*var(--scale-factor));box-shadow:0 calc(2px*var(--scale-factor)) calc(5px*var(--scale-factor)) #888;cursor:pointer;font:message-box;outline:1.5px solid #ffff4a;padding:calc(6px*var(--scale-factor));pointer-events:auto;white-space:normal}.annotationLayer .popupAnnotation.focused .popup{outline-width:3px}.annotationLayer .popup *{font-size:calc(9px*var(--scale-factor))}.annotationLayer .popup>.header{display:inline-block}.annotationLayer .popup>.header h1{display:inline}.annotationLayer .popup>.header .popupDate{display:inline-block;margin-left:calc(5px*var(--scale-factor));width:-moz-fit-content;width:fit-content}.annotationLayer .popupContent{border-top:1px solid #333;margin-top:calc(2px*var(--scale-factor));padding-top:calc(2px*var(--scale-factor))}.annotationLayer .richText>*{font-size:calc(9px*var(--scale-factor));white-space:pre-wrap}.annotationLayer .popupTriggerArea{cursor:pointer}.annotationLayer section svg{height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .annotationTextContent{color:#0000;height:100%;opacity:0;pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}:is(.annotationLayer .annotationTextContent) span{display:inline-block;width:100%}.annotationLayer svg.quadrilateralsContainer{contain:strict;height:0;left:0;position:absolute;top:0;width:0;z-index:-1}:root{--xfa-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--xfa-focus-outline:auto}@media screen and (forced-colors:active){:root{--xfa-focus-outline:2px solid CanvasText}.xfaLayer :required{outline:1.5px solid selectedItem}}.xfaLayer{background-color:initial}.xfaLayer .highlight{background-color:#efcbed;border-radius:4px;margin:-1px;padding:1px}.xfaLayer .highlight.appended{position:static}.xfaLayer .highlight.begin{border-radius:4px 0 0 4px}.xfaLayer .highlight.end{border-radius:0 4px 4px 0}.xfaLayer .highlight.middle{border-radius:0}.xfaLayer .highlight.selected{background-color:#cbdfcb}.xfaPage{overflow:hidden;position:relative}.xfaContentarea{position:absolute}.xfaPrintOnly{display:none}.xfaLayer{left:0;line-height:1.2;position:absolute;text-align:initial;top:0;transform-origin:0 0}.xfaLayer *{background-color:initial;box-sizing:border-box;color:inherit;font:inherit;font-kerning:inherit;font-style:inherit;font-weight:inherit;letter-spacing:-.01px;line-height:inherit;margin:0;padding:0;pointer-events:auto;text-align:inherit;text-decoration:inherit}.xfaLayer :required{outline:1.5px solid red}.xfaLayer div,.xfaLayer svg,.xfaLayer svg *{pointer-events:none}.xfaLayer a{color:blue}.xfaRich li{margin-left:3em}.xfaFont{color:#000;font-kerning:none;font-size:10px;font-style:normal;font-weight:400;letter-spacing:0;text-decoration:none;vertical-align:0}.xfaCaption{flex:0 0 auto;overflow:hidden}.xfaCaptionForCheckButton{flex:1 1 auto;overflow:hidden}.xfaLabel{height:100%;width:100%}.xfaLeft{flex-direction:row}.xfaLeft,.xfaRight{align-items:center;display:flex}.xfaRight{flex-direction:row-reverse}:is(.xfaLeft,.xfaRight)>:is(.xfaCaption,.xfaCaptionForCheckButton){max-height:100%}.xfaTop{flex-direction:column}.xfaBottom,.xfaTop{align-items:flex-start;display:flex}.xfaBottom{flex-direction:column-reverse}:is(.xfaTop,.xfaBottom)>:is(.xfaCaption,.xfaCaptionForCheckButton){width:100%}.xfaBorder{background-color:initial;pointer-events:none;position:absolute}.xfaWrapped{height:100%;width:100%}:is(.xfaTextfield,.xfaSelect):focus{background-color:initial;background-image:none;outline:var(--xfa-focus-outline);outline-offset:-1px}:is(.xfaCheckbox,.xfaRadio):focus{outline:var(--xfa-focus-outline)}.xfaSelect,.xfaTextfield{background-image:var(--xfa-unfocused-field-background);border:none;flex:1 1 auto;height:100%;resize:none;width:100%}.xfaSelect{padding-inline:2px}:is(.xfaTop,.xfaBottom)>:is(.xfaTextfield,.xfaSelect){flex:0 1 auto}.xfaButton{border:none;cursor:pointer;text-align:center}.xfaButton,.xfaLink{height:100%;width:100%}.xfaLink{left:0;position:absolute;top:0}.xfaCheckbox,.xfaRadio{border:none;flex:0 0 auto;height:100%;width:100%}.xfaRich{white-space:pre-wrap}.xfaImage,.xfaRich{height:100%;width:100%}.xfaImage{-o-object-fit:contain;object-fit:contain;-o-object-position:left top;object-position:left top}.xfaLrTb,.xfaRlTb,.xfaTb{flex-direction:column}.xfaLr,.xfaLrTb,.xfaRlTb,.xfaTb{align-items:stretch;display:flex}.xfaLr{flex-direction:row}.xfaRl{align-items:stretch;display:flex;flex-direction:row-reverse}.xfaTb>div{justify-content:left}.xfaArea,.xfaPosition{position:relative}.xfaValignMiddle{align-items:center;display:flex}.xfaTable{flex-direction:column}.xfaTable,.xfaTable .xfaRow{align-items:stretch;display:flex}.xfaTable .xfaRow{flex-direction:row}.xfaTable .xfaRlRow{align-items:stretch;display:flex;flex:1;flex-direction:row-reverse}.xfaTable .xfaRlRow>div{flex:1}:is(.xfaNonInteractive,.xfaDisabled,.xfaReadOnly) :is(input,textarea){background:initial}@media print{.xfaSelect,.xfaTextfield{background:#0000}.xfaSelect{-webkit-appearance:none;-moz-appearance:none;appearance:none;text-indent:1px;text-overflow:""}}.canvasWrapper svg{transform:none}.moving:is(.canvasWrapper svg){z-index:100000}[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,1,-1,0,1,0)}[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(-1,0,0,-1,1,1)}[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,-1,1,0,0,1)}.draw:is(.canvasWrapper svg){mix-blend-mode:normal;position:absolute}.draw[data-draw-rotation="90"]:is(.canvasWrapper svg){transform:rotate(90deg)}.draw[data-draw-rotation="180"]:is(.canvasWrapper svg){transform:rotate(180deg)}.draw[data-draw-rotation="270"]:is(.canvasWrapper svg){transform:rotate(270deg)}.highlight:is(.canvasWrapper svg){--blend-mode:multiply}@media screen and (forced-colors:active){.highlight:is(.canvasWrapper svg){--blend-mode:difference}}.highlight:is(.canvasWrapper svg){mix-blend-mode:var(--blend-mode);position:absolute}.highlight:is(.canvasWrapper svg):not(.free){fill-rule:evenodd}.highlightOutline:is(.canvasWrapper svg){fill-rule:evenodd;fill:none;mix-blend-mode:normal;position:absolute}.highlightOutline.hovered:is(.canvasWrapper svg):not(.free):not(.selected){stroke:var(--hover-outline-color);stroke-width:var(--outline-width)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc(var(--outline-width) + var(--outline-around-width)*2)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .secondaryOutline{stroke:var(--outline-color);stroke-width:var(--outline-width)}.highlightOutline.free.hovered:is(.canvasWrapper svg):not(.selected){stroke:var(--hover-outline-color);stroke-width:calc(var(--outline-width)*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc((var(--outline-width) + var(--outline-around-width))*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .secondaryOutline{stroke:var(--outline-color);stroke-width:calc(var(--outline-width)*2)}.toggle-button{--button-background-color:#f0f0f4;--button-background-color-hover:#e0e0e6;--button-background-color-active:#cfcfd8;--color-accent-primary:#0060df;--color-accent-primary-hover:#0250bb;--color-accent-primary-active:#054096;--border-interactive-color:#8f8f9d;--border-radius-circle:9999px;--border-width:1px;--size-item-small:16px;--size-item-large:32px;--color-canvas:#fff}@media (prefers-color-scheme:dark){.toggle-button{--button-background-color:color-mix(in srgb,currentColor 7%,#0000);--button-background-color-hover:color-mix(in srgb,currentColor 14%,#0000);--button-background-color-active:color-mix(in srgb,currentColor 21%,#0000);--color-accent-primary:#0df;--color-accent-primary-hover:#80ebff;--color-accent-primary-active:#aaf2ff;--border-interactive-color:#bfbfc9;--color-canvas:#1c1b22}}@media (forced-colors:active){.toggle-button{--color-accent-primary:ButtonText;--color-accent-primary-hover:SelectedItem;--color-accent-primary-active:SelectedItem;--border-interactive-color:ButtonText;--button-background-color:ButtonFace;--border-interactive-color-hover:SelectedItem;--border-interactive-color-active:SelectedItem;--border-interactive-color-disabled:GrayText;--color-canvas:ButtonText}}.toggle-button{--toggle-background-color:var(--button-background-color);--toggle-background-color-hover:var(--button-background-color-hover);--toggle-background-color-active:var(--button-background-color-active);--toggle-background-color-pressed:var(--color-accent-primary);--toggle-background-color-pressed-hover:var(--color-accent-primary-hover);--toggle-background-color-pressed-active:var(--color-accent-primary-active);--toggle-border-color:var(--border-interactive-color);--toggle-border-color-hover:var(--toggle-border-color);--toggle-border-color-active:var(--toggle-border-color);--toggle-border-radius:var(--border-radius-circle);--toggle-border-width:var(--border-width);--toggle-height:var(--size-item-small);--toggle-width:var(--size-item-large);--toggle-dot-background-color:var(--toggle-border-color);--toggle-dot-background-color-hover:var(--toggle-dot-background-color);--toggle-dot-background-color-active:var(--toggle-dot-background-color);--toggle-dot-background-color-on-pressed:var(--color-canvas);--toggle-dot-margin:1px;--toggle-dot-height:calc(var(--toggle-height) - var(--toggle-dot-margin)*2 - var(--toggle-border-width)*2);--toggle-dot-width:var(--toggle-dot-height);--toggle-dot-transform-x:calc(var(--toggle-width) - var(--toggle-dot-margin)*4 - var(--toggle-dot-width));-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--toggle-background-color);border:var(--toggle-border-width) solid var(--toggle-border-color);border-radius:var(--toggle-border-radius);box-sizing:border-box;flex-shrink:0;height:var(--toggle-height);margin:0;padding:0;width:var(--toggle-width)}.toggle-button:focus-visible{outline:var(--focus-outline);outline-offset:var(--focus-outline-offset)}.toggle-button:enabled:hover{background:var(--toggle-background-color-hover);border-color:var(--toggle-border-color)}.toggle-button:enabled:active{background:var(--toggle-background-color-active);border-color:var(--toggle-border-color)}.toggle-button[aria-pressed=true]{background:var(--toggle-background-color-pressed);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:hover{background:var(--toggle-background-color-pressed-hover);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:active{background:var(--toggle-background-color-pressed-active);border-color:#0000}.toggle-button:before{background-color:var(--toggle-dot-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-dot-height);margin:var(--toggle-dot-margin);translate:0;width:var(--toggle-dot-width)}.toggle-button[aria-pressed=true]:before{translate:var(--toggle-dot-transform-x)}.toggle-button[aria-pressed=true]:before,.toggle-button[aria-pressed=true]:enabled:active:before,.toggle-button[aria-pressed=true]:enabled:hover:before{background-color:var(--toggle-dot-background-color-on-pressed)}[dir=rtl] .toggle-button[aria-pressed=true]:before{translate:calc(var(--toggle-dot-transform-x)*-1)}@media (prefers-reduced-motion:no-preference){.toggle-button:before{transition:translate .1s}}@media (prefers-contrast){.toggle-button:enabled:hover{border-color:var(--toggle-border-color-hover)}.toggle-button:enabled:active{border-color:var(--toggle-border-color-active)}.toggle-button[aria-pressed=true]:enabled{border-color:var(--toggle-border-color);position:relative}.toggle-button[aria-pressed=true]:enabled:hover,.toggle-button[aria-pressed=true]:enabled:hover:active{border-color:var(--toggle-border-color-hover)}.toggle-button[aria-pressed=true]:enabled:active{background-color:var(--toggle-dot-background-color-active);border-color:var(--toggle-dot-background-color-hover)}.toggle-button:active:before,.toggle-button:hover:before{background-color:var(--toggle-dot-background-color-hover)}}@media (forced-colors){.toggle-button{--toggle-dot-background-color:var(--color-accent-primary);--toggle-dot-background-color-hover:var(--color-accent-primary-hover);--toggle-dot-background-color-active:var(--color-accent-primary-active);--toggle-dot-background-color-on-pressed:var(--button-background-color);--toggle-background-color-disabled:var(--button-background-color-disabled);--toggle-border-color-hover:var(--border-interactive-color-hover);--toggle-border-color-active:var(--border-interactive-color-active);--toggle-border-color-disabled:var(--border-interactive-color-disabled)}.toggle-button[aria-pressed=true]:enabled:after{border:1px solid var(--button-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-height);inset:-2px;position:absolute;width:var(--toggle-width)}.toggle-button[aria-pressed=true]:enabled:active:after{border-color:var(--toggle-border-color-active)}}:root{--outline-width:2px;--outline-color:#0060df;--outline-around-width:1px;--outline-around-color:#f0f0f4;--hover-outline-around-color:var(--outline-around-color);--focus-outline:solid var(--outline-width) var(--outline-color);--unfocus-outline:solid var(--outline-width) #0000;--focus-outline-around:solid var(--outline-around-width) var(--outline-around-color);--hover-outline-color:#8f8f9d;--hover-outline:solid var(--outline-width) var(--hover-outline-color);--hover-outline-around:solid var(--outline-around-width) var(--hover-outline-around-color);--freetext-line-height:1.35;--freetext-padding:2px;--resizer-bg-color:var(--outline-color);--resizer-size:6px;--resizer-shift:calc(0px - (var(--outline-width) + var(--resizer-size))/2 - var(--outline-around-width));--editorFreeText-editing-cursor:text;--editorInk-editing-cursor:url(images/cursor-editorInk.svg) 0 16,pointer;--editorHighlight-editing-cursor:url(images/cursor-editorTextHighlight.svg) 24 24,text;--editorFreeHighlight-editing-cursor:url(images/cursor-editorFreeHighlight.svg) 1 18,pointer;--new-alt-text-warning-image:url(images/altText_warning.svg)}.visuallyHidden{border:0;font-size:0;height:0;left:0;margin:0;overflow:hidden;padding:0;position:absolute;top:0;white-space:nowrap;width:0}.textLayer.highlighting{cursor:var(--editorFreeHighlight-editing-cursor)}.textLayer.highlighting:not(.free) span{cursor:var(--editorHighlight-editing-cursor)}.textLayer.highlighting.free span,[role=img]:is(.textLayer.highlighting:not(.free) span){cursor:var(--editorFreeHighlight-editing-cursor)}:is(#viewerContainer.pdfPresentationMode:fullscreen,.annotationEditorLayer.disabled) .noAltTextBadge{display:none!important}@media (min-resolution:1.1dppx){:root{--editorFreeText-editing-cursor:url(images/cursor-editorFreeText.svg) 0 16,text}}@media screen and (forced-colors:active){:root{--outline-color:CanvasText;--outline-around-color:ButtonFace;--resizer-bg-color:ButtonText;--hover-outline-color:Highlight;--hover-outline-around-color:SelectedItemText}}[data-editor-rotation="90"]{transform:rotate(90deg)}[data-editor-rotation="180"]{transform:rotate(180deg)}[data-editor-rotation="270"]{transform:rotate(270deg)}.annotationEditorLayer{background:#0000;cursor:auto;font-size:calc(100px*var(--scale-factor));inset:0;position:absolute;transform-origin:0 0}.annotationEditorLayer .selectedEditor{z-index:100000!important}.annotationEditorLayer.drawing *{pointer-events:none!important}.annotationEditorLayer.waiting{content:"";cursor:wait;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer.disabled{pointer-events:none}.annotationEditorLayer.freetextEditing{cursor:var(--editorFreeText-editing-cursor)}.annotationEditorLayer.inkEditing{cursor:var(--editorInk-editing-cursor)}.annotationEditorLayer .draw{box-sizing:border-box}.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor){background:#0000;border:var(--unfocus-outline);cursor:auto;max-height:100%;max-width:100%;position:absolute;transform-origin:0 0;z-index:1}.draggable.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){cursor:move}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){border:var(--focus-outline);outline:var(--focus-outline-around)}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):before{border:var(--focus-outline-around);content:"";inset:0;pointer-events:none;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor){border:var(--hover-outline);outline:var(--hover-outline-around)}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor):before{border:var(--focus-outline-around);content:"";inset:0;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-delete-image:url(images/editor-toolbar-delete.svg);--editor-toolbar-bg-color:#f0f0f4;--editor-toolbar-highlight-image:url(images/toolbarButton-editorHighlight.svg);--editor-toolbar-fg-color:#2e2e56;--editor-toolbar-border-color:#8f8f9d;--editor-toolbar-hover-border-color:var(--editor-toolbar-border-color);--editor-toolbar-hover-bg-color:#e0e0e6;--editor-toolbar-hover-fg-color:var(--editor-toolbar-fg-color);--editor-toolbar-hover-outline:none;--editor-toolbar-focus-outline-color:#0060df;--editor-toolbar-shadow:0 2px 6px 0 #3a394433;--editor-toolbar-vert-offset:6px;--editor-toolbar-height:28px;--editor-toolbar-padding:2px;--alt-text-done-color:#2ac3a2;--alt-text-warning-color:#0090ed;--alt-text-hover-done-color:var(--alt-text-done-color);--alt-text-hover-warning-color:var(--alt-text-warning-color)}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:#2b2a33;--editor-toolbar-fg-color:#fbfbfe;--editor-toolbar-hover-bg-color:#52525e;--editor-toolbar-focus-outline-color:#0df;--alt-text-done-color:#54ffbd;--alt-text-warning-color:#80ebff}}@media screen and (forced-colors:active){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:ButtonFace;--editor-toolbar-fg-color:ButtonText;--editor-toolbar-border-color:ButtonText;--editor-toolbar-hover-border-color:AccentColor;--editor-toolbar-hover-bg-color:ButtonFace;--editor-toolbar-hover-fg-color:AccentColor;--editor-toolbar-hover-outline:2px solid var(--editor-toolbar-hover-border-color);--editor-toolbar-focus-outline-color:ButtonBorder;--editor-toolbar-shadow:none;--alt-text-done-color:var(--editor-toolbar-fg-color);--alt-text-warning-color:var(--editor-toolbar-fg-color);--alt-text-hover-done-color:var(--editor-toolbar-hover-fg-color);--alt-text-hover-warning-color:var(--editor-toolbar-hover-fg-color)}}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);box-sizing:initial;cursor:default;display:flex;flex-direction:column;height:var(--editor-toolbar-height);inset-block-start:calc(100% + var(--editor-toolbar-vert-offset));inset-inline-end:0;justify-content:center;padding:var(--editor-toolbar-padding);pointer-events:auto;position:absolute;width:-moz-fit-content;width:fit-content}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar):has(:focus-visible){border-color:#0000}[dir=ltr] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:100% 0}[dir=rtl] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:0 0}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons{align-items:center;display:flex;gap:0;height:100%;justify-content:center}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) button{padding:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .divider{border-left:1px solid var(--editor-toolbar-border-color);border-right:none;display:inline-block;height:calc(var(--editor-toolbar-padding)*2 + var(--editor-toolbar-height));margin-inline:2px;width:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-highlight-image);mask-image:var(--editor-toolbar-highlight-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-delete-image);mask-image:var(--editor-toolbar-delete-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>*{height:var(--editor-toolbar-height)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider){background-color:initial;border:none;cursor:pointer}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover{background-color:var(--editor-toolbar-hover-bg-color);border-radius:2px;color:var(--editor-toolbar-hover-fg-color);outline:var(--editor-toolbar-hover-outline);outline-offset:1px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover:active{outline:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):focus-visible{border-radius:2px;outline:2px solid var(--editor-toolbar-focus-outline-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText{--alt-text-add-image:url(images/altText_add.svg);--alt-text-done-image:url(images/altText_done.svg);align-items:center;color:var(--editor-toolbar-fg-color);display:flex;font:menu;font-size:12px;font-weight:590;justify-content:center;padding-inline:8px;pointer-events:all;width:-moz-max-content;width:max-content}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):disabled{pointer-events:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:13px;margin-inline-end:4px;-webkit-mask-image:var(--alt-text-add-image);mask-image:var(--alt-text-add-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-warning-color);height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-warning-color)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-done-color);-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-done-color)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip{word-wrap:anywhere;display:none}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#f0f0f4;--alt-text-tooltip-fg:#15141a;--alt-text-tooltip-border:#8f8f9d;--alt-text-tooltip-shadow:0px 2px 6px 0px #3a394433}@media (prefers-color-scheme:dark){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#1c1b22;--alt-text-tooltip-fg:#fbfbfe;--alt-text-tooltip-shadow:0px 2px 6px 0px #15141a}}@media screen and (forced-colors:active){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:Canvas;--alt-text-tooltip-fg:CanvasText;--alt-text-tooltip-border:CanvasText;--alt-text-tooltip-shadow:none}}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){align-items:center;background:var(--alt-text-tooltip-bg);border:.5px solid var(--alt-text-tooltip-border);box-shadow:var(--alt-text-tooltip-shadow);color:var(--alt-text-tooltip-fg);display:inline-flex;flex-direction:column;font-size:12px;height:auto;inset-inline-start:0;justify-content:center;max-width:300px;padding-block:2px 3px;padding-inline:3px;pointer-events:none;position:absolute;top:calc(100% + 2px);width:-moz-max-content;width:max-content}.annotationEditorLayer .freeTextEditor{height:auto;padding:calc(var(--freetext-padding)*var(--scale-factor));touch-action:none;width:auto}.annotationEditorLayer .freeTextEditor .internal{background:#0000;border:none;font:10px sans-serif;inset:0;line-height:var(--freetext-line-height);overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationEditorLayer .freeTextEditor .overlay{background:#0000;display:none;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer freeTextEditor .overlay.enabled{display:block}.annotationEditorLayer .freeTextEditor .internal:empty:before{color:gray;content:attr(default-content)}.annotationEditorLayer .freeTextEditor .internal:focus{outline:none;-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}.annotationEditorLayer .inkEditor{height:100%;width:100%}.annotationEditorLayer .inkEditor.editing{cursor:inherit}.annotationEditorLayer .inkEditor .inkEditorCanvas{height:100%;inset:0;position:absolute;touch-action:none;width:100%}.annotationEditorLayer .stampEditor{height:auto;width:auto}:is(.annotationEditorLayer .stampEditor) canvas{height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#f0f0f4;--no-alt-text-badge-bg-color:#cfcfd8;--no-alt-text-badge-fg-color:#5b5b66}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#52525e;--no-alt-text-badge-bg-color:#fbfbfe;--no-alt-text-badge-fg-color:#15141a}}@media screen and (forced-colors:active){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:ButtonText;--no-alt-text-badge-bg-color:ButtonFace;--no-alt-text-badge-fg-color:ButtonText}}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{align-items:center;background:var(--no-alt-text-badge-bg-color);border:1px solid var(--no-alt-text-badge-border-color);border-radius:2px;display:inline-flex;height:32px;inset-block-end:5px;inset-inline-end:5px;justify-content:center;padding:3px;pointer-events:none;position:absolute;width:32px;z-index:1}:is(:is(.annotationEditorLayer .stampEditor) .noAltTextBadge):before{background-color:var(--no-alt-text-badge-fg-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers{inset:0;position:absolute}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer{background:content-box var(--resizer-bg-color);border:var(--focus-outline-around);border-radius:2px;height:var(--resizer-size);position:absolute;width:var(--resizer-size)}.topLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:var(--resizer-shift)}.topMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:calc(50% + var(--resizer-shift));top:var(--resizer-shift)}.topRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:var(--resizer-shift)}.middleRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);right:var(--resizer-shift)}.bottomMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:calc(50% + var(--resizer-shift))}.bottomLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:var(--resizer-shift)}.middleLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nwse-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ns-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nesw-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ew-resize}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nesw-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ew-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nwse-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ns-resize}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar{rotate:270deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(0px - var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="180"],[data-main-rotation="90"] [data-editor-rotation="90"],[data-main-rotation="180"] [data-editor-rotation="0"],[data-main-rotation="270"] [data-editor-rotation="270"])) .editToolbar{inset-block-start:calc(0pc - var(--editor-toolbar-vert-offset));inset-inline-end:100%;rotate:180deg}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar{rotate:90deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:100%;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:0;inset-inline-start:calc(0px - var(--editor-toolbar-vert-offset))}.dialog.altText::backdrop{-webkit-mask:url(#alttext-manager-mask);mask:url(#alttext-manager-mask)}.dialog.altText.positioned{margin:0}.dialog.altText #altTextContainer{align-items:flex-start;display:inline-flex;flex-direction:column;gap:16px;height:-moz-fit-content;height:fit-content;width:300px}:is(.dialog.altText #altTextContainer) #overallDescription{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog.altText #altTextContainer) #overallDescription) span{align-self:stretch}:is(:is(.dialog.altText #altTextContainer) #overallDescription) .title{font-size:13px;font-style:normal;font-weight:590}:is(.dialog.altText #altTextContainer) #addDescription{align-items:stretch;display:flex;flex-direction:column;gap:8px}:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea{flex:1;padding-inline:24px 10px}:is(:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea) textarea{min-height:75px;width:100%}:is(.dialog.altText #altTextContainer) #buttons{align-items:flex-start;align-self:stretch;display:flex;gap:8px;justify-content:flex-end}.dialog.newAltText{--new-alt-text-ai-disclaimer-icon:url(images/altText_disclaimer.svg);--new-alt-text-spinner-icon:url(images/altText_spinner.svg);--preview-image-bg-color:#f0f0f4;--preview-image-border:none}@media (prefers-color-scheme:dark){.dialog.newAltText{--preview-image-bg-color:#2b2a33}}@media screen and (forced-colors:active){.dialog.newAltText{--preview-image-bg-color:ButtonFace;--preview-image-border:1px solid ButtonText}}.dialog.newAltText{max-width:570px;min-width:300px;padding:0;width:80%}.dialog.newAltText.aiInstalling #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextDisclaimer{display:none!important}.dialog.newAltText.aiInstalling #newAltTextDownloadModel{display:flex!important}.dialog.newAltText.error #newAltTextNotNow{display:none!important}.dialog.newAltText.error #newAltTextCancel{display:inline-block!important}.dialog.newAltText:not(.error) #newAltTextError{display:none!important}.dialog.newAltText #newAltTextContainer{align-items:flex-start;display:flex;flex:0 1 auto;flex-direction:column;gap:12px;justify-content:flex-end;line-height:normal;padding:16px;width:auto}:is(.dialog.newAltText #newAltTextContainer) #mainContent{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;gap:12px;justify-content:flex-end}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionAndSettings{align-items:flex-start;align-self:stretch;display:flex;flex:1 0 0;flex-direction:column;gap:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;flex-direction:column;gap:8px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer{height:70px;position:relative;width:100%}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea{height:100%;padding:8px;width:100%}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::-moz-placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{background-color:var(--text-secondary-color);display:none;height:16px;inset-block-start:8px;inset-inline-start:8px;-webkit-mask-size:cover;mask-size:cover;pointer-events:none;position:absolute;width:16px}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::-moz-placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{display:inline-block;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon)}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescription{font-size:11px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer{align-items:flex-start;display:flex;flex-direction:row;font-size:11px;gap:4px}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer):before{background-color:var(--text-secondary-color);content:"";display:inline-block;flex:1 0 auto;height:16px;-webkit-mask-image:var(--new-alt-text-ai-disclaimer-icon);mask-image:var(--new-alt-text-ai-disclaimer-icon);-webkit-mask-size:cover;mask-size:cover;width:17px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel{align-items:center;align-self:stretch;display:flex;gap:4px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel):before{background-color:var(--text-secondary-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview{align-items:center;aspect-ratio:1;background-color:var(--preview-image-bg-color);border:var(--preview-image-border);display:flex;flex:0 0 auto;justify-content:center;width:180px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview)>canvas{max-height:100%;max-width:100%}.colorPicker{--hover-outline-color:#0250bb;--selected-outline-color:#0060df;--swatch-border-color:#cfcfd8}@media (prefers-color-scheme:dark){.colorPicker{--hover-outline-color:#80ebff;--selected-outline-color:#aaf2ff;--swatch-border-color:#52525e}}@media screen and (forced-colors:active){.colorPicker{--hover-outline-color:Highlight;--selected-outline-color:var(--hover-outline-color);--swatch-border-color:ButtonText}}.colorPicker .swatch{border:1px solid var(--swatch-border-color);border-radius:100%;box-sizing:border-box;forced-color-adjust:none;height:16px;outline-offset:2px;width:16px}.colorPicker button:is(:hover,.selected)>.swatch{border:none}.annotationEditorLayer[data-main-rotation="0"] .highlightEditor:not(.free)>.editToolbar{rotate:0deg}.annotationEditorLayer[data-main-rotation="90"] .highlightEditor:not(.free)>.editToolbar{rotate:270deg}.annotationEditorLayer[data-main-rotation="180"] .highlightEditor:not(.free)>.editToolbar{rotate:180deg}.annotationEditorLayer[data-main-rotation="270"] .highlightEditor:not(.free)>.editToolbar{rotate:90deg}.annotationEditorLayer .highlightEditor{background:#0000;border:none;cursor:auto;max-height:100%;max-width:100%;outline:none;pointer-events:none;position:absolute;transform-origin:0 0;z-index:1}:is(.annotationEditorLayer .highlightEditor):not(.free){transform:none}:is(.annotationEditorLayer .highlightEditor) .internal{height:100%;left:0;pointer-events:auto;position:absolute;top:0;width:100%}.disabled:is(.annotationEditorLayer .highlightEditor) .internal{pointer-events:none}.selectedEditor:is(.annotationEditorLayer .highlightEditor) .internal{cursor:pointer}:is(.annotationEditorLayer .highlightEditor) .editToolbar{--editor-toolbar-colorpicker-arrow-image:url(images/toolbarButton-menuArrow.svg);transform-origin:center!important}:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker{align-items:center;display:flex;gap:4px;justify-content:center;padding:4px;position:relative;width:auto}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):after{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:12px;-webkit-mask-image:var(--editor-toolbar-colorpicker-arrow-image);mask-image:var(--editor-toolbar-colorpicker-arrow-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):hover:after{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)){background-color:var(--editor-toolbar-hover-bg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)):after{scale:-1}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);display:flex;flex-direction:column;gap:11px;inset-block-start:calc(100% + 4px);justify-content:center;padding-block:8px;position:absolute;width:calc(100% + var(--editor-toolbar-padding)*2)}:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;height:auto;justify-content:center;width:100%}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline-offset:2px}[aria-selected=true]:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}.editorParamsToolbar:has(#highlightParamsToolbarContainer){padding:unset}#highlightParamsToolbarContainer{gap:16px;padding-block-end:12px;padding-inline:10px}#highlightParamsToolbarContainer .colorPicker{display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer .colorPicker) .dropdown{align-items:center;display:flex;flex-direction:row;height:auto;justify-content:space-between}:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;flex:0 0 auto;height:auto;justify-content:center;padding:0;width:auto}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button) .swatch{height:24px;width:24px}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}[aria-selected=true]:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}#highlightParamsToolbarContainer #editorHighlightThickness{align-items:center;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .editorParamsLabel{align-self:stretch;height:auto}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#bfbfc9;align-items:center;align-self:stretch;display:flex;justify-content:space-between}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#80808e}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:CanvasText}}:is(:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker)>.editorParamsSlider[disabled]){opacity:.4}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after,:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):before{aspect-ratio:1;background-color:var(--example-color);border-radius:100%;content:"";display:block;width:8px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after{width:24px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker) .editorParamsSlider{height:14px;width:unset}#highlightParamsToolbarContainer #editorHighlightVisibility{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#d7d7db}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#8f8f9d}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:CanvasText}}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{background-color:var(--divider-color);height:1px;margin-block:4px;width:100%}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .toggler{align-items:center;align-self:stretch;display:flex;justify-content:space-between}#altTextSettingsDialog{padding:16px}#altTextSettingsDialog #altTextSettingsContainer{display:flex;flex-direction:column;gap:16px;width:573px}:is(#altTextSettingsDialog #altTextSettingsContainer) .mainContainer{gap:16px}:is(#altTextSettingsDialog #altTextSettingsContainer) .description{color:var(--text-secondary-color)}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings{display:flex;flex-direction:column;gap:12px}:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) button{width:-moz-fit-content;width:fit-content}.download:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) #deleteModelButton,:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings):not(.download) #downloadModelButton{display:none}:is(#altTextSettingsDialog #altTextSettingsContainer) #altTextEditor,:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticAltText{display:flex;flex-direction:column;gap:8px}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings,:is(#altTextSettingsDialog #altTextSettingsContainer) #createModelDescription,:is(#altTextSettingsDialog #altTextSettingsContainer) #showAltTextDialogDescription{padding-inline-start:40px}:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticSettings{display:flex;flex-direction:column;gap:16px}:root{--viewer-container-height:0;--pdfViewer-padding-bottom:0;--page-margin:1px auto -8px;--page-border:9px solid #0000;--spreadHorizontalWrapped-margin-LR:-3.5px;--loading-icon-delay:400ms}@media screen and (forced-colors:active){:root{--pdfViewer-padding-bottom:9px;--page-margin:8px auto -1px;--page-border:1px solid CanvasText;--spreadHorizontalWrapped-margin-LR:3.5px}}[data-main-rotation="90"]{transform:rotate(90deg) translateY(-100%)}[data-main-rotation="180"]{transform:rotate(180deg) translate(-100%,-100%)}[data-main-rotation="270"]{transform:rotate(270deg) translateX(-100%)}#hiddenCopyElement,.hiddenCanvasElement{display:none;height:0;left:0;position:absolute;top:0;width:0}.pdfViewer{--scale-factor:1;--page-bg-color:unset;--hcm-highlight-filter:none;--hcm-highlight-selected-filter:none;padding-bottom:var(--pdfViewer-padding-bottom)}@media screen and (forced-colors:active){.pdfViewer{--hcm-highlight-filter:invert(100%)}}.pdfViewer.copyAll{cursor:wait}.pdfViewer .canvasWrapper{height:100%;overflow:hidden;width:100%}:is(.pdfViewer .canvasWrapper) canvas{contain:content;display:block;height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(:is(.pdfViewer .canvasWrapper) canvas) .structTree{contain:strict}.pdfViewer .page{--scale-round-x:1px;--scale-round-y:1px;background-clip:content-box;background-color:var(--page-bg-color,#fff);border:var(--page-border);direction:ltr;height:1056px;margin:var(--page-margin);overflow:visible;position:relative;width:816px}.pdfViewer .dummyPage{height:var(--viewer-container-height);position:relative;width:0}.pdfViewer.noUserSelect{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pdfViewer.removePageBorders .page{border:none;margin:0 auto 10px}.pdfViewer.singlePageView{display:inline-block}.pdfViewer.singlePageView .page{border:none;margin:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped),.spread{margin-inline:3.5px;text-align:center}.pdfViewer.scrollHorizontal,.spread{white-space:nowrap}.pdfViewer.removePageBorders,.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .spread{margin-inline:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) :is(.page,.spread),.spread :is(.page,.dummyPage){display:inline-block;vertical-align:middle}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .page,.spread .page{margin-inline:var(--spreadHorizontalWrapped-margin-LR)}.pdfViewer.removePageBorders .spread .page,.pdfViewer.removePageBorders:is(.scrollHorizontal,.scrollWrapped) .page{margin-inline:5px}.pdfViewer .page.loadingIcon:after{background:url(images/loading-icon.gif) 50% no-repeat;contain:strict;content:"";display:none;height:100%;left:0;position:absolute;top:0;transition-delay:var(--loading-icon-delay);transition-property:display;width:100%;z-index:5}.pdfViewer .page.loading:after{display:block}.pdfViewer .page:not(.loading):after{display:none;transition-property:none}.pdfPresentationMode .pdfViewer{padding-bottom:0}.pdfPresentationMode .spread{margin:0}.pdfPresentationMode .pdfViewer .page{border:2px solid #0000;margin:0 auto}');var xle=function(){function e(){}return e.generateUniqueId=function(){var e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return"".concat(e,"-").concat(t)},e}(),Sle=Symbol.for("immer-nothing"),Tle=Symbol.for("immer-draftable"),Ole=Symbol.for("immer-state"),Ale="production"!==xt.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Rle(e,...t){if("production"!==xt.env.NODE_ENV){const n=Ale[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Nle=Object.getPrototypeOf;function _le(e){return!!e&&!!e[Ole]}function Dle(e){return!!e&&(Fle(e)||Array.isArray(e)||!!e[Tle]||!!e.constructor?.[Tle]||Wle(e)||$le(e))}var Ple=Object.prototype.constructor.toString();function Fle(e){if(!e||"object"!=typeof e)return!1;const t=Nle(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Ple}function Ile(e,t){0===Ble(e)?Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)})):e.forEach(((n,r)=>t(r,n,e)))}function Ble(e){const t=e[Ole];return t?t.type_:Array.isArray(e)?1:Wle(e)?2:$le(e)?3:0}function jle(e,t){return 2===Ble(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ule(e,t,n){const r=Ble(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function Wle(e){return e instanceof Map}function $le(e){return e instanceof Set}function qle(e){return e.copy_||e.base_}function Gle(e,t){if(Wle(e))return new Map(e);if($le(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Fle(e);if(!0===t||"class_only"===t&&!n){const t=Object.getOwnPropertyDescriptors(e);delete t[Ole];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){const a=n[r],o=t[a];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[a]})}return Object.create(Nle(e),t)}{const t=Nle(e);if(null!==t&&n)return{...e};const r=Object.create(t);return Object.assign(r,e)}}function Yle(e,t=!1){return Xle(e)||_le(e)||!Dle(e)||(Ble(e)>1&&(e.set=e.add=e.clear=e.delete=Kle),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>Yle(t,!0)))),e}function Kle(){Rle(2)}function Xle(e){return Object.isFrozen(e)}var Qle,Jle={};function Zle(e){const t=Jle[e];return t||Rle(0,e),t}function ese(){return Qle}function tse(e,t){t&&(Zle("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function nse(e){rse(e),e.drafts_.forEach(ose),e.drafts_=null}function rse(e){e===Qle&&(Qle=e.parent_)}function ase(e){return Qle={drafts_:[],parent_:Qle,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ose(e){const t=e[Ole];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function cse(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ole].modified_&&(nse(t),Rle(4)),Dle(e)&&(e=ise(t,e),t.parent_||sse(t,e)),t.patches_&&Zle("Patches").generateReplacementPatches_(n[Ole].base_,e,t.patches_,t.inversePatches_)):e=ise(t,n,[]),nse(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Sle?e:void 0}function ise(e,t,n){if(Xle(t))return t;const r=t[Ole];if(!r)return Ile(t,((a,o)=>lse(e,r,t,a,o,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return sse(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let a=t,o=!1;3===r.type_&&(a=new Set(t),t.clear(),o=!0),Ile(a,((a,c)=>lse(e,r,t,a,c,n,o))),sse(e,t,!1),n&&e.patches_&&Zle("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function lse(e,t,n,r,a,o,c){if("production"!==xt.env.NODE_ENV&&a===n&&Rle(5),_le(a)){const c=ise(e,a,o&&t&&3!==t.type_&&!jle(t.assigned_,r)?o.concat(r):void 0);if(Ule(n,r,c),!_le(c))return;e.canAutoFreeze_=!1}else c&&n.add(a);if(Dle(a)&&!Xle(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ise(e,a),t&&t.scope_.parent_||"symbol"==typeof r||!Object.prototype.propertyIsEnumerable.call(n,r)||sse(e,a)}}function sse(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Yle(t,n)}var hse={get(e,t){if(t===Ole)return e;const n=qle(e);if(!jle(n,t))return function(e,t,n){const r=mse(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!Dle(r)?r:r===use(e.base_,t)?(vse(e),e.copy_[t]=fse(r,e)):r},has:(e,t)=>t in qle(e),ownKeys:e=>Reflect.ownKeys(qle(e)),set(e,t,n){const r=mse(qle(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=use(qle(e),t),c=r?.[Ole];if(c&&c.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((a=n)===(o=r)?0!==a||1/a==1/o:a!=a&&o!=o)&&(void 0!==n||jle(e.base_,t)))return!0;vse(e),pse(e)}var a,o;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==use(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,vse(e),pse(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=qle(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){Rle(11)},getPrototypeOf:e=>Nle(e.base_),setPrototypeOf(){Rle(12)}},dse={};function use(e,t){const n=e[Ole];return(n?qle(n):e)[t]}function mse(e,t){if(!(t in e))return;let n=Nle(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Nle(n)}}function pse(e){e.modified_||(e.modified_=!0,e.parent_&&pse(e.parent_))}function vse(e){e.copy_||(e.copy_=Gle(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function fse(e,t){const n=Wle(e)?Zle("MapSet").proxyMap_(e,t):$le(e)?Zle("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ese(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let a=r,o=hse;n&&(a=[r],o=dse);const{revoke:c,proxy:i}=Proxy.revocable(a,o);return r.draft_=i,r.revoke_=c,i}(e,t);return(t?t.scope_:ese()).drafts_.push(n),n}function zse(e){if(!Dle(e)||Xle(e))return e;const t=e[Ole];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Gle(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Gle(e,!0);return Ile(n,((e,t)=>{Ule(n,e,zse(t))})),t&&(t.finalized_=!1),n}Ile(hse,((e,t)=>{dse[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),dse.deleteProperty=function(e,t){return"production"!==xt.env.NODE_ENV&&isNaN(parseInt(t))&&Rle(13),dse.set.call(this,e,t,void 0)},dse.set=function(e,t,n){return"production"!==xt.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Rle(14),hse.set.call(this,e[0],t,n,e[0])};var gse=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const r=this;return function(e=n,...a){return r.produce(e,(e=>t.call(this,e,...a)))}}let r;if("function"!=typeof t&&Rle(6),void 0!==n&&"function"!=typeof n&&Rle(7),Dle(e)){const a=ase(this),o=fse(e,void 0);let c=!0;try{r=t(o),c=!1}finally{c?nse(a):rse(a)}return tse(a,n),cse(r,a)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===Sle&&(r=void 0),this.autoFreeze_&&Yle(r,!0),n){const t=[],a=[];Zle("Patches").generateReplacementPatches_(e,r,t,a),n(t,a)}return r}Rle(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;return[this.produce(e,t,((e,t)=>{n=e,r=t})),n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Dle(e)||Rle(8),_le(e)&&(e=function(e){return _le(e)||Rle(10,e),zse(e)}(e));const t=ase(this),n=fse(e,void 0);return n[Ole].isManual_=!0,rse(t),n}finishDraft(e,t){const n=e&&e[Ole];n&&n.isManual_||Rle(9);const{scope_:r}=n;return tse(r,t),cse(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=Zle("Patches").applyPatches_;return _le(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},yse=gse.produce;gse.produceWithPatches.bind(gse);var Mse=gse.setAutoFreeze.bind(gse);gse.setUseStrictShallowCopy.bind(gse),gse.applyPatches.bind(gse),gse.createDraft.bind(gse),gse.finishDraft.bind(gse);var Ese={isScaleSaveHappening:!1,isAddNewScaleFormPopupOpen:!1,scaleName:"",paperDimension:{unitOfMeasurement:"inch",scalarQuantity:1},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:1},precision:.1,userCalibratingScaleOnPdfPageDetails:{isHappening:!1,coordinates:[]},isCalibrationScaleFormPopupOpen:!1,pdfPageId:""},bse={scaleId:"",popup:{isOpen:!1},paperDimension:{unitOfMeasurement:"inch",scalarQuantity:0},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:0},scaleName:"",precision:.1,isScaleSaveHappening:!1},Hse=function(){function e(){}return e.getEnvValue=function(e){var t,n=null===(t=null===window||void 0===window?void 0:window._env_)||void 0===t?void 0:t[e];return n&&"default"!==n?n:""},e}(),Vse=function(){function e(){}return e.BACKEND_BASE_URL=Hse.getEnvValue("BACKEND_BASE_URL"),e.scalePrecisionOptions=[.1,.01,.001],e.annotationAvalaibleColors=[{color:"#E34234"},{color:"#FF8D02"},{color:"#FFCD44"},{color:"#5BC96D"},{color:"#26D2D2"},{color:"#587CE2"},{color:"#C544CE"},{color:"#7D2E25"},{color:"#A84F1C"},{color:"#E99E38"},{color:"#347842"},{color:"#167E7D"},{color:"#354A87"},{color:"#76287B"},{color:"#000"},{color:"#CDCDCD"},{color:"#9C9C9C"},{color:"#696969"},{color:"#272727"},{color:"#FFFFFF"}],e.pdfPagesElementId="pdf-pages-container",e}(),Cse={isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:Vse.annotationAvalaibleColors[0].color},coordinates:{collapsedStatus:"collapsed",shouldHighlightFirstCoordinate:!1,shouldHighlightSecondCoordinate:!1,x1:0,x2:0,y1:0,y2:0}}};Cle.workerSrc="https://unpkg.com/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs",Mse(!1);var Lse={options:{showDividerBetweenToolSections:!0,alignmentOfFirstRowToolSections:"space-between"},sections:[[{name:"fullScreen"},{name:"zoomTool"}],[{name:"Annotation",children:[{name:"highlight"},{name:"callout"}]},{name:"Shapes",children:[{name:"rectangle"}]},{name:"Measure",children:[{name:"measureDistance"}]}],[{name:"toggleTextSelectionTool"},{name:"eyeTool"},{name:"comment"}]]};function wse(e){var t=this,r=c([]),a=r[0],o=r[1],d=c(""),u=d[0],m=d[1],p=c(""),v=p[0],f=p[1],z=c({pdfEditorToolsToShow:e.toolsToShow||Lse,toolsRelatedData:{},measureToolRelatedData:{scaleIdSelected:"",addNewScaleDetails:Ese,editScaleDetails:bse,distanceAnnotation:{configurationsDrawer:Cse,isFirstPointSelected:!1,isSecondPointSelected:!1}},textHighlightToolRelatedData:{isTextSelectionEnabled:!0,selectedTextToolBoxDetails:{pdfPageId:"",x:0,y:0}}}),g=z[0],y=z[1],M=c(e.currentUserId),E=M[0],b=M[1],H=c([]),V=H[0],C=H[1],L=c([]),w=L[0],k=L[1],x=c(!1),S=x[0],T=x[1],O=c(0),A=O[0],R=O[1],N=c(!1),_=N[0],D=N[1],P=c(!1),F=P[0],I=P[1],B=c(e.areAnnotationsVisibleByDefault),j=B[0],U=B[1],W=c(""),$=W[0],q=W[1],G=c(""),Y=G[0],K=G[1],X=e.rectangleAnnotationToolOptions,Q=e.backendBaseUrl,J=e.rlefEventServiceBaseUrl,Z=i(new pae({backendBaseUrl:Q})),ee=c(xle.generateUniqueId()),te=ee[0];ee[1];var ne=c([]),re=ne[0],ae=ne[1],oe=l((function(e){ae((function(t){return _ee(_ee([],t,!0),[e],!1)}))}),[ae]),ce=l((function(e,n){return Ree(t,void 0,void 0,(function(){var t,r;return Nee(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),T(!0),[4,Z.current.fetchUsersOfPdf({pdfId:n,userNameSearchKey:e,limit:10,offset:1})];case 1:return(t=a.sent())&&k(t),[3,4];case 2:return r=a.sent(),console.error("Error fetching suggested users: ",r),[3,4];case 3:return T(!1),[7];case 4:return[2]}}))}))}),[]),ie=l((function(e){ae((function(t){return _ee([],t.filter((function(t){return t!==e})),!0)}))}),[ae]),le=l((function(){return Ree(t,void 0,void 0,(function(){var t,n,r,o,c;return Nee(this,(function(i){switch(i.label){case 0:if(!(t=(null===(c=a[0])||void 0===c?void 0:c._id)||""))return[2];i.label=1;case 1:return i.trys.push([1,5,,6]),I(!0),[4,Z.current.fetchUsersOfPdf({pdfId:t})];case 2:return(n=i.sent())?-1!==n.findIndex((function(t){return t._id===e.currentUserId}))?[3,4]:[4,Z.current.fetchUsersOfPdf({pdfId:t,userIds:[e.currentUserId]})]:[2];case 3:(r=i.sent())&&r.length>0&&n.push(r[0]),i.label=4;case 4:return C(n),[3,6];case 5:return o=i.sent(),console.error("Error fetching users: ",o),[3,6];case 6:return[2]}}))}))}),[a]);s((function(){F||le()}),[le,F]);var se=c([]);se[0];var he=se[1],de=c({isEditingText:!1,annotationId:"",pdfId:"",pdfPageId:"",color:"",points:[],text:""}),ue=de[0],me=de[1],pe=l((function(e,n){return Ree(t,void 0,void 0,(function(){var t,r,a,c,i,l,s,h,d,u,m,p,v;return Nee(this,(function(f){switch(f.label){case 0:return t=(n||{}).pdfSourceUrl,e&&oe(e),r={},e&&(r.pdfId=e),t&&(r.pdfSourceUrl=t),a=Z.current.fetchOnlyPdfData(Aee(Aee({},r),{getPdfDownloadUrl:"true"})),c={pdfs:[]},t?[4,a]:[3,6];case 1:return(c=f.sent()).pdfs.length>0?(e=c.pdfs[0]._id,[3,5]):[3,2];case 2:return he((function(e){return _ee(_ee([],e,!0),[t],!1)})),[4,Z.current.insertPdfAndItsPagesInDb({pdfSourceUrl:t,pdfFileName:"sourceUrl.pdf"})];case 3:return i=f.sent(),e=i._id,[4,Z.current.fetchOnlyPdfData(Aee(Aee({},r),{getPdfDownloadUrl:"true"}))];case 4:c=f.sent(),he((function(e){return _ee([],e.filter((function(e){return e!==t})),!0)})),f.label=5;case 5:return[3,8];case 6:return[4,a];case 7:c=f.sent(),f.label=8;case 8:return l=Z.current.fetchOnlyPdfPagesData({pdfId:e,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"}),s=Z.current.fetchPdfScales({pdfId:e}),[4,l];case 9:return h=f.sent(),[4,s];case 10:return d=f.sent(),!g.measureToolRelatedData.scaleIdSelected&&d.scales.length>0&&y(yse((function(e){var t;e.measureToolRelatedData.scaleIdSelected=(null===(t=d.scales[0])||void 0===t?void 0:t._id)||""}))),(u=null===(v=null==c?void 0:c.pdfs[0])||void 0===v?void 0:v.pdfDownloadUrl)?[4,wle(u).promise]:[3,12];case 11:return p=f.sent(),[3,13];case 12:p=null,f.label=13;case 13:return(m=p)&&o((function(n){var r,a,o=_ee([],n,!0),i=o.length>0?o.findIndex((function(t){return t._id===e})):-1,l=-1!==i,s={_id:null===(a=null===(r=null==c?void 0:c.pdfs)||void 0===r?void 0:r[0])||void 0===a?void 0:a._id,sourcePdfUrl:t||"",pdfPagesImageGenerationStatus:c.pdfs[0].pdfPagesImageGenerationStatus,pdfDownloadUrl:c.pdfs[0].pdfDownloadUrl,pdfDocument:m,pages:h.pages.map((function(e){return{_id:null==e?void 0:e._id,pdfId:e.pdfId,annotations:[],commentThreads:[],pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pageNumber:e.pageNumber,pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints,pageAsImageDetails:e.pageAsImageDetails}})),scales:d.scales.map((function(e){return Aee({},e)}))};return l?o[i]=Aee({},s):o.push(s),o})),ie(e),[2]}}))}))}),[oe,Z,ie,o]),ve=l((function(e){y((function(t){var n=Aee({},t);return n.toolsRelatedData=Aee(Aee({},n.toolsRelatedData),{comment:Aee(Aee({},n.toolsRelatedData.comment),{selectedThreadId:e})}),n}))}),[y]),fe=g.measureToolRelatedData.addNewScaleDetails,ze=g.measureToolRelatedData.editScaleDetails,ge=l((function(){return Ree(t,void 0,void 0,(function(){return Nee(this,(function(e){return y((function(e){var t,n;return Aee(Aee({},e),{measureToolRelatedData:Aee(Aee({},e.measureToolRelatedData),{addNewScaleDetails:Aee(Aee({},e.measureToolRelatedData.addNewScaleDetails),{isAddNewScaleFormPopupOpen:!0,pdfPageId:null===(n=null===(t=null==a?void 0:a[0])||void 0===t?void 0:t.pages[0])||void 0===n?void 0:n._id})})})})),[2]}))}))}),[a]),ye=c([]),Me=ye[0],Ee=ye[1],be=l((function(e){return Ree(t,void 0,void 0,(function(){var t,n,r;return Nee(this,(function(c){switch(c.label){case 0:return(t=a.find((function(t){return t._id===e.pdfIdOfPage})))&&(n=t.pages.find((function(t){return t._id===e.pdfPageId})))?n.pageImageElement||Me.includes(n._id)?[2]:(Ee((function(e){return _ee(_ee([],e,!0),[n._id],!1)})),[4,vae.downloadImage(n.pageImageUrl)]):[2];case 1:return r=c.sent(),o((function(t){var n=t.map((function(e){return Aee(Aee({},e),{pages:e.pages.map((function(e){return Aee({},e)}))})})),a=n.findIndex((function(t){return t._id===e.pdfIdOfPage})),o=n[a].pages.findIndex((function(t){return t._id===e.pdfPageId}));return n[a].pages[o].pageImageElement=r,n})),Ee((function(e){return _ee([],e.filter((function(e){return e!==n._id})),!0)})),[2]}}))}))}),[Me,a]),He=l((function(e){return Ree(t,void 0,void 0,(function(){var t,n,r,c;return Nee(this,(function(i){switch(i.label){case 0:return t=e.pdfId,(n=a.find((function(e){return e._id===t})))?(r=n.pages.map((function(e){return e._id})),[4,Z.current.fetchOnlyPdfPagesData({excludePdfPageIds:r,pdfId:t,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"})]):[2];case 1:return c=i.sent(),o((function(e){var n=e.findIndex((function(e){return e._id===t}));return-1===n?e:(e[n].pages=_ee(_ee([],e[n].pages,!0),c.pages.map((function(e){return{_id:e._id,pdfId:e.pdfId,pageNumber:e.pageNumber,annotations:[],commentThreads:[],pageAsImageDetails:e.pageAsImageDetails,pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints}})),!0),_ee([],e,!0))})),[2]}}))}))}),[a,Z]),Ve=l((function(e){var n=e.pdfId,r=e.pdfPageId,a=e.annotationIds;return Ree(t,void 0,void 0,(function(){return Nee(this,(function(e){return o((function(e){return e.map((function(e){return e._id===n?Aee(Aee({},e),{pages:e.pages.map((function(e){return e._id===r?Aee(Aee({},e),{annotations:e.annotations.filter((function(e){return!a.includes(e._id)||(Z.current.deletePageAnnotation({annotationId:e._id}),!1)}))}):Aee({},e)}))}):Aee({},e)}))})),[2]}))}))}),[Z]),Ce=l((function(e){var t=e.pdfId,n=e.pdfPageId,r=e.annotations;o((function(e){return e.map((function(e){return e._id===t?Aee(Aee({},e),{pages:e.pages.map((function(e){return e._id===n?Aee(Aee({},e),{annotations:_ee(_ee([],e.annotations,!0),r,!0)}):Aee({pdfPageId:e._id},e)}))}):Aee({},e)}))}))}),[]),Le=c({rectangleAnnotationOptions:X,rectangleAnnotationData:{_id:"",color:"",height:0,width:0,pdfId:"",pdfPageId:"",rotationAngle:0,x:0,y:0},rectangleAnnotationConfigurationDrawer:{isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:""}}}}),we=Le[0],ke=Le[1],xe=h((function(){for(var e=null,t=0,n=a||[];t<n.length;t++)for(var r=0,o=n[t].pages||[];r<o.length;r++)for(var c=0,i=o[r].annotations||[];c<i.length;c++){var l=i[c];if(l._id===u)return l}return e}),[u]);s((function(){(null==xe?void 0:xe.rectangleAnnotation)?ke(yse((function(e){var t;e.rectangleAnnotationConfigurationDrawer.sections.color.currentlySelectedColor=(null===(t=xe.rectangleAnnotation)||void 0===t?void 0:t.color)||""}))):(y(yse((function(e){e.measureToolRelatedData.distanceAnnotation.configurationsDrawer.isOpen=!1}))),ke(yse((function(e){e.rectangleAnnotationConfigurationDrawer.isOpen=!1}))))}),[xe]);var Se=h((function(){return{pdfs:a,setPdfs:o,annotationSelectedId:u,setAnnotationSelectedId:m,toolSelected:v,setToolSelected:f,tools:g,setTools:y,currentUserId:E,setCurrentUserId:b,users:V,setUsers:C,isLeftBarOpen:_,setIsLeftBarOpen:D,isAnnotationsVisible:j,setIsAnnotationsVisible:U,backendBaseUrl:Q,fetchPdfRelatedData:pe,removeAnnotationsFromPdfPageAndDb:Ve,addAnnotationsToPdfPage:Ce,addPdfPageImageElementIfNotPresentAlready:be,setSelectedCommentThreadId:ve,pageZoomPercentage:A,setPageZoomPercentage:R,rlefEventServiceBaseUrl:J,addNewScaleDetails:fe,addScaleButtonClickedFromToolbar:ge,pdfEditorServiceRef:Z,fetchAndSetPdfPagesInPdfWhichAreCreatedInDB:He,pdfPageIdsForWhichPageImageElementIsBeingFetched:Me,callOutToolRelatedDataWhenSelected:ue,setCallOutToolRelatedDataWhenSelected:me,pdfEditorElementId:te,selectedToolGroup:$,setSelectedToolGroup:q,pdfIdsWhoseDataBeingFetched:re,annotationSelected:xe,editScaleDetails:ze,suggestedUsersForMention:w,fetchAndSetSuggestedUsersForMention:ce,isFetchingSuggestedUsersForMention:S,customCursorToShow:Y,setCustomCursorToShow:K,rectangleRelatedData:we,setRectangleRelatedData:ke}}),[a,u,v,g,E,V,_,j,Q,pe,be,ve,A,R,J,fe,ge,He,Me,ue,te,$,re,xe,ze,w,ce,S,Y,we]);return n(kse.Provider,Aee({value:Se},{children:e.children}))}var kse=a.createContext({}),xse=function(){var e=a.useContext(kse);if(!e)throw new Error("usePdfAnnotationContext must be used within a PdfEditorContextProvider");return e};kle(".ContentArea-module_content-area-container__otXm-{align-items:center;background-color:#e3e6e8;display:flex;flex:1;justify-content:center;overflow:auto;position:relative}");kle(".PdfPage-module_pageContainer__-Q0sD{display:flex;flex-grow:1;height:100%;width:100%}.PdfPage-module_pageContainerWhenHorizontallyOverflowingAndIsVisibleInViewport__8onR1{align-self:flex-start}.PdfPage-module_justifyContentCenter__-7ATB{justify-content:center}.PdfPage-module_selectedText__m7jFl span::selection{background-color:#ffff0045!important}.PdfPage-module_selectedText__m7jFl span::-moz-selection{background-color:#ffff0045!important}.PdfPage-module_displayNone__cHRJo{display:none}.PdfPage-module_handCursor__vsE7b{cursor:grab!important}.PdfPage-module_handCursor__vsE7b:active{cursor:grabbing!important}");var Sse=Math.PI/180;const Tse=void 0!==Dee?Dee:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Ose={_global:Tse,version:"8.4.3",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle:e=>Ose.angleDeg?e*Sse:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Ose.DD.isDragging,isDragReady:()=>!!Ose.DD.node,releaseCanvasOnDestroy:!0,document:Tse.document,_injectGlobal(e){Tse.Konva=e}},Ase=e=>{Ose[e.prototype.getClassName()]=e};Ose._injectGlobal(Ose);class Rse{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Rse(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){var t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,a=this.m[1]*t+this.m[3]*n,o=this.m[0]*-n+this.m[2]*t,c=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=a,this.m[2]=o,this.m[3]=c,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,a=this.m[2]+this.m[0]*e,o=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=a,this.m[3]=o,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],a=this.m[1]*e.m[2]+this.m[3]*e.m[3],o=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],c=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=a,this.m[4]=o,this.m[5]=c,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,a=this.m[0]*e,o=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),c=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=a,this.m[4]=o,this.m[5]=c,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],a=e*r-t*n;let o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=t){var c=Math.sqrt(e*e+t*t);o.rotation=t>0?Math.acos(e/c):-Math.acos(e/c),o.scaleX=c,o.scaleY=a/c,o.skewX=(e*n+t*r)/a,o.skewY=0}else if(0!=n||0!=r){var i=Math.sqrt(n*n+r*r);o.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),o.scaleX=a/i,o.scaleY=i,o.skewX=0,o.skewY=(e*n+t*r)/a}return o.rotation=jse._getRotation(o.rotation),o}}var Nse=Math.PI/180,_se=180/Math.PI,Dse="Konva error: ",Pse={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},Fse=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Ise=[];const Bse="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(e){setTimeout(e,60)},jse={_isElement:e=>!(!e||1!=e.nodeType),_isFunction:e=>!!(e&&e.constructor&&e.call&&e.apply),_isPlainObject:e=>!!e&&e.constructor===Object,_isArray:e=>"[object Array]"===Object.prototype.toString.call(e),_isNumber:e=>"[object Number]"===Object.prototype.toString.call(e)&&!isNaN(e)&&isFinite(e),_isString:e=>"[object String]"===Object.prototype.toString.call(e),_isBoolean:e=>"[object Boolean]"===Object.prototype.toString.call(e),isObject:e=>e instanceof Object,isValidSelector(e){if("string"!=typeof e)return!1;var t=e[0];return"#"===t||"."===t||t===t.toUpperCase()},_sign:e=>0===e||e>0?1:-1,requestAnimFrame(e){Ise.push(e),1===Ise.length&&Bse((function(){const e=Ise;Ise=[],e.forEach((function(e){e()}))}))},createCanvasElement(){var e=document.createElement("canvas");try{e.style=e.style||{}}catch(e){}return e},createImageElement:()=>document.createElement("img"),_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){var n=jse.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex:(e,t,n)=>((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1),_hexToRgb(e){e=e.replace("#","");var t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:255&t}},getRandomColor(){for(var e=(16777215*Math.random()|0).toString(16);e.length<6;)e="0"+e;return"#"+e},getRGB(e){var t;return e in Pse?{r:(t=Pse[e])[0],g:t[1],b:t[2]}:"#"===e[0]?this._hexToRgb(e.substring(1)):"rgb("===e.substr(0,4)?(t=Fse.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",jse._namedColorToRBA(e)||jse._hex3ColorToRGBA(e)||jse._hex4ColorToRGBA(e)||jse._hex6ColorToRGBA(e)||jse._hex8ColorToRGBA(e)||jse._rgbColorToRGBA(e)||jse._rgbaColorToRGBA(e)||jse._hslColorToRGBA(e)),_namedColorToRBA(e){var t=Pse[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(0===e.indexOf("rgb(")){var t=(e=e.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(0===e.indexOf("rgba(")){var t=(e=e.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((e,t)=>"%"===e.slice(-1)?3===t?parseInt(e)/100:parseInt(e)/100*255:Number(e)));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if("#"===e[0]&&9===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if("#"===e[0]&&7===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if("#"===e[0]&&5===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if("#"===e[0]&&4===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,a=Number(n[1])/100,o=Number(n[2])/100;let c,i,l;if(0===a)return l=255*o,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};c=o<.5?o*(1+a):o+a-o*a;const s=2*o-c,h=[0,0,0];for(let e=0;e<3;e++)i=r+1/3*-(e-1),i<0&&i++,i>1&&i--,l=6*i<1?s+6*(c-s)*i:2*i<1?c:3*i<2?s+(c-s)*(2/3-i)*6:s,h[e]=255*l;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection:(e,t)=>!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y),cloneObject(e){var t={};for(var n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray:e=>e.slice(0),degToRad:e=>e*Nse,radToDeg:e=>e*_se,_degToRad:e=>(jse.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),jse.degToRad(e)),_radToDeg:e=>(jse.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),jse.radToDeg(e)),_getRotation:e=>Ose.angleDeg?jse.radToDeg(e):e,_capitalize:e=>e.charAt(0).toUpperCase()+e.slice(1),throw(e){throw new Error(Dse+e)},error(e){console.error(Dse+e)},warn(e){Ose.showWarnings&&console.warn("Konva warning: "+e)},each(e,t){for(var n in e)t(n,e[n])},_inRange:(e,t,n)=>t<=e&&e<n,_getProjectionToSegment(e,t,n,r,a,o){var c,i,l,s=(e-n)*(e-n)+(t-r)*(t-r);if(0==s)c=e,i=t,l=(a-n)*(a-n)+(o-r)*(o-r);else{var h=((a-e)*(n-e)+(o-t)*(r-t))/s;h<0?(c=e,i=t,l=(e-a)*(e-a)+(t-o)*(t-o)):h>1?(c=n,i=r,l=(n-a)*(n-a)+(r-o)*(r-o)):l=((c=e+h*(n-e))-a)*(c-a)+((i=t+h*(r-t))-o)*(i-o)}return[c,i,l]},_getProjectionToLine(e,t,n){var r=jse.cloneObject(e),a=Number.MAX_VALUE;return t.forEach((function(o,c){if(n||c!==t.length-1){var i=t[(c+1)%t.length],l=jse._getProjectionToSegment(o.x,o.y,i.x,i.y,e.x,e.y),s=l[0],h=l[1],d=l[2];d<a&&(r.x=s,r.y=h,a=d)}})),r},_prepareArrayForTween(e,t,n){var r,a=[],o=[];if(e.length>t.length){var c=t;t=e,e=c}for(r=0;r<e.length;r+=2)a.push({x:e[r],y:e[r+1]});for(r=0;r<t.length;r+=2)o.push({x:t[r],y:t[r+1]});var i=[];return o.forEach((function(e){var t=jse._getProjectionToLine(e,a,n);i.push(t.x),i.push(t.y)})),i},_prepareToStringify(e){var t;for(var n in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||jse._isElement(e[n])){if(!t.configurable)return null;delete e[n]}else if(null===jse._prepareToStringify(e[n])){if(!t.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(var n in t)e[n]=t[n];return e},_getFirstPointerId:e=>e.touches?e.changedTouches[0].identifier:e.pointerId||999,releaseCanvas(...e){Ose.releaseCanvasOnDestroy&&e.forEach((e=>{e.width=0,e.height=0}))},drawRoundedRectPath(e,t,n,r){let a=0,o=0,c=0,i=0;"number"==typeof r?a=o=c=i=Math.min(r,t/2,n/2):(a=Math.min(r[0]||0,t/2,n/2),o=Math.min(r[1]||0,t/2,n/2),i=Math.min(r[2]||0,t/2,n/2),c=Math.min(r[3]||0,t/2,n/2)),e.moveTo(a,0),e.lineTo(t-o,0),e.arc(t-o,o,o,3*Math.PI/2,0,!1),e.lineTo(t,n-i),e.arc(t-i,n-i,i,0,Math.PI/2,!1),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(0,a),e.arc(a,a,a,Math.PI,3*Math.PI/2,!1)}};function Use(e){return jse._isString(e)?'"'+e+'"':"[object Number]"===Object.prototype.toString.call(e)||jse._isBoolean(e)?e:Object.prototype.toString.call(e)}function Wse(e){return e>255?255:e<0?0:Math.round(e)}function $se(){if(Ose.isUnminified)return function(e,t){return jse._isNumber(e)||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function qse(e){if(Ose.isUnminified)return function(t,n){let r=jse._isNumber(t),a=jse._isArray(t)&&t.length==e;return r||a||jse.warn(Use(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function Gse(){if(Ose.isUnminified)return function(e,t){return jse._isNumber(e)||"auto"===e||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Yse(){if(Ose.isUnminified)return function(e,t){return jse._isString(e)||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function Kse(){if(Ose.isUnminified)return function(e,t){const n=jse._isString(e),r="[object CanvasGradient]"===Object.prototype.toString.call(e)||e&&e.addColorStop;return n||r||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function Xse(){if(Ose.isUnminified)return function(e,t){return!0===e||!1===e||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}var Qse="get",Jse="set";const Zse={addGetterSetter(e,t,n,r,a){Zse.addGetter(e,t,n),Zse.addSetter(e,t,r,a),Zse.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){var r=Qse+jse._capitalize(t);e.prototype[r]=e.prototype[r]||function(){var e=this.attrs[t];return void 0===e?n:e}},addSetter(e,t,n,r){var a=Jse+jse._capitalize(t);e.prototype[a]||Zse.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){var a=Jse+jse._capitalize(t);e.prototype[a]=function(e){return n&&null!=e&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,a){var o,c,i=n.length,l=jse._capitalize,s=Qse+l(t),h=Jse+l(t);e.prototype[s]=function(){var e={};for(o=0;o<i;o++)e[c=n[o]]=this.getAttr(t+l(c));return e};var d=function(e){if(Ose.isUnminified)return function(t,n){return null==t||jse.isObject(t)||jse.warn(Use(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}(n);e.prototype[h]=function(e){var o,c=this.attrs[t];for(o in r&&(e=r.call(this,e)),d&&d.call(this,e,t),e)e.hasOwnProperty(o)&&this._setAttr(t+l(o),e[o]);return e||n.forEach((e=>{this._setAttr(t+l(e),void 0)})),this._fireChangeEvent(t,c,e),a&&a.call(this),this},Zse.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){var n=jse._capitalize(t),r=Jse+n,a=Qse+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[a]()}},addDeprecatedGetterSetter(e,t,n,r){jse.error("Adding deprecated "+t);var a=Qse+jse._capitalize(t),o=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[a]=function(){jse.error(o);var e=this.attrs[t];return void 0===e?n:e},Zse.addSetter(e,t,r,(function(){jse.error(o)})),Zse.addOverloadedGetterSetter(e,t)},backCompat(e,t){jse.each(t,(function(t,n){var r=e.prototype[n],a=Qse+jse._capitalize(t),o=Jse+jse._capitalize(t);function c(){r.apply(this,arguments),jse.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}e.prototype[t]=c,e.prototype[a]=c,e.prototype[o]=c}))},afterSetFilter(){this._filterUpToDate=!1}};var ehe,the=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class nhe{constructor(e){this.canvas=e,Ose.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){var n,r,a,o,c=this.traceArr,i=c.length,l="";for(n=0;n<i;n++)(a=(r=c[n]).method)?(o=r.args,l+=a,e?l+="()":jse._isArray(o[0])?l+="(["+o.join(",")+"])":(t&&(o=o.map((e=>"number"==typeof e?Math.floor(e):e))),l+="("+o.join(",")+")")):(l+=r.property,e||(l+="="+r.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr;t.push(e),t.length>=100&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();1!==t&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,a,o){this._context.arc(e,t,n,r,a,o)}arcTo(e,t,n,r,a){this._context.arcTo(e,t,n,r,a)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,a,o){this._context.bezierCurveTo(e,t,n,r,a,o)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var n=arguments;return 2===n.length?this._context.createImageData(e,t):1===n.length?this._context.createImageData(e):void 0}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,a,o){return this._context.createRadialGradient(e,t,n,r,a,o)}drawImage(e,t,n,r,a,o,c,i,l){var s=arguments,h=this._context;3===s.length?h.drawImage(e,t,n):5===s.length?h.drawImage(e,t,n,r,a):9===s.length&&h.drawImage(e,t,n,r,a,o,c,i,l)}ellipse(e,t,n,r,a,o,c,i){this._context.ellipse(e,t,n,r,a,o,c,i)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,a,o){this._context.setTransform(e,t,n,r,a,o)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,a,o){this._context.transform(e,t,n,r,a,o)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e,t,n=this,r=the.length,a=this.setAttr,o=function(e){var r,a=n[e];n[e]=function(){return t=function(e){var t,n,r=[],a=e.length,o=jse;for(t=0;t<a;t++)n=e[t],o._isNumber(n)?n=Math.round(1e3*n)/1e3:o._isString(n)||(n+=""),r.push(n);return r}(Array.prototype.slice.call(arguments,0)),r=a.apply(n,arguments),n._trace({method:e,args:t}),r}};for(e=0;e<r;e++)o(the[e]);n.setAttr=function(){a.apply(n,arguments);var e=arguments[0],t=arguments[1];"shadowOffsetX"!==e&&"shadowOffsetY"!==e&&"shadowBlur"!==e||(t/=this.canvas.getPixelRatio()),n._trace({property:e,val:t})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||"source-over"===t||this.setAttr("globalCompositeOperation",t)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(e){Object.defineProperty(nhe.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})}));class rhe extends nhe{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&"color"===n)return void this._fillColor(e);const r=e.getFillPatternImage();if(r&&"pattern"===n)return void this._fillPattern(e);const a=e.getFillLinearGradientColorStops();if(a&&"linear-gradient"===n)return void this._fillLinearGradient(e);const o=e.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(e):t?this._fillColor(e):r?this._fillPattern(e):a?this._fillLinearGradient(e):o&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),a=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(var o=0;o<r.length;o+=2)a.addColorStop(r[o],r[o+1]);this.setAttr("strokeStyle",a)}}_stroke(e){var t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r,a=null!==(t=e.getShadowRGBA())&&void 0!==t?t:"black",o=null!==(n=e.getShadowBlur())&&void 0!==n?n:5,c=null!==(r=e.getShadowOffset())&&void 0!==r?r:{x:0,y:0},i=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),s=i.x*l,h=i.y*l;this.setAttr("shadowColor",a),this.setAttr("shadowBlur",o*Math.min(Math.abs(s),Math.abs(h))),this.setAttr("shadowOffsetX",c.x*s),this.setAttr("shadowOffsetY",c.y*h)}}class ahe extends nhe{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const a=e.getStrokeScaleEnabled();if(!a){this.save();var t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(e);var n=e.hitStrokeWidth(),r="auto"===n?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),a||this.restore()}}}class ohe{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=(e||{}).pixelRatio||Ose.pixelRatio||function(){if(ehe)return ehe;var e=jse.createCanvasElement(),t=e.getContext("2d");return ehe=(Ose._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),jse.releaseCanvas(e),ehe}();this.pixelRatio=t,this._canvas=jse.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch(e){try{return this._canvas.toDataURL()}catch(e){return jse.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Zse.addGetterSetter(ohe,"pixelRatio",void 0,$se());class che extends ohe{constructor(e={width:0,height:0}){super(e),this.context=new rhe(this),this.setSize(e.width,e.height)}}class ihe extends ohe{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new ahe(this),this.setSize(e.width,e.height)}}const lhe={get isDragging(){var e=!1;return lhe._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return lhe._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const t=[];lhe._dragElements.forEach(((n,r)=>{const{node:a}=n,o=a.getStage();o.setPointersPositions(e),void 0===n.pointerId&&(n.pointerId=jse._getFirstPointerId(e));const c=o._changedPointerPositions.find((e=>e.id===n.pointerId));if(c){if("dragging"!==n.dragStatus){var i=a.dragDistance();if(Math.max(Math.abs(c.x-n.startPointerPos.x),Math.abs(c.y-n.startPointerPos.y))<i)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,n),t.push(a)}})),t.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(e){const t=[];lhe._dragElements.forEach((n=>{const{node:r}=n,a=r.getStage();if(e&&a.setPointersPositions(e),!a._changedPointerPositions.find((e=>e.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(lhe.justDragged=!0,Ose._mouseListenClick=!1,Ose._touchListenClick=!1,Ose._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof Ose.Stage&&n.node;o&&-1===t.indexOf(o)&&t.push(o)})),t.forEach((e=>{e.draw()}))},_endDragAfter(e){lhe._dragElements.forEach(((t,n)=>{"stopped"===t.dragStatus&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),"dragging"!==t.dragStatus&&lhe._dragElements.delete(n)}))}};Ose.isBrowser&&(window.addEventListener("mouseup",lhe._endDragBefore,!0),window.addEventListener("touchend",lhe._endDragBefore,!0),window.addEventListener("mousemove",lhe._drag),window.addEventListener("touchmove",lhe._drag),window.addEventListener("mouseup",lhe._endDragAfter,!1),window.addEventListener("touchend",lhe._endDragAfter,!1));var she="absoluteOpacity",hhe="allEventListeners",dhe="absoluteTransform",uhe="absoluteScale",mhe="canvas",phe="listening",vhe="mouseenter",fhe="mouseleave",zhe="Shape",ghe=" ",yhe="stage",Mhe="transform",Ehe="visible",bhe=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(ghe);let Hhe=1;class Vhe{constructor(e){this._id=Hhe++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){e!==Mhe&&e!==dhe||!this._cache.get(e)?e?this._cache.delete(e):this._cache.clear():this._cache.get(e).dirty=!0}_getCache(e,t){var n=this._cache.get(e);return(void 0===n||(e===Mhe||e===dhe)&&!0===n.dirty)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){const n=t.map((e=>e+"Change.konva")).join(ghe);this.on(n,(()=>{this._clearCache(e)})),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(mhe)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===dhe&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(mhe)){const{scene:e,filter:t,hit:n}=this._cache.get(mhe);jse.releaseCanvas(e,t,n),this._cache.delete(mhe)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},n={};void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var r=Math.ceil(t.width||n.width),a=Math.ceil(t.height||n.height),o=t.pixelRatio,c=void 0===t.x?Math.floor(n.x):t.x,i=void 0===t.y?Math.floor(n.y):t.y,l=t.offset||0,s=t.drawBorder||!1,h=t.hitCanvasPixelRatio||1;if(r&&a){c-=l,i-=l;var d=new che({pixelRatio:o,width:r+=2*l+1,height:a+=2*l+1}),u=new che({pixelRatio:o,width:0,height:0}),m=new ihe({pixelRatio:h,width:r,height:a}),p=d.getContext(),v=m.getContext();return m.isCache=!0,d.isCache=!0,this._cache.delete(mhe),this._filterUpToDate=!1,!1===t.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),v.save(),p.translate(-c,-i),v.translate(-c,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(she),this._clearSelfAndDescendantCache(uhe),this.drawScene(d,this),this.drawHit(m,this),this._isUnderCache=!1,p.restore(),v.restore(),s&&(p.save(),p.beginPath(),p.rect(0,0,r,a),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(mhe,{scene:d,filter:u,hit:m,x:c,y:i}),this._requestDraw(),this}jse.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")}isCached(){return this._cache.has(mhe)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var n,r,a,o,c=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],i=this.getAbsoluteTransform(t);return c.forEach((function(e){var t=i.point(e);void 0===n&&(n=a=t.x,r=o=t.y),n=Math.min(n,t.x),r=Math.min(r,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y)})),{x:n,y:r,width:a-n,height:o-r}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e,t,n,r,a=this.filters(),o=this._getCanvasCache(),c=o.scene,i=o.filter,l=i.getContext();if(a){if(!this._filterUpToDate){var s=c.pixelRatio;i.setSize(c.width/c.pixelRatio,c.height/c.pixelRatio);try{for(e=a.length,l.clear(),l.drawImage(c._canvas,0,0,c.getWidth()/s,c.getHeight()/s),t=l.getImageData(0,0,i.getWidth(),i.getHeight()),n=0;n<e;n++)"function"==typeof(r=a[n])?(r.call(this,t),l.putImageData(t,0,0)):jse.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){jse.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return i}return c}on(e,t){if(this._cache&&this._cache.delete(hhe),3===arguments.length)return this._delegate.apply(this,arguments);var n,r,a,o,c=e.split(ghe),i=c.length;for(n=0;n<i;n++)a=(r=c[n].split("."))[0],o=r[1]||"",this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:o,handler:t});return this}off(e,t){var n,r,a,o,c,i=(e||"").split(ghe),l=i.length;if(this._cache&&this._cache.delete(hhe),!e)for(r in this.eventListeners)this._off(r);for(n=0;n<l;n++)if(o=(a=i[n].split("."))[0],c=a[1],o)this.eventListeners[o]&&this._off(o,c,t);else for(r in this.eventListeners)this._off(r,c,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,(function(e){t.call(this,e.evt)})),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){var r=this;this.on(e,(function(e){for(var a=e.target.findAncestors(t,!0,r),o=0;o<a.length;o++)(e=jse.cloneObject(e)).currentTarget=a[o],n.call(a[o],e)}))}remove(){return this.isDragging()&&this.stopDrag(),lhe._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(dhe),this._clearSelfAndDescendantCache(she),this._clearSelfAndDescendantCache(uhe),this._clearSelfAndDescendantCache(yhe),this._clearSelfAndDescendantCache(Ehe),this._clearSelfAndDescendantCache(phe)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var t="get"+jse._capitalize(e);return jse._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{var t,n;if(!e)return this;for(t in e)"children"!==t&&(n="set"+jse._capitalize(t),jse._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))})),this}isListening(){return this._getCache(phe,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return!t||t===e||this===e||t._isListening(e)}isVisible(){return this._getCache(Ehe,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return!t||t===e||this===e||t._isVisible(e)}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var n=this.getLayer(),r=!1;lhe._dragElements.forEach((e=>{"dragging"===e.dragStatus&&("Stage"===e.node.nodeType||e.node.getLayer()===n)&&(r=!0)}));var a=!t&&!Ose.hitOnDragEnabled&&r;return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e,t,n,r,a=this.getDepth(),o=this,c=0;return"Stage"!==o.nodeType&&function i(l){for(e=[],t=l.length,n=0;n<t;n++)r=l[n],c++,r.nodeType!==zhe&&(e=e.concat(r.getChildren().slice())),r._id===o._id&&(n=t);e.length>0&&e[0].getDepth()<=a&&i(e)}(o.getStage().getChildren()),c}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Mhe),this._clearSelfAndDescendantCache(dhe)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges((()=>{this.x(e.x),this.y(e.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);var r=this.getAbsoluteTransform(e).getMatrix(),a=new Rse,o=this.offset();return a.m=r.slice(),a.translate(o.x,o.y),a.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(Mhe);var n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(e.x,e.y),e={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(Mhe),this._clearSelfAndDescendantCache(dhe),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var t=e.x,n=e.y,r=this.x(),a=this.y();return void 0!==t&&(r+=t),void 0!==n&&(a+=n),this.setPosition({x:r,y:a}),this}_eachAncestorReverse(e,t){var n,r,a=[],o=this.getParent();if(!t||t._id!==this._id){for(a.unshift(this);o&&(!t||o._id!==t._id);)a.unshift(o),o=o.parent;for(n=a.length,r=0;r<n;r++)e(a[r])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return jse.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return jse.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return jse.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return jse.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return jse.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&jse.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(she,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e,t,n,r,a={},o=this.getAttrs();for(e in a.attrs={},o)t=o[e],jse.isObject(t)&&!jse._isPlainObject(t)&&!jse._isArray(t)||(n="function"==typeof this[e]&&this[e],delete o[e],r=n?n.call(this):null,o[e]=t,r!==t&&(a.attrs[e]=t));return a.className=this.getClassName(),jse._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){var r=[];t&&this._isMatch(e)&&r.push(this);for(var a=this.parent;a;){if(a===n)return r;a._isMatch(e)&&r.push(a),a=a.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);var t,n,r=e.replace(/ /g,"").split(","),a=r.length;for(t=0;t<a;t++)if(n=r[t],jse.isValidSelector(n)||(jse.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),jse.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),jse.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(yhe,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():void 0}fire(e,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(dhe,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Rse,this._eachAncestorReverse((function(e){var n=e.transformsEnabled();"all"===n?t.multiply(e.getTransform()):"position"===n&&t.translate(e.x()-e.offsetX(),e.y()-e.offsetY())}),e),t;t=this._cache.get(dhe)||new Rse,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var n=this.transformsEnabled();if("all"===n)t.multiply(this.getTransform());else if("position"===n){const e=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,a=this.attrs.offsetY||0;t.translate(e-r,n-a)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Mhe,this._getTransform)}_getTransform(){var e,t,n=this._cache.get(Mhe)||new Rse;n.reset();var r=this.x(),a=this.y(),o=Ose.getAngle(this.rotation()),c=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,i=null!==(t=this.attrs.scaleY)&&void 0!==t?t:1,l=this.attrs.skewX||0,s=this.attrs.skewY||0,h=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===r&&0===a||n.translate(r,a),0!==o&&n.rotate(o),0===l&&0===s||n.skew(l,s),1===c&&1===i||n.scale(c,i),0===h&&0===d||n.translate(-1*h,-1*d),n.dirty=!1,n}clone(e){var t,n,r,a,o,c=jse.cloneObject(this.attrs);for(t in e)c[t]=e[t];var i=new this.constructor(c);for(t in this.eventListeners)for(r=(n=this.eventListeners[t]).length,a=0;a<r;a++)(o=n[a]).name.indexOf("konva")<0&&(i.eventListeners[t]||(i.eventListeners[t]=[]),i.eventListeners[t].push(o));return i}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),n=this.getStage(),r=void 0!==e.x?e.x:Math.floor(t.x),a=void 0!==e.y?e.y:Math.floor(t.y),o=e.pixelRatio||1,c=new che({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:o}),i=c.getContext();return!1===e.imageSmoothingEnabled&&(i._context.imageSmoothingEnabled=!1),i.save(),(r||a)&&i.translate(-1*r,-1*a),this.drawScene(c),i.restore(),c}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){var t=(e=e||{}).mimeType||null,n=e.quality||null,r=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(r),r}toImage(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,jse._urlToImage(this.toDataURL(e),(function(e){t(e),null==n||n(e)}))}catch(e){n(e)}}))}toBlob(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob((e=>{t(e),null==n||n(e)}))}catch(e){n(e)}}))}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Ose.dragDistance}_off(e,t,n){var r,a,o,c=this.eventListeners[e];for(r=0;r<c.length;r++)if(a=c[r].name,o=c[r].handler,!("konva"===a&&"konva"!==t||t&&a!==t||n&&n!==o)){if(c.splice(r,1),0===c.length){delete this.eventListeners[e];break}r--}}_fireChangeEvent(e,t,n){this._fire(e+"Change",{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){var t=this.name(),n=t?t+" "+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;const t=this.name();return!!t&&-1!==(t||"").split(/\s/g).indexOf(e)}removeName(e){var t=(this.name()||"").split(/\s/g),n=t.indexOf(e);return-1!==n&&(t.splice(n,1),this.name(t.join(" "))),this}setAttr(e,t){var n=this["set"+jse._capitalize(e)];return jse._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(Ose.autoDrawEnabled){const e=this.getLayer()||this.getStage();null==e||e.batchDraw()}}_setAttr(e,t){var n=this.attrs[e];(n!==t||jse.isObject(t))&&(null==t?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){var r;void 0!==n&&((r=this.attrs[e])||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,r,n))}_fireAndBubble(e,t,n){if(t&&this.nodeType===zhe&&(t.target=this),e!==vhe&&e!==fhe||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(e,t);var r=(e===vhe||e===fhe)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!r&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(hhe);if(!t){t={};let e=Object.getPrototypeOf(this);for(;e;)if(e.eventListeners){for(var n in e.eventListeners){const r=e.eventListeners[n],a=t[n]||[];t[n]=r.concat(a)}e=Object.getPrototypeOf(e)}else e=Object.getPrototypeOf(e);this._cache.set(hhe,t)}return t[e]}_fire(e,t){(t=t||{}).currentTarget=this,t.type=e;const n=this._getProtoListeners(e);if(n)for(var r=0;r<n.length;r++)n[r].handler.call(this,t);const a=this.eventListeners[e];if(a)for(r=0;r<a.length;r++)a[r].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition(),a=n._getPointerById(t)||n._changedPointerPositions[0]||r;lhe._dragElements.set(this._id,{node:this,startPointerPos:a,offset:{x:a.x-r.x,y:a.y-r.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){lhe._dragElements.has(this._id)||this._createDragElement(e),lhe._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const n=this.getStage()._getPointerById(t.pointerId);if(n){var r={x:n.x-t.offset.x,y:n.y-t.offset.y},a=this.dragBoundFunc();if(void 0!==a){const t=a.call(this,r,e);t?r=t:jse.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(e){const t=lhe._dragElements.get(this._id);t&&(t.dragStatus="stopped"),lhe._endDragBefore(e),lhe._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=lhe._dragElements.get(this._id);return!!e&&"dragging"===e.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(e){if((void 0===e.evt.button||Ose.dragButtons.indexOf(e.evt.button)>=0)&&!this.isDragging()){var t=!1;lhe._dragElements.forEach((e=>{this.isAncestorOf(e.node)&&(t=!0)})),t||this._createDragElement(e)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const e=lhe._dragElements.get(this._id),t=e&&"dragging"===e.dragStatus,n=e&&"ready"===e.dragStatus;t?this.stopDrag():n&&lhe._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return jse.haveIntersection(n,this.getClientRect())}static create(e,t){return jse._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var n,r,a,o=Vhe.prototype.getClassName.call(e),c=e.children;if(t&&(e.attrs.container=t),Ose[o]||(jse.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new Ose[o](e.attrs),c)for(r=c.length,a=0;a<r;a++)n.add(Vhe._createNode(c[a]));return n}}Vhe.prototype.nodeType="Node",Vhe.prototype._attrsAffectingSize=[],Vhe.prototype.eventListeners={},Vhe.prototype.on.call(Vhe.prototype,bhe,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Mhe),this._clearSelfAndDescendantCache(dhe))})),Vhe.prototype.on.call(Vhe.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(Ehe)})),Vhe.prototype.on.call(Vhe.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(phe)})),Vhe.prototype.on.call(Vhe.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(she)}));const Che=Zse.addGetterSetter;Che(Vhe,"zIndex"),Che(Vhe,"absolutePosition"),Che(Vhe,"position"),Che(Vhe,"x",0,$se()),Che(Vhe,"y",0,$se()),Che(Vhe,"globalCompositeOperation","source-over",Yse()),Che(Vhe,"opacity",1,$se()),Che(Vhe,"name","",Yse()),Che(Vhe,"id","",Yse()),Che(Vhe,"rotation",0,$se()),Zse.addComponentsGetterSetter(Vhe,"scale",["x","y"]),Che(Vhe,"scaleX",1,$se()),Che(Vhe,"scaleY",1,$se()),Zse.addComponentsGetterSetter(Vhe,"skew",["x","y"]),Che(Vhe,"skewX",0,$se()),Che(Vhe,"skewY",0,$se()),Zse.addComponentsGetterSetter(Vhe,"offset",["x","y"]),Che(Vhe,"offsetX",0,$se()),Che(Vhe,"offsetY",0,$se()),Che(Vhe,"dragDistance",null,$se()),Che(Vhe,"width",0,$se()),Che(Vhe,"height",0,$se()),Che(Vhe,"listening",!0,Xse()),Che(Vhe,"preventDefault",!0,Xse()),Che(Vhe,"filters",null,(function(e){return this._filterUpToDate=!1,e})),Che(Vhe,"visible",!0,Xse()),Che(Vhe,"transformsEnabled","all",Yse()),Che(Vhe,"size"),Che(Vhe,"dragBoundFunc"),Che(Vhe,"draggable",!1,Xse()),Zse.backCompat(Vhe,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Lhe extends Vhe{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var n=[];return t.forEach((function(t){e(t)&&n.push(t)})),n}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.destroy()})),this.children=[],this._requestDraw(),this}add(...e){if(0===e.length)return this;if(e.length>1){for(var t=0;t<e.length;t++)this.add(e[t]);return this}const n=e[0];return n.getParent()?(n.moveTo(this),this):(this._validateAdd(n),n.index=this.getChildren().length,n.parent=this,n._clearCaches(),this.getChildren().push(n),this._fire("add",{child:n}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var n=[];return this._descendants((r=>{const a=r._isMatch(e);return a&&n.push(r),!(!a||!t)})),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){var e=Vhe.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach((t=>{e.children.push(t.toObject())})),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=Vhe.prototype.clone.call(this,e);return this.getChildren().forEach((function(e){t.add(e.clone())})),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach((function(n){n.isVisible()&&n.intersects(e)&&t.push(n)})),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),this.isCached()||null===(t=this.children)||void 0===t||t.forEach((function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;null===(e=this.children)||void 0===e||e.forEach((function(e,t){e.index=t})),this._requestDraw()}drawScene(e,t){var n=this.getLayer(),r=e||n&&n.getCanvas(),a=r&&r.getContext(),o=this._getCanvasCache(),c=o&&o.scene,i=r&&r.isCache;if(!this.isVisible()&&!i)return this;if(c){a.save();var l=this.getAbsoluteTransform(t).getMatrix();a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var n=this.getLayer(),r=e||n&&n.hitCanvas,a=r&&r.getContext(),o=this._getCanvasCache();if(o&&o.hit){a.save();var c=this.getAbsoluteTransform(t).getMatrix();a.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(a),a.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n){var r,a=t&&t.getContext(),o=this.clipWidth(),c=this.clipHeight(),i=this.clipFunc(),l=o&&c||i;const s=n===this;if(l){a.save();var h=this.getAbsoluteTransform(n),d=h.getMatrix();if(a.transform(d[0],d[1],d[2],d[3],d[4],d[5]),a.beginPath(),i)i.call(this,a,this);else{var u=this.clipX(),m=this.clipY();a.rect(u,m,o,c)}a.clip(),d=h.copy().invert().getMatrix(),a.transform(d[0],d[1],d[2],d[3],d[4],d[5])}var p=!s&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===e;p&&(a.save(),a._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[e](t,n)})),p&&a.restore(),l&&a.restore()}getClientRect(e){var t,n,r,a,o,c,i=(e=e||{}).skipTransform,l=e.relativeTo,s=this;null===(t=this.children)||void 0===t||t.forEach((function(t){if(t.visible()){var c=t.getClientRect({relativeTo:s,skipShadow:e.skipShadow,skipStroke:e.skipStroke});0===c.width&&0===c.height||(void 0===n?(n=c.x,r=c.y,a=c.x+c.width,o=c.y+c.height):(n=Math.min(n,c.x),r=Math.min(r,c.y),a=Math.max(a,c.x+c.width),o=Math.max(o,c.y+c.height)))}}));for(var h=this.find("Shape"),d=!1,u=0;u<h.length;u++)if(h[u]._isVisible(this)){d=!0;break}return c=d&&void 0!==n?{x:n,y:r,width:a-n,height:o-r}:{x:0,y:0,width:0,height:0},i?c:this._transformedRect(c,l)}}Zse.addComponentsGetterSetter(Lhe,"clip",["x","y","width","height"]),Zse.addGetterSetter(Lhe,"clipX",void 0,$se()),Zse.addGetterSetter(Lhe,"clipY",void 0,$se()),Zse.addGetterSetter(Lhe,"clipWidth",void 0,$se()),Zse.addGetterSetter(Lhe,"clipHeight",void 0,$se()),Zse.addGetterSetter(Lhe,"clipFunc");const whe=new Map,khe=void 0!==Ose._global.PointerEvent;function xhe(e){return whe.get(e)}function She(e){return{evt:e,pointerId:e.pointerId}}function The(e,t){return whe.get(e)===t}function Ohe(e,t){Ahe(e),t.getStage()&&(whe.set(e,t),khe&&t._fire("gotpointercapture",She(new PointerEvent("gotpointercapture"))))}function Ahe(e,t){const n=whe.get(e);if(!n)return;const r=n.getStage();r&&r.content,whe.delete(e),khe&&n._fire("lostpointercapture",She(new PointerEvent("lostpointercapture")))}var Rhe="mouseleave",Nhe="mouseover",_he="mouseenter",Dhe="mousemove",Phe="mousedown",Fhe="mouseup",Ihe="pointermove",Bhe="pointerdown",jhe="pointerup",Uhe="pointercancel",Whe="pointerout",$he="pointerleave",qhe="pointerover",Ghe="pointerenter",Yhe="contextmenu",Khe="touchstart",Xhe="touchend",Qhe="touchmove",Jhe="touchcancel",Zhe="wheel",ede=[[_he,"_pointerenter"],[Phe,"_pointerdown"],[Dhe,"_pointermove"],[Fhe,"_pointerup"],[Rhe,"_pointerleave"],[Khe,"_pointerdown"],[Qhe,"_pointermove"],[Xhe,"_pointerup"],[Jhe,"_pointercancel"],[Nhe,"_pointerover"],[Zhe,"_wheel"],[Yhe,"_contextmenu"],[Bhe,"_pointerdown"],[Ihe,"_pointermove"],[jhe,"_pointerup"],[Uhe,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const tde={mouse:{[Whe]:"mouseout",[$he]:Rhe,[qhe]:Nhe,[Ghe]:_he,[Ihe]:Dhe,[Bhe]:Phe,[jhe]:Fhe,[Uhe]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Whe]:"touchout",[$he]:"touchleave",[qhe]:"touchover",[Ghe]:"touchenter",[Ihe]:Qhe,[Bhe]:Khe,[jhe]:Xhe,[Uhe]:Jhe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Whe]:Whe,[$he]:$he,[qhe]:qhe,[Ghe]:Ghe,[Ihe]:Ihe,[Bhe]:Bhe,[jhe]:jhe,[Uhe]:Uhe,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},nde=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",rde=e=>{const t=nde(e);return"pointer"===t?Ose.pointerEventsEnabled&&tde.pointer:"touch"===t?tde.touch:"mouse"===t?tde.mouse:void 0};function ade(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&jse.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}const ode=[];class cde extends Lhe{constructor(e){super(ade(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),ode.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{ade(this.attrs)})),this._checkVisibility()}_validateAdd(e){const t="Layer"===e.getType(),n="FastLayer"===e.getType();t||n||jse.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if("string"==typeof e){if("."===e.charAt(0)){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var n;n="#"!==e.charAt(0)?e:e.slice(1),e=document.getElementById(n)}if(!e)throw"Can not find container in document with id "+n}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e,t=this.children,n=t.length;for(e=0;e<n;e++)t[e].clear();return this}clone(e){return e||(e={}),e.container="undefined"!=typeof document&&document.createElement("div"),Lhe.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&jse._isInDocument(e)&&this.container().removeChild(e);var t=ode.indexOf(this);return t>-1&&ode.splice(t,1),jse.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(jse.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(e){return this._pointerPositions.find((t=>t.id===e))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){(e=e||{}).x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();var t=new che({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach((function(t){if(t.isVisible()){var r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}})),t}getIntersection(e){if(!e)return null;var t,n=this.children;for(t=n.length-1;t>=0;t--){const r=n[t].getIntersection(e);if(r)return r}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+"px",this.content.style.height=t+"px"),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach((n=>{n.setSize({width:e,height:t}),n.draw()}))}add(e,...t){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(e);var r=this.children.length;return r>5&&jse.warn("The stage has "+r+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),Ose.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return The(e,this)}setPointerCapture(e){Ohe(e,this)}releaseCapture(e){Ahe(e)}getLayers(){return this.children}_bindContentEvents(){Ose.isBrowser&&ede.forEach((([e,t])=>{this.content.addEventListener(e,(e=>{this[t](e)}),{passive:!1})}))}_pointerenter(e){this.setPointersPositions(e);const t=rde(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=rde(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=rde(e.type),n=nde(e.type);if(t){this.setPointersPositions(e);var r=this._getTargetShape(n),a=!lhe.isDragging||Ose.hitOnDragEnabled;r&&a?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):a&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=rde(e.type),n=nde(e.type);if(t){this.setPointersPositions(e);var r=!1;this._changedPointerPositions.forEach((a=>{var o=this.getIntersection(a);if(lhe.justDragged=!1,Ose["_"+n+"ListenClick"]=!0,!o||!o.isListening())return;Ose.capturePointerEventsEnabled&&o.setPointerCapture(a.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(t.pointerdown,{evt:e,pointerId:a.id}),r=!0;const c=e.type.indexOf("touch")>=0;o.preventDefault()&&e.cancelable&&c&&e.preventDefault()})),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=rde(e.type),n=nde(e.type);if(!t)return;if(lhe.isDragging&&lhe.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e),lhe.isDragging&&!Ose.hitOnDragEnabled)return;var r={};let a=!1;var o=this._getTargetShape(n);this._changedPointerPositions.forEach((c=>{const i=xhe(c.id)||this.getIntersection(c),l=c.id,s={evt:e,pointerId:l};var h=o!==i;if(h&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},s),i),o._fireAndBubble(t.pointerleave,Object.assign({},s),i)),i){if(r[i._id])return;r[i._id]=!0}i&&i.isListening()?(a=!0,h&&(i._fireAndBubble(t.pointerover,Object.assign({},s),o),i._fireAndBubble(t.pointerenter,Object.assign({},s),o),this[n+"targetShape"]=i),i._fireAndBubble(t.pointermove,Object.assign({},s))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:l}),this[n+"targetShape"]=null)})),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=rde(e.type),n=nde(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],a=this[n+"ClickEndShape"];var o={};let c=!1;this._changedPointerPositions.forEach((i=>{const l=xhe(i.id)||this.getIntersection(i);if(l){if(l.releaseCapture(i.id),o[l._id])return;o[l._id]=!0}const s=i.id,h={evt:e,pointerId:s};let d=!1;Ose["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):lhe.justDragged||(Ose["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){Ose["_"+n+"InDblClickWindow"]=!1}),Ose.dblClickWindow),l&&l.isListening()?(c=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,Object.assign({},h)),Ose["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,Object.assign({},h)),d&&a&&a===l&&l._fireAndBubble(t.pointerdblclick,Object.assign({},h)))):(this[n+"ClickEndShape"]=null,Ose["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:s}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:s}))})),c||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Ose["_"+n+"ListenClick"]=!1,e.cancelable&&"touch"!==n&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Yhe,{evt:e}):this._fire(Yhe,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Zhe,{evt:e}):this._fire(Zhe,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=xhe(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(jhe,She(e)),Ahe(e.pointerId)}_lostpointercapture(e){Ahe(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),n=null,r=null;void 0!==(e=e||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,(e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})})),Array.prototype.forEach.call(e.changedTouches||e.touches,(e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:jse._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:jse._getFirstPointerId(e)}])}_setPointerPosition(e){jse.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new che({width:this.width(),height:this.height()}),this.bufferHitCanvas=new ihe({pixelRatio:1,width:this.width(),height:this.height()}),Ose.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return jse.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(e){e.batchDraw()})),this}}cde.prototype.nodeType="Stage",Ase(cde),Zse.addGetterSetter(cde,"container");var ide="hasShadow",lde="shadowRGBA",sde="patternImage",hde="linearGradient",dde="radialGradient";let ude;function mde(){return ude||(ude=jse.createCanvasElement().getContext("2d"),ude)}const pde={};class vde extends Vhe{constructor(e){let t;for(super(e);t=jse.getRandomColor(),!t||t in pde;);this.colorKey=t,pde[t]=this}getContext(){return jse.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return jse.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(ide,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(sde,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=mde().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Rse;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Ose.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(hde,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=mde(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),a=t.createLinearGradient(n.x,n.y,r.x,r.y),o=0;o<e.length;o+=2)a.addColorStop(e[o],e[o+1]);return a}}_getRadialGradient(){return this._getCache(dde,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=mde(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),a=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),o=0;o<e.length;o+=2)a.addColorStop(e[o],e[o+1]);return a}}getShadowRGBA(){return this._getCache(lde,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=jse.colorToRGBA(this.shadowColor());return e?"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const e=this.hitStrokeWidth();return"auto"===e?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var t=this.getStage().bufferHitCanvas;return t.getContext().clear(),this.drawHit(t,null,!0),t.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return Vhe.prototype.destroy.call(this),delete pde[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage())return!1;if(null!==(t=this.attrs.perfectDrawEnabled)&&void 0!==t&&!t)return!1;const n=e||this.hasFill(),r=this.hasStroke(),a=1!==this.getAbsoluteOpacity();if(n&&r&&a)return!0;const o=this.hasShadow(),c=this.shadowForStrokeEnabled();return!!(n&&r&&o&&c)}setStrokeHitEnabled(e){jse.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const t=e.skipTransform,n=e.relativeTo,r=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+a,c=r.height+a,i=!e.skipShadow&&this.hasShadow(),l=i?this.shadowOffsetX():0,s=i?this.shadowOffsetY():0,h=o+Math.abs(l),d=c+Math.abs(s),u=i&&this.shadowBlur()||0,m={width:h+2*u,height:d+2*u,x:-(a/2+u)+Math.min(l,0)+r.x,y:-(a/2+u)+Math.min(s,0)+r.y};return t?m:this._transformedRect(m,n)}drawScene(e,t){var n,r,a=this.getLayer(),o=e||a.getCanvas(),c=o.getContext(),i=this._getCanvasCache(),l=this.getSceneFunc(),s=this.hasShadow(),h=o.isCache,d=t===this;if(!this.isVisible()&&!d)return this;if(i){c.save();var u=this.getAbsoluteTransform(t).getMatrix();return c.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(c),c.restore(),this}if(!l)return this;if(c.save(),this._useBufferCanvas()&&!h){(r=(n=this.getStage().bufferCanvas).getContext()).clear(),r.save(),r._applyLineJoin(this);var m=this.getAbsoluteTransform(t).getMatrix();r.transform(m[0],m[1],m[2],m[3],m[4],m[5]),l.call(this,r,this),r.restore();var p=n.pixelRatio;s&&c._applyShadow(this),c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(n._canvas,0,0,n.width/p,n.height/p)}else c._applyLineJoin(this),d||(m=this.getAbsoluteTransform(t).getMatrix(),c.transform(m[0],m[1],m[2],m[3],m[4],m[5]),c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),s&&c._applyShadow(this),l.call(this,c,this);return c.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;var r=this.getLayer(),a=e||r.hitCanvas,o=a&&a.getContext(),c=this.hitFunc()||this.sceneFunc(),i=this._getCanvasCache(),l=i&&i.hit;if(this.colorKey||jse.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();var s=this.getAbsoluteTransform(t).getMatrix();return o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!c)return this;if(o.save(),o._applyLineJoin(this),this!==t){var h=this.getAbsoluteTransform(t).getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}return c.call(this,o,this),o.restore(),this}drawHitFromCache(e=0){var t,n,r,a,o,c=this._getCanvasCache(),i=this._getCachedSceneCanvas(),l=c.hit,s=l.getContext(),h=l.getWidth(),d=l.getHeight();s.clear(),s.drawImage(i._canvas,0,0,h,d);try{for(r=(n=(t=s.getImageData(0,0,h,d)).data).length,a=jse._hexToRgb(this.colorKey),o=0;o<r;o+=4)n[o+3]>e?(n[o]=a.r,n[o+1]=a.g,n[o+2]=a.b,n[o+3]=255):n[o+3]=0;s.putImageData(t,0,0)}catch(e){jse.error("Unable to draw hit graph from cached scene canvas. "+e.message)}return this}hasPointerCapture(e){return The(e,this)}setPointerCapture(e){Ohe(e,this)}releaseCapture(e){Ahe(e)}}vde.prototype._fillFunc=function(e){e.fill()},vde.prototype._strokeFunc=function(e){e.stroke()},vde.prototype._fillFuncHit=function(e){e.fill()},vde.prototype._strokeFuncHit=function(e){e.stroke()},vde.prototype._centroid=!1,vde.prototype.nodeType="Shape",Ase(vde),vde.prototype.eventListeners={},vde.prototype.on.call(vde.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(ide)})),vde.prototype.on.call(vde.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(lde)})),vde.prototype.on.call(vde.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(sde)})),vde.prototype.on.call(vde.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(hde)})),vde.prototype.on.call(vde.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(dde)})),Zse.addGetterSetter(vde,"stroke",void 0,Kse()),Zse.addGetterSetter(vde,"strokeWidth",2,$se()),Zse.addGetterSetter(vde,"fillAfterStrokeEnabled",!1),Zse.addGetterSetter(vde,"hitStrokeWidth","auto",Gse()),Zse.addGetterSetter(vde,"strokeHitEnabled",!0,Xse()),Zse.addGetterSetter(vde,"perfectDrawEnabled",!0,Xse()),Zse.addGetterSetter(vde,"shadowForStrokeEnabled",!0,Xse()),Zse.addGetterSetter(vde,"lineJoin"),Zse.addGetterSetter(vde,"lineCap"),Zse.addGetterSetter(vde,"sceneFunc"),Zse.addGetterSetter(vde,"hitFunc"),Zse.addGetterSetter(vde,"dash"),Zse.addGetterSetter(vde,"dashOffset",0,$se()),Zse.addGetterSetter(vde,"shadowColor",void 0,Yse()),Zse.addGetterSetter(vde,"shadowBlur",0,$se()),Zse.addGetterSetter(vde,"shadowOpacity",1,$se()),Zse.addComponentsGetterSetter(vde,"shadowOffset",["x","y"]),Zse.addGetterSetter(vde,"shadowOffsetX",0,$se()),Zse.addGetterSetter(vde,"shadowOffsetY",0,$se()),Zse.addGetterSetter(vde,"fillPatternImage"),Zse.addGetterSetter(vde,"fill",void 0,Kse()),Zse.addGetterSetter(vde,"fillPatternX",0,$se()),Zse.addGetterSetter(vde,"fillPatternY",0,$se()),Zse.addGetterSetter(vde,"fillLinearGradientColorStops"),Zse.addGetterSetter(vde,"strokeLinearGradientColorStops"),Zse.addGetterSetter(vde,"fillRadialGradientStartRadius",0),Zse.addGetterSetter(vde,"fillRadialGradientEndRadius",0),Zse.addGetterSetter(vde,"fillRadialGradientColorStops"),Zse.addGetterSetter(vde,"fillPatternRepeat","repeat"),Zse.addGetterSetter(vde,"fillEnabled",!0),Zse.addGetterSetter(vde,"strokeEnabled",!0),Zse.addGetterSetter(vde,"shadowEnabled",!0),Zse.addGetterSetter(vde,"dashEnabled",!0),Zse.addGetterSetter(vde,"strokeScaleEnabled",!0),Zse.addGetterSetter(vde,"fillPriority","color"),Zse.addComponentsGetterSetter(vde,"fillPatternOffset",["x","y"]),Zse.addGetterSetter(vde,"fillPatternOffsetX",0,$se()),Zse.addGetterSetter(vde,"fillPatternOffsetY",0,$se()),Zse.addComponentsGetterSetter(vde,"fillPatternScale",["x","y"]),Zse.addGetterSetter(vde,"fillPatternScaleX",1,$se()),Zse.addGetterSetter(vde,"fillPatternScaleY",1,$se()),Zse.addComponentsGetterSetter(vde,"fillLinearGradientStartPoint",["x","y"]),Zse.addComponentsGetterSetter(vde,"strokeLinearGradientStartPoint",["x","y"]),Zse.addGetterSetter(vde,"fillLinearGradientStartPointX",0),Zse.addGetterSetter(vde,"strokeLinearGradientStartPointX",0),Zse.addGetterSetter(vde,"fillLinearGradientStartPointY",0),Zse.addGetterSetter(vde,"strokeLinearGradientStartPointY",0),Zse.addComponentsGetterSetter(vde,"fillLinearGradientEndPoint",["x","y"]),Zse.addComponentsGetterSetter(vde,"strokeLinearGradientEndPoint",["x","y"]),Zse.addGetterSetter(vde,"fillLinearGradientEndPointX",0),Zse.addGetterSetter(vde,"strokeLinearGradientEndPointX",0),Zse.addGetterSetter(vde,"fillLinearGradientEndPointY",0),Zse.addGetterSetter(vde,"strokeLinearGradientEndPointY",0),Zse.addComponentsGetterSetter(vde,"fillRadialGradientStartPoint",["x","y"]),Zse.addGetterSetter(vde,"fillRadialGradientStartPointX",0),Zse.addGetterSetter(vde,"fillRadialGradientStartPointY",0),Zse.addComponentsGetterSetter(vde,"fillRadialGradientEndPoint",["x","y"]),Zse.addGetterSetter(vde,"fillRadialGradientEndPointX",0),Zse.addGetterSetter(vde,"fillRadialGradientEndPointY",0),Zse.addGetterSetter(vde,"fillPatternRotation",0),Zse.backCompat(vde,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var fde=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],zde=fde.length;class gde extends Lhe{constructor(e){super(e),this.canvas=new che,this.hitCanvas=new ihe({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Vhe.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!Vhe.prototype.moveUp.call(this))return!1;var e=this.getStage();return!(!e||!e.content||(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),0))}moveDown(){if(Vhe.prototype.moveDown.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Vhe.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Vhe.prototype.remove.call(this),e&&e.parentNode&&jse._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&jse.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return(e=e||{}).width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=void 0!==e.x?e.x:this.x(),e.y=void 0!==e.y?e.y:this.y(),Vhe.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){const e=this.visible();this.canvas._canvas.style.display=e?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){jse.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){jse.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,jse.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var t=1,n=!1;;){for(let r=0;r<zde;r++){const a=fde[r],o=this._getIntersection({x:e.x+a.x*t,y:e.y+a.y*t}),c=o.shape;if(c)return c;if(n=!!o.antialiased,!o.antialiased)break}if(!n)return null;t+=1}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(255===r){const e=jse._rgbToHex(n[0],n[1],n[2]),t=pde["#"+e];return t?{shape:t}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(e,t){var n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Lhe.prototype.drawScene.call(this,r,t),this._fire("draw",{node:this}),this}drawHit(e,t){var n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Lhe.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){jse.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return jse.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return jse.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}gde.prototype.nodeType="Layer",Ase(gde),Zse.addGetterSetter(gde,"imageSmoothingEnabled",!0),Zse.addGetterSetter(gde,"clearBeforeDraw",!0),Zse.addGetterSetter(gde,"hitGraphEnabled",!0,Xse());class yde extends gde{constructor(e){super(e),this.listening(!1),jse.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}yde.prototype.nodeType="FastLayer",Ase(yde);class Mde extends Lhe{_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&jse.throw("You may only add groups and shapes to groups.")}}Mde.prototype.nodeType="Group",Ase(Mde);var Ede=Tse.performance&&Tse.performance.now?function(){return Tse.performance.now()}:function(){return(new Date).getTime()};class bde{constructor(e,t){this.id=bde.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Ede(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t;return t=e?e.length>0?e:[e]:[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t,n=this.layers,r=n.length;for(t=0;t<r;t++)if(n[t]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e,t=bde.animations,n=t.length;for(e=0;e<n;e++)if(t[e].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Ede(),bde._addAnimation(this),this}stop(){return bde._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var t,n=e.id,r=this.animations,a=r.length;for(t=0;t<a;t++)if(r[t].id===n){this.animations.splice(t,1);break}}static _runFrames(){var e,t,n,r,a,o,c,i,l={},s=this.animations;for(r=0;r<s.length;r++)if(t=(e=s[r]).layers,n=e.func,e._updateFrameObject(Ede()),o=t.length,!n||!1!==n.call(e,e.frame))for(a=0;a<o;a++)void 0!==(c=t[a])._id&&(l[c._id]=c);for(i in l)l.hasOwnProperty(i)&&l[i].batchDraw()}static _animationLoop(){var e=bde;e.animations.length?(e._runFrames(),jse.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,jse.requestAnimFrame(this._animationLoop))}}bde.animations=[],bde.animIdCounter=0,bde.animRunning=!1;var Hde={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Vde=0,Cde=["fill","stroke","shadowColor"];class Lde{constructor(e,t,n,r,a,o,c){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=c,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=a-this.begin,this.pause()}fire(e){var t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return void 0===e&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;2===this.state?this.setTime(e):3===this.state&&this.setTime(this.duration-e)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class wde{constructor(e){var t,n,r=this,a=e.node,o=a._id,c=e.easing||kde.Linear,i=!!e.yoyo;t=void 0===e.duration?.3:0===e.duration?.001:e.duration,this.node=a,this._id=Vde++;var l=a.getLayer()||(a instanceof Ose.Stage?a.getLayers():null);for(n in l||jse.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new bde((function(){r.tween.onEnterFrame()}),l),this.tween=new Lde(n,(function(e){r._tweenFunc(e)}),c,0,1,1e3*t,i),this._addListeners(),wde.attrs[o]||(wde.attrs[o]={}),wde.attrs[o][this._id]||(wde.attrs[o][this._id]={}),wde.tweens[o]||(wde.tweens[o]={}),e)void 0===Hde[n]&&this._addAttr(n,e[n]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var n,r,a,o,c,i,l,s,h=this.node,d=h._id;if((a=wde.tweens[d][e])&&delete wde.attrs[d][a][e],n=h.getAttr(e),jse._isArray(t))if(r=[],c=Math.max(t.length,n.length),"points"===e&&t.length!==n.length&&(t.length>n.length?(l=n,n=jse._prepareArrayForTween(n,t,h.closed())):(i=t,t=jse._prepareArrayForTween(t,n,h.closed()))),0===e.indexOf("fill"))for(o=0;o<c;o++)if(o%2==0)r.push(t[o]-n[o]);else{var u=jse.colorToRGBA(n[o]);s=jse.colorToRGBA(t[o]),n[o]=u,r.push({r:s.r-u.r,g:s.g-u.g,b:s.b-u.b,a:s.a-u.a})}else for(o=0;o<c;o++)r.push(t[o]-n[o]);else-1!==Cde.indexOf(e)?(n=jse.colorToRGBA(n),r={r:(s=jse.colorToRGBA(t)).r-n.r,g:s.g-n.g,b:s.b-n.b,a:s.a-n.a}):r=t-n;wde.attrs[d][this._id][e]={start:n,diff:r,end:t,trueEnd:i,trueStart:l},wde.tweens[d][e]=this._id}_tweenFunc(e){var t,n,r,a,o,c,i,l,s=this.node,h=wde.attrs[s._id][this._id];for(t in h){if(r=(n=h[t]).start,a=n.diff,l=n.end,jse._isArray(r))if(o=[],i=Math.max(r.length,l.length),0===t.indexOf("fill"))for(c=0;c<i;c++)c%2==0?o.push((r[c]||0)+a[c]*e):o.push("rgba("+Math.round(r[c].r+a[c].r*e)+","+Math.round(r[c].g+a[c].g*e)+","+Math.round(r[c].b+a[c].b*e)+","+(r[c].a+a[c].a*e)+")");else for(c=0;c<i;c++)o.push((r[c]||0)+a[c]*e);else o=-1!==Cde.indexOf(t)?"rgba("+Math.round(r.r+a.r*e)+","+Math.round(r.g+a.g*e)+","+Math.round(r.b+a.b*e)+","+(r.a+a.a*e)+")":r+a*e;s.setAttr(t,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,t=wde.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=wde.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(1e3*e),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e,t=this.node._id,n=this._id,r=wde.tweens[t];for(e in this.pause(),r)delete wde.tweens[t][e];delete wde.attrs[t][n]}}wde.attrs={},wde.tweens={},Vhe.prototype.to=function(e){var t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new wde(e).play()};const kde={BackEaseIn(e,t,n,r){var a=1.70158;return n*(e/=r)*e*((a+1)*e-a)+t},BackEaseOut(e,t,n,r){var a=1.70158;return n*((e=e/r-1)*e*((a+1)*e+a)+1)+t},BackEaseInOut(e,t,n,r){var a=1.70158;return(e/=r/2)<1?n/2*(e*e*((1+(a*=1.525))*e-a))+t:n/2*((e-=2)*e*((1+(a*=1.525))*e+a)+2)+t},ElasticEaseIn(e,t,n,r,a,o){var c=0;return 0===e?t:1==(e/=r)?t+n:(o||(o=.3*r),!a||a<Math.abs(n)?(a=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/a),-a*Math.pow(2,10*(e-=1))*Math.sin((e*r-c)*(2*Math.PI)/o)+t)},ElasticEaseOut(e,t,n,r,a,o){var c=0;return 0===e?t:1==(e/=r)?t+n:(o||(o=.3*r),!a||a<Math.abs(n)?(a=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/a),a*Math.pow(2,-10*e)*Math.sin((e*r-c)*(2*Math.PI)/o)+n+t)},ElasticEaseInOut(e,t,n,r,a,o){var c=0;return 0===e?t:2==(e/=r/2)?t+n:(o||(o=r*(.3*1.5)),!a||a<Math.abs(n)?(a=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/a),e<1?a*Math.pow(2,10*(e-=1))*Math.sin((e*r-c)*(2*Math.PI)/o)*-.5+t:a*Math.pow(2,-10*(e-=1))*Math.sin((e*r-c)*(2*Math.PI)/o)*.5+n+t)},BounceEaseOut:(e,t,n,r)=>(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t,BounceEaseIn:(e,t,n,r)=>n-kde.BounceEaseOut(r-e,0,n,r)+t,BounceEaseInOut:(e,t,n,r)=>e<r/2?.5*kde.BounceEaseIn(2*e,0,n,r)+t:.5*kde.BounceEaseOut(2*e-r,0,n,r)+.5*n+t,EaseIn:(e,t,n,r)=>n*(e/=r)*e+t,EaseOut:(e,t,n,r)=>-n*(e/=r)*(e-2)+t,EaseInOut:(e,t,n,r)=>(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t,StrongEaseIn:(e,t,n,r)=>n*(e/=r)*e*e*e*e+t,StrongEaseOut:(e,t,n,r)=>n*((e=e/r-1)*e*e*e*e+1)+t,StrongEaseInOut:(e,t,n,r)=>(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t,Linear:(e,t,n,r)=>n*e/r+t},xde=jse._assign(Ose,{Util:jse,Transform:Rse,Node:Vhe,Container:Lhe,Stage:cde,stages:ode,Layer:gde,FastLayer:yde,Group:Mde,DD:lhe,Shape:vde,shapes:pde,Animation:bde,Tween:wde,Easings:kde,Context:nhe,Canvas:ohe});class Sde extends vde{_sceneFunc(e){var t=Ose.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=Ose.getAngle(n?360-this.angle():this.angle()),a=Math.cos(Math.min(r,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),c=Math.sin(Math.min(r,Math.PI/2)),i=a*(a>0?e:t),l=o*(o>0?e:t),s=c*(c>0?t:e);return{x:i,y:n?-1*s:l,width:1*t-i,height:s-l}}}function Tde(e,t,n,r,a,o,c){var i=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(a-n,2)+Math.pow(o-r,2)),s=c*i/(i+l),h=c*l/(i+l);return[n-s*(a-e),r-s*(o-t),n+h*(a-e),r+h*(o-t)]}function Ode(e,t){var n,r,a=e.length,o=[];for(n=2;n<a-2;n+=2)r=Tde(e[n-2],e[n-1],e[n],e[n+1],e[n+2],e[n+3],t),isNaN(r[0])||(o.push(r[0]),o.push(r[1]),o.push(e[n]),o.push(e[n+1]),o.push(r[2]),o.push(r[3]));return o}Sde.prototype._centroid=!0,Sde.prototype.className="Arc",Sde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ase(Sde),Zse.addGetterSetter(Sde,"innerRadius",0,$se()),Zse.addGetterSetter(Sde,"outerRadius",0,$se()),Zse.addGetterSetter(Sde,"angle",0,$se()),Zse.addGetterSetter(Sde,"clockwise",!1,Xse());class Ade extends vde{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(e){var t,n,r,a=this.points(),o=a.length,c=this.tension(),i=this.closed(),l=this.bezier();if(o){if(e.beginPath(),e.moveTo(a[0],a[1]),0!==c&&o>4){for(n=(t=this.getTensionPoints()).length,r=i?0:4,i||e.quadraticCurveTo(t[0],t[1],t[2],t[3]);r<n-2;)e.bezierCurveTo(t[r++],t[r++],t[r++],t[r++],t[r++],t[r++]);i||e.quadraticCurveTo(t[n-2],t[n-1],a[o-2],a[o-1])}else if(l)for(r=2;r<o;)e.bezierCurveTo(a[r++],a[r++],a[r++],a[r++],a[r++],a[r++]);else for(r=2;r<o;r+=2)e.lineTo(a[r],a[r+1]);i?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Ode(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,n=this.tension(),r=Tde(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),a=Tde(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),o=Ode(e,n);return[r[2],r[3]].concat(o).concat([a[0],a[1],e[t-2],e[t-1],a[2],a[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};for(var t,n,r=(e=0!==this.tension()?[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.points())[0],a=e[0],o=e[1],c=e[1],i=0;i<e.length/2;i++)t=e[2*i],n=e[2*i+1],r=Math.min(r,t),a=Math.max(a,t),o=Math.min(o,n),c=Math.max(c,n);return{x:r,y:o,width:a-r,height:c-o}}}Ade.prototype.className="Line",Ade.prototype._attrsAffectingSize=["points","bezier","tension"],Ase(Ade),Zse.addGetterSetter(Ade,"closed",!1),Zse.addGetterSetter(Ade,"bezier",!1),Zse.addGetterSetter(Ade,"tension",0,$se()),Zse.addGetterSetter(Ade,"points",[],function(){if(Ose.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(jse._isArray(e)?e.forEach((function(e){jse._isNumber(e)||jse.warn('"'+t+'" attribute has non numeric element '+e+". Make sure that all elements are numbers.")})):jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}());class Rde extends vde{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Rde.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",(function(){this.dataArray=Rde.parsePathData(this.data()),this.pathLength=0;for(var e=0;e<this.dataArray.length;++e)this.pathLength+=this.dataArray[e].pathLength}))}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var n=!1,r=0;r<t.length;r++){var a=t[r].command,o=t[r].points;switch(a){case"L":e.lineTo(o[0],o[1]);break;case"M":e.moveTo(o[0],o[1]);break;case"C":e.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":e.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":var c=o[0],i=o[1],l=o[2],s=o[3],h=o[4],d=o[5],u=o[6],m=o[7],p=l>s?l:s,v=l>s?1:l/s,f=l>s?s/l:1;e.translate(c,i),e.rotate(u),e.scale(v,f),e.arc(0,0,p,h,h+d,1-m),e.scale(1/v,1/f),e.rotate(-u),e.translate(-c,-i);break;case"z":n=!0,e.closePath()}}n||this.hasFill()?e.fillStrokeShape(this):e.strokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach((function(t){if("A"===t.command){var n=t.points[4],r=t.points[5],a=t.points[4]+r,o=Math.PI/180;if(Math.abs(n-a)<o&&(o=Math.abs(n-a)),r<0)for(let r=n-o;r>a;r-=o){const n=Rde.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],r,0);e.push(n.x,n.y)}else for(let r=n+o;r<a;r+=o){const n=Rde.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],r,0);e.push(n.x,n.y)}}else if("C"===t.command)for(let n=0;n<=1;n+=.01){const r=Rde.getPointOnCubicBezier(n,t.start.x,t.start.y,t.points[0],t.points[1],t.points[2],t.points[3],t.points[4],t.points[5]);e.push(r.x,r.y)}else e=e.concat(t.points)}));for(var t,n,r=e[0],a=e[0],o=e[1],c=e[1],i=0;i<e.length/2;i++)t=e[2*i],n=e[2*i+1],isNaN(t)||(r=Math.min(r,t),a=Math.max(a,t)),isNaN(n)||(o=Math.min(o,n),c=Math.max(c,n));return{x:r,y:o,width:a-r,height:c-o}}getLength(){return this.pathLength}getPointAtLength(e){var t,n=0,r=this.dataArray.length;if(!r)return null;for(;n<r&&e>this.dataArray[n].pathLength;)e-=this.dataArray[n].pathLength,++n;if(n===r)return{x:(t=this.dataArray[n-1].points.slice(-2))[0],y:t[1]};if(e<.01)return{x:(t=this.dataArray[n].points.slice(0,2))[0],y:t[1]};var a=this.dataArray[n],o=a.points;switch(a.command){case"L":return Rde.getPointOnLine(e,a.start.x,a.start.y,o[0],o[1]);case"C":return Rde.getPointOnCubicBezier(e/a.pathLength,a.start.x,a.start.y,o[0],o[1],o[2],o[3],o[4],o[5]);case"Q":return Rde.getPointOnQuadraticBezier(e/a.pathLength,a.start.x,a.start.y,o[0],o[1],o[2],o[3]);case"A":var c=o[0],i=o[1],l=o[2],s=o[3],h=o[4],d=o[5],u=o[6];return h+=d*e/a.pathLength,Rde.getPointOnEllipticalArc(c,i,l,s,h,u)}return null}static getLineLength(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}static getPointOnLine(e,t,n,r,a,o,c){void 0===o&&(o=t),void 0===c&&(c=n);var i=(a-n)/(r-t+1e-8),l=Math.sqrt(e*e/(1+i*i));r<t&&(l*=-1);var s,h=i*l;if(r===t)s={x:o,y:c+h};else if((c-n)/(o-t+1e-8)===i)s={x:o+l,y:c+h};else{var d,u,m=this.getLineLength(t,n,r,a),p=(o-t)*(r-t)+(c-n)*(a-n);d=t+(p/=m*m)*(r-t),u=n+p*(a-n);var v=this.getLineLength(o,c,d,u),f=Math.sqrt(e*e-v*v);l=Math.sqrt(f*f/(1+i*i)),r<t&&(l*=-1),s={x:d+l,y:u+(h=i*l)}}return s}static getPointOnCubicBezier(e,t,n,r,a,o,c,i,l){function s(e){return e*e*e}function h(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function u(e){return(1-e)*(1-e)*(1-e)}return{x:i*s(e)+o*h(e)+r*d(e)+t*u(e),y:l*s(e)+c*h(e)+a*d(e)+n*u(e)}}static getPointOnQuadraticBezier(e,t,n,r,a,o,c){function i(e){return e*e}function l(e){return 2*e*(1-e)}function s(e){return(1-e)*(1-e)}return{x:o*i(e)+r*l(e)+t*s(e),y:c*i(e)+a*l(e)+n*s(e)}}static getPointOnEllipticalArc(e,t,n,r,a,o){var c=Math.cos(o),i=Math.sin(o),l=n*Math.cos(a),s=r*Math.sin(a);return{x:e+(l*c-s*i),y:t+(l*i+s*c)}}static parsePathData(e){if(!e)return[];var t=e,n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var r=0;r<n.length;r++)t=t.replace(new RegExp(n[r],"g"),"|"+n[r]);var a,o=t.split("|"),c=[],i=[],l=0,s=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(r=1;r<o.length;r++){var d=o[r],u=d.charAt(0);for(d=d.slice(1),i.length=0;a=h.exec(d);)i.push(a[0]);for(var m=[],p=0,v=i.length;p<v;p++)if("00"!==i[p]){var f=parseFloat(i[p]);isNaN(f)?m.push(0):m.push(f)}else m.push(0,0);for(;m.length>0&&!isNaN(m[0]);){var z,g,y,M,E,b,H,V,C,L,w=null,k=[],x=l,S=s;switch(u){case"l":l+=m.shift(),s+=m.shift(),w="L",k.push(l,s);break;case"L":l=m.shift(),s=m.shift(),k.push(l,s);break;case"m":var T=m.shift(),O=m.shift();if(l+=T,s+=O,w="M",c.length>2&&"z"===c[c.length-1].command)for(var A=c.length-2;A>=0;A--)if("M"===c[A].command){l=c[A].points[0]+T,s=c[A].points[1]+O;break}k.push(l,s),u="l";break;case"M":l=m.shift(),s=m.shift(),w="M",k.push(l,s),u="L";break;case"h":l+=m.shift(),w="L",k.push(l,s);break;case"H":l=m.shift(),w="L",k.push(l,s);break;case"v":s+=m.shift(),w="L",k.push(l,s);break;case"V":s=m.shift(),w="L",k.push(l,s);break;case"C":k.push(m.shift(),m.shift(),m.shift(),m.shift()),l=m.shift(),s=m.shift(),k.push(l,s);break;case"c":k.push(l+m.shift(),s+m.shift(),l+m.shift(),s+m.shift()),l+=m.shift(),s+=m.shift(),w="C",k.push(l,s);break;case"S":g=l,y=s,"C"===(z=c[c.length-1]).command&&(g=l+(l-z.points[2]),y=s+(s-z.points[3])),k.push(g,y,m.shift(),m.shift()),l=m.shift(),s=m.shift(),w="C",k.push(l,s);break;case"s":g=l,y=s,"C"===(z=c[c.length-1]).command&&(g=l+(l-z.points[2]),y=s+(s-z.points[3])),k.push(g,y,l+m.shift(),s+m.shift()),l+=m.shift(),s+=m.shift(),w="C",k.push(l,s);break;case"Q":k.push(m.shift(),m.shift()),l=m.shift(),s=m.shift(),k.push(l,s);break;case"q":k.push(l+m.shift(),s+m.shift()),l+=m.shift(),s+=m.shift(),w="Q",k.push(l,s);break;case"T":g=l,y=s,"Q"===(z=c[c.length-1]).command&&(g=l+(l-z.points[0]),y=s+(s-z.points[1])),l=m.shift(),s=m.shift(),w="Q",k.push(g,y,l,s);break;case"t":g=l,y=s,"Q"===(z=c[c.length-1]).command&&(g=l+(l-z.points[0]),y=s+(s-z.points[1])),l+=m.shift(),s+=m.shift(),w="Q",k.push(g,y,l,s);break;case"A":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=l,L=s,l=m.shift(),s=m.shift(),w="A",k=this.convertEndpointToCenterParameterization(C,L,l,s,H,V,M,E,b);break;case"a":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=l,L=s,l+=m.shift(),s+=m.shift(),w="A",k=this.convertEndpointToCenterParameterization(C,L,l,s,H,V,M,E,b)}c.push({command:w||u,points:k,start:{x:x,y:S},pathLength:this.calcLength(x,S,w||u,k)})}"z"!==u&&"Z"!==u||c.push({command:"z",points:[],start:void 0,pathLength:0})}return c}static calcLength(e,t,n,r){var a,o,c,i,l=Rde;switch(n){case"L":return l.getLineLength(e,t,r[0],r[1]);case"C":for(a=0,o=l.getPointOnCubicBezier(0,e,t,r[0],r[1],r[2],r[3],r[4],r[5]),i=.01;i<=1;i+=.01)c=l.getPointOnCubicBezier(i,e,t,r[0],r[1],r[2],r[3],r[4],r[5]),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;return a;case"Q":for(a=0,o=l.getPointOnQuadraticBezier(0,e,t,r[0],r[1],r[2],r[3]),i=.01;i<=1;i+=.01)c=l.getPointOnQuadraticBezier(i,e,t,r[0],r[1],r[2],r[3]),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;return a;case"A":a=0;var s=r[4],h=r[5],d=r[4]+h,u=Math.PI/180;if(Math.abs(s-d)<u&&(u=Math.abs(s-d)),o=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],s,0),h<0)for(i=s-u;i>d;i-=u)c=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],i,0),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;else for(i=s+u;i<d;i+=u)c=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],i,0),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;return c=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],d,0),a+l.getLineLength(o.x,o.y,c.x,c.y)}return 0}static convertEndpointToCenterParameterization(e,t,n,r,a,o,c,i,l){var s=l*(Math.PI/180),h=Math.cos(s)*(e-n)/2+Math.sin(s)*(t-r)/2,d=-1*Math.sin(s)*(e-n)/2+Math.cos(s)*(t-r)/2,u=h*h/(c*c)+d*d/(i*i);u>1&&(c*=Math.sqrt(u),i*=Math.sqrt(u));var m=Math.sqrt((c*c*(i*i)-c*c*(d*d)-i*i*(h*h))/(c*c*(d*d)+i*i*(h*h)));a===o&&(m*=-1),isNaN(m)&&(m=0);var p=m*c*d/i,v=m*-i*h/c,f=(e+n)/2+Math.cos(s)*p-Math.sin(s)*v,z=(t+r)/2+Math.sin(s)*p+Math.cos(s)*v,g=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(g(e)*g(t))},M=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},E=M([1,0],[(h-p)/c,(d-v)/i]),b=[(h-p)/c,(d-v)/i],H=[(-1*h-p)/c,(-1*d-v)/i],V=M(b,H);return y(b,H)<=-1&&(V=Math.PI),y(b,H)>=1&&(V=0),0===o&&V>0&&(V-=2*Math.PI),1===o&&V<0&&(V+=2*Math.PI),[f,z,c,i,E,V,s,o]}}Rde.prototype.className="Path",Rde.prototype._attrsAffectingSize=["data"],Ase(Rde),Zse.addGetterSetter(Rde,"data");class Nde extends Ade{_sceneFunc(e){super._sceneFunc(e);var t=2*Math.PI,n=this.points(),r=n,a=0!==this.tension()&&n.length>4;a&&(r=this.getTensionPoints());var o,c,i=this.pointerLength(),l=n.length;if(a){const e=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[l-2],n[l-1]],t=Rde.calcLength(r[r.length-4],r[r.length-3],"C",e),a=Rde.getPointOnQuadraticBezier(Math.min(1,1-i/t),e[0],e[1],e[2],e[3],e[4],e[5]);o=n[l-2]-a.x,c=n[l-1]-a.y}else o=n[l-2]-n[l-4],c=n[l-1]-n[l-3];var s=(Math.atan2(c,o)+t)%t,h=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[l-2],n[l-1]),e.rotate(s),e.moveTo(0,0),e.lineTo(-i,h/2),e.lineTo(-i,-h/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),a?(o=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(o=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-o)+t)%t),e.moveTo(0,0),e.lineTo(-i,h/2),e.lineTo(-i,-h/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}}Nde.prototype.className="Arrow",Ase(Nde),Zse.addGetterSetter(Nde,"pointerLength",10,$se()),Zse.addGetterSetter(Nde,"pointerWidth",10,$se()),Zse.addGetterSetter(Nde,"pointerAtBeginning",!1),Zse.addGetterSetter(Nde,"pointerAtEnding",!0);class _de extends vde{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}_de.prototype._centroid=!0,_de.prototype.className="Circle",_de.prototype._attrsAffectingSize=["radius"],Ase(_de),Zse.addGetterSetter(_de,"radius",0,$se());class Dde extends vde{_sceneFunc(e){var t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,2*Math.PI,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Dde.prototype.className="Ellipse",Dde.prototype._centroid=!0,Dde.prototype._attrsAffectingSize=["radiusX","radiusY"],Ase(Dde),Zse.addComponentsGetterSetter(Dde,"radius",["x","y"]),Zse.addGetterSetter(Dde,"radiusX",0,$se()),Zse.addGetterSetter(Dde,"radiusY",0,$se());class Pde extends vde{constructor(e){super(e),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&4===e.readyState||e&&e.addEventListener&&e.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),a=this.attrs.image;let o;if(a){const e=this.attrs.cropWidth,r=this.attrs.cropHeight;o=e&&r?[a,this.cropX(),this.cropY(),e,r,0,0,t,n]:[a,0,0,t,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?jse.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),a&&(r&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){var t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?jse.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return null!==(e=this.attrs.width)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.width}getHeight(){var e,t;return null!==(e=this.attrs.height)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.height}static fromURL(e,t,n=null){var r=jse.createImageElement();r.onload=function(){var e=new Pde({image:r});t(e)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}}Pde.prototype.className="Image",Ase(Pde),Zse.addGetterSetter(Pde,"cornerRadius",0,qse(4)),Zse.addGetterSetter(Pde,"image"),Zse.addComponentsGetterSetter(Pde,"crop",["x","y","width","height"]),Zse.addGetterSetter(Pde,"cropX",0,$se()),Zse.addGetterSetter(Pde,"cropY",0,$se()),Zse.addGetterSetter(Pde,"cropWidth",0,$se()),Zse.addGetterSetter(Pde,"cropHeight",0,$se());var Fde=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Ide="up",Bde="right",jde="down",Ude="left",Wde=Fde.length;class $de extends Mde{constructor(e){super(e),this.on("add.konva",(function(e){this._addListeners(e.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t,n=this,r=function(){n._sync()};for(t=0;t<Wde;t++)e.on(Fde[t]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e,t,n,r,a,o,c,i=this.getText(),l=this.getTag();if(i&&l){switch(e=i.width(),t=i.height(),n=l.pointerDirection(),r=l.pointerWidth(),c=l.pointerHeight(),a=0,o=0,n){case Ide:a=e/2,o=-1*c;break;case Bde:a=e+r,o=t/2;break;case jde:a=e/2,o=t+c;break;case Ude:a=-1*r,o=t/2}l.setAttrs({x:-1*a,y:-1*o,width:e,height:t}),i.setAttrs({x:-1*a,y:-1*o})}}}$de.prototype.className="Label",Ase($de);class qde extends vde{_sceneFunc(e){var t=this.width(),n=this.height(),r=this.pointerDirection(),a=this.pointerWidth(),o=this.pointerHeight(),c=this.cornerRadius();let i=0,l=0,s=0,h=0;"number"==typeof c?i=l=s=h=Math.min(c,t/2,n/2):(i=Math.min(c[0]||0,t/2,n/2),l=Math.min(c[1]||0,t/2,n/2),h=Math.min(c[2]||0,t/2,n/2),s=Math.min(c[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(i,0),r===Ide&&(e.lineTo((t-a)/2,0),e.lineTo(t/2,-1*o),e.lineTo((t+a)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,3*Math.PI/2,0,!1),r===Bde&&(e.lineTo(t,(n-o)/2),e.lineTo(t+a,n/2),e.lineTo(t,(n+o)/2)),e.lineTo(t,n-h),e.arc(t-h,n-h,h,0,Math.PI/2,!1),r===jde&&(e.lineTo((t+a)/2,n),e.lineTo(t/2,n+o),e.lineTo((t-a)/2,n)),e.lineTo(s,n),e.arc(s,n-s,s,Math.PI/2,Math.PI,!1),r===Ude&&(e.lineTo(0,(n+o)/2),e.lineTo(-1*a,n/2),e.lineTo(0,(n-o)/2)),e.lineTo(0,i),e.arc(i,i,i,Math.PI,3*Math.PI/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),a=this.pointerDirection(),o=this.width(),c=this.height();return a===Ide?(t-=r,c+=r):a===jde?c+=r:a===Ude?(e-=1.5*n,o+=n):a===Bde&&(o+=1.5*n),{x:e,y:t,width:o,height:c}}}qde.prototype.className="Tag",Ase(qde),Zse.addGetterSetter(qde,"pointerDirection","none"),Zse.addGetterSetter(qde,"pointerWidth",0,$se()),Zse.addGetterSetter(qde,"pointerHeight",0,$se()),Zse.addGetterSetter(qde,"cornerRadius",0,qse(4));class Gde extends vde{_sceneFunc(e){var t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?jse.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}}Gde.prototype.className="Rect",Ase(Gde),Zse.addGetterSetter(Gde,"cornerRadius",0,qse(4));class Yde extends vde{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(var r=0;r<e;r++)n.push({x:t*Math.sin(2*r*Math.PI/e),y:-1*t*Math.cos(2*r*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();var t=e[0].x,n=e[0].y,r=e[0].x,a=e[0].y;return e.forEach((e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),a=Math.max(a,e.y)})),{x:t,y:r,width:n-t,height:a-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Yde.prototype.className="RegularPolygon",Yde.prototype._centroid=!0,Yde.prototype._attrsAffectingSize=["radius"],Ase(Yde),Zse.addGetterSetter(Yde,"radius",0,$se()),Zse.addGetterSetter(Yde,"sides",0,$se());var Kde=2*Math.PI;class Xde extends vde{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Kde,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Kde,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Xde.prototype.className="Ring",Xde.prototype._centroid=!0,Xde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ase(Xde),Zse.addGetterSetter(Xde,"innerRadius",0,$se()),Zse.addGetterSetter(Xde,"outerRadius",0,$se());class Qde extends vde{constructor(e){super(e),this._updated=!0,this.anim=new bde((()=>{var e=this._updated;return this._updated=!1,e})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(e){var t=this.animation(),n=this.frameIndex(),r=4*n,a=this.animations()[t],o=this.frameOffsets(),c=a[r+0],i=a[r+1],l=a[r+2],s=a[r+3],h=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,s),e.closePath(),e.fillStrokeShape(this)),h)if(o){var d=o[t],u=2*n;e.drawImage(h,c,i,l,s,d[u+0],d[u+1],l,s)}else e.drawImage(h,c,i,l,s,0,0,l,s)}_hitFunc(e){var t=this.animation(),n=this.frameIndex(),r=4*n,a=this.animations()[t],o=this.frameOffsets(),c=a[r+2],i=a[r+3];if(e.beginPath(),o){var l=o[t],s=2*n;e.rect(l[s+0],l[s+1],c,i)}else e.rect(0,0,c,i);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval((function(){e._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}}Qde.prototype.className="Sprite",Ase(Qde),Zse.addGetterSetter(Qde,"animation"),Zse.addGetterSetter(Qde,"animations"),Zse.addGetterSetter(Qde,"frameOffsets"),Zse.addGetterSetter(Qde,"image"),Zse.addGetterSetter(Qde,"frameIndex",0,$se()),Zse.addGetterSetter(Qde,"frameRate",17,$se()),Zse.backCompat(Qde,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Jde extends vde{_sceneFunc(e){var t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(var a=1;a<2*r;a++){var o=a%2==0?n:t,c=o*Math.sin(a*Math.PI/r),i=-1*o*Math.cos(a*Math.PI/r);e.lineTo(c,i)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}function Zde(e){return Array.from(e)}Jde.prototype.className="Star",Jde.prototype._centroid=!0,Jde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ase(Jde),Zse.addGetterSetter(Jde,"numPoints",5,$se()),Zse.addGetterSetter(Jde,"innerRadius",0,$se()),Zse.addGetterSetter(Jde,"outerRadius",0,$se());var eue,tue="auto",nue="justify",rue="left",aue="middle",oue="normal",cue=" ",iue="none",lue=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],sue=lue.length;function hue(){return eue||(eue=jse.createCanvasElement().getContext("2d"))}class due extends vde{constructor(e){super(function(e){return(e=e||{}).fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage||(e.fill=e.fill||"black"),e}(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<sue;t++)this.on(lue[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,n=t.length;if(this.text()){var r,a=this.padding(),o=this.fontSize(),c=this.lineHeight()*o,i=this.verticalAlign(),l=0,s=this.align(),h=this.getWidth(),d=this.letterSpacing(),u=this.fill(),m=this.textDecoration(),p=-1!==m.indexOf("underline"),v=-1!==m.indexOf("line-through"),f=0,z=(f=c/2,0),g=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",aue),e.setAttr("textAlign",rue),i===aue?l=(this.getHeight()-n*c-2*a)/2:"bottom"===i&&(l=this.getHeight()-n*c-2*a),e.translate(a,l+a),r=0;r<n;r++){z=0,g=0;var y,M,E,b=t[r],H=b.text,V=b.width,C=b.lastInParagraph;if(e.save(),"right"===s?z+=h-V-2*a:"center"===s&&(z+=(h-V-2*a)/2),p){e.save(),e.beginPath(),e.moveTo(z,f+g+Math.round(o/2)),M=0==(y=H.split(" ").length-1),E=s!==nue||C?V:h-2*a,e.lineTo(z+Math.round(E),f+g+Math.round(o/2)),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(z,f+g),M=0==(y=H.split(" ").length-1),E=s===nue&&C&&!M?h-2*a:V,e.lineTo(z+Math.round(E),f+g),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(0!==d||s===nue){y=H.split(" ").length-1;for(var L=Zde(H),w=0;w<L.length;w++){var k=L[w];" "!==k||C||s!==nue||(z+=(h-2*a-V)/y),this._partialTextX=z,this._partialTextY=f+g,this._partialText=k,e.fillStrokeShape(this),z+=this.measureSize(k).width+d}}else this._partialTextX=z,this._partialTextY=f+g,this._partialText=H,e.fillStrokeShape(this);e.restore(),n>1&&(f+=c)}}}_hitFunc(e){var t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=jse._isString(e)?e:null==e?"":e+"";return this._setAttr("text",t),this}getWidth(){return this.attrs.width===tue||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===tue||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return jse.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n=hue(),r=this.fontSize();return n.save(),n.font=this._getContextFont(),t=n.measureText(e),n.restore(),{width:t.width,height:r}}_getContextFont(){return this.fontStyle()+cue+this.fontVariant()+cue+(this.fontSize()+"px ")+function(e){return e.split(",").map((e=>{const t=(e=e.trim()).indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e})).join(", ")}(this.fontFamily())}_addTextLine(e){this.align()===nue&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),n=e.length;return hue().measureText(e).width+(n?t*(n-1):0)}_setTextData(){var e=this.text().split("\n"),t=+this.fontSize(),n=0,r=this.lineHeight()*t,a=this.attrs.width,o=this.attrs.height,c=a!==tue&&void 0!==a,i=o!==tue&&void 0!==o,l=this.padding(),s=a-2*l,h=o-2*l,d=0,u=this.wrap(),m="char"!==u&&u!==iue,p=this.ellipsis();this.textArr=[],hue().font=this._getContextFont();for(var v=p?this._getTextWidth("…"):0,f=0,z=e.length;f<z;++f){var g=e[f],y=this._getTextWidth(g);if(c&&y>s)for(;g.length>0;){for(var M=0,E=g.length,b="",H=0;M<E;){var V=M+E>>>1,C=g.slice(0,V+1),L=this._getTextWidth(C)+v;L<=s?(M=V+1,b=C,H=L):E=V}if(!b)break;if(m){var w,k=g[b.length];(w=(k===cue||"-"===k)&&H<=s?b.length:Math.max(b.lastIndexOf(cue),b.lastIndexOf("-"))+1)>0&&(M=w,b=b.slice(0,M),H=this._getTextWidth(b))}if(b=b.trimRight(),this._addTextLine(b),n=Math.max(n,H),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if((g=(g=g.slice(M)).trimLeft()).length>0&&(y=this._getTextWidth(g))<=s){this._addTextLine(g),d+=r,n=Math.max(n,y);break}}else this._addTextLine(g),d+=r,n=Math.max(n,y),this._shouldHandleEllipsis(d)&&f<z-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),i&&d+r>h)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){var t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,a=r!==tue&&void 0!==r,o=r-2*this.padding();return!(this.wrap()!==iue)||a&&e+n>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==tue&&void 0!==e,n=e-2*this.padding(),r=this.ellipsis(),a=this.textArr[this.textArr.length-1];a&&r&&(t&&(this._getTextWidth(a.text+"…")<n||(a.text=a.text.slice(0,a.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+"…"))}getStrokeScaleEnabled(){return!0}}due.prototype._fillFunc=function(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)},due.prototype._strokeFunc=function(e){e.strokeText(this._partialText,this._partialTextX,this._partialTextY)},due.prototype.className="Text",due.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Ase(due),Zse.overWriteSetter(due,"width",Gse()),Zse.overWriteSetter(due,"height",Gse()),Zse.addGetterSetter(due,"fontFamily","Arial"),Zse.addGetterSetter(due,"fontSize",12,$se()),Zse.addGetterSetter(due,"fontStyle",oue),Zse.addGetterSetter(due,"fontVariant",oue),Zse.addGetterSetter(due,"padding",0,$se()),Zse.addGetterSetter(due,"align",rue),Zse.addGetterSetter(due,"verticalAlign","top"),Zse.addGetterSetter(due,"lineHeight",1,$se()),Zse.addGetterSetter(due,"wrap","word"),Zse.addGetterSetter(due,"ellipsis",!1,Xse()),Zse.addGetterSetter(due,"letterSpacing",0,$se()),Zse.addGetterSetter(due,"text","",Yse()),Zse.addGetterSetter(due,"textDecoration","");var uue="normal";function mue(e){e.fillText(this.partialText,0,0)}function pue(e){e.strokeText(this.partialText,0,0)}class vue extends vde{constructor(e){super(e),this.dummyCanvas=jse.createCanvasElement(),this.dataArray=[],this.dataArray=Rde.parsePathData(this.attrs.data),this.on("dataChange.konva",(function(){this.dataArray=Rde.parsePathData(this.attrs.data),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var t=this.textDecoration(),n=this.fill(),r=this.fontSize(),a=this.glyphInfo;"underline"===t&&e.beginPath();for(var o=0;o<a.length;o++){e.save();var c=a[o].p0;e.translate(c.x,c.y),e.rotate(a[o].rotation),this.partialText=a[o].text,e.fillStrokeShape(this),"underline"===t&&(0===o&&e.moveTo(0,r/2+1),e.lineTo(r,r/2+1)),e.restore()}"underline"===t&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var n=t[0].p0;e.moveTo(n.x,n.y)}for(var r=0;r<t.length;r++){var a=t[r].p1;e.lineTo(a.x,a.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return jse.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return due.prototype.setText.call(this,e)}_getContextFont(){return due.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();var n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),n=this.letterSpacing(),r=this.align(),a=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);this.glyphInfo=[];for(var c=0,i=0;i<e.dataArray.length;i++)e.dataArray[i].pathLength>0&&(c+=e.dataArray[i].pathLength);var l=0;"center"===r&&(l=Math.max(0,c/2-o/2)),"right"===r&&(l=Math.max(0,c-o));for(var s,h,d,u=Zde(this.text()),m=this.text().split(" ").length-1,p=-1,v=0,f=function(){v=0;for(var t=e.dataArray,n=p+1;n<t.length;n++){if(t[n].pathLength>0)return p=n,t[n];"M"===t[n].command&&(s={x:t[n].points[0],y:t[n].points[1]})}return{}},z=function(t){var a=e._getTextSize(t).width+n;" "===t&&"justify"===r&&(a+=(c-o)/m);var i=0,l=0;for(h=void 0;Math.abs(a-i)/a>.01&&l<20;){l++;for(var u=i;void 0===d;)(d=f())&&u+d.pathLength<a&&(u+=d.pathLength,d=void 0);if(0===Object.keys(d).length||void 0===s)return;var p=!1;switch(d.command){case"L":Rde.getLineLength(s.x,s.y,d.points[0],d.points[1])>a?h=Rde.getPointOnLine(a,s.x,s.y,d.points[0],d.points[1],s.x,s.y):d=void 0;break;case"A":var z=d.points[4],g=d.points[5],y=d.points[4]+g;0===v?v=z+1e-8:a>i?v+=Math.PI/180*g/Math.abs(g):v-=Math.PI/360*g/Math.abs(g),(g<0&&v<y||g>=0&&v>y)&&(v=y,p=!0),h=Rde.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],v,d.points[6]);break;case"C":0===v?v=a>d.pathLength?1e-8:a/d.pathLength:a>i?v+=(a-i)/d.pathLength/2:v=Math.max(v-(i-a)/d.pathLength/2,0),v>1&&(v=1,p=!0),h=Rde.getPointOnCubicBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3],d.points[4],d.points[5]);break;case"Q":0===v?v=a/d.pathLength:a>i?v+=(a-i)/d.pathLength:v-=(i-a)/d.pathLength,v>1&&(v=1,p=!0),h=Rde.getPointOnQuadraticBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3])}void 0!==h&&(i=Rde.getLineLength(s.x,s.y,h.x,h.y)),p&&(p=!1,d=void 0)}},g=l/(e._getTextSize("C").width+n)-1,y=0;y<g&&(z("C"),void 0!==s&&void 0!==h);y++)s=h;for(var M=0;M<u.length&&(z(u[M]),void 0!==s&&void 0!==h);M++){var E=Rde.getLineLength(s.x,s.y,h.x,h.y),b=0;if(a)try{b=a(u[M-1],u[M])*this.fontSize()}catch(e){b=0}s.x+=b,h.x+=b,this.textWidth+=b;var H=Rde.getPointOnLine(b+E/2,s.x,s.y,h.x,h.y),V=Math.atan2(h.y-s.y,h.x-s.x);this.glyphInfo.push({transposeX:H.x,transposeY:H.y,text:u[M],rotation:V,p0:s,p1:h}),s=h}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach((function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)}));for(var t,n,r=e[0]||0,a=e[0]||0,o=e[1]||0,c=e[1]||0,i=0;i<e.length/2;i++)t=e[2*i],n=e[2*i+1],r=Math.min(r,t),a=Math.max(a,t),o=Math.min(o,n),c=Math.max(c,n);var l=this.fontSize();return{x:r-l/2,y:o-l/2,width:a-r+l,height:c-o+l}}destroy(){return jse.releaseCanvas(this.dummyCanvas),super.destroy()}}vue.prototype._fillFunc=mue,vue.prototype._strokeFunc=pue,vue.prototype._fillFuncHit=mue,vue.prototype._strokeFuncHit=pue,vue.prototype.className="TextPath",vue.prototype._attrsAffectingSize=["text","fontSize","data"],Ase(vue),Zse.addGetterSetter(vue,"data"),Zse.addGetterSetter(vue,"fontFamily","Arial"),Zse.addGetterSetter(vue,"fontSize",12,$se()),Zse.addGetterSetter(vue,"fontStyle",uue),Zse.addGetterSetter(vue,"align","left"),Zse.addGetterSetter(vue,"letterSpacing",0,$se()),Zse.addGetterSetter(vue,"textBaseline","middle"),Zse.addGetterSetter(vue,"fontVariant",uue),Zse.addGetterSetter(vue,"text",""),Zse.addGetterSetter(vue,"textDecoration",null),Zse.addGetterSetter(vue,"kerningFunc",null);var fue="tr-konva",zue=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map((e=>e+`.${fue}`)).join(" "),gue="nodesRect",yue=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Mue={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const Eue="ontouchstart"in Ose._global;var bue=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Hue(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),a=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return Object.assign(Object.assign({},e),{rotation:e.rotation+t,x:r,y:a})}class Vue extends Mde{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(zue,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return jse.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return fue+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const t=e.filter((e=>!e.isAncestorOf(this)||(jse.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=e=t,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((e=>{const t=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},n=e._attrsAffectingSize.map((e=>e+"Change."+this._getEventNamespace())).join(" ");e.on(n,t),e.on(yue.map((e=>e+`.${this._getEventNamespace()}`)).join(" "),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,(n=>{t=e.getAbsolutePosition(),this.isDragging()||e===this.findOne(".back")||this.startDrag(n,!1)})),e.on(`dragmove.${this._getEventNamespace()}`,(n=>{if(!t)return;const r=e.getAbsolutePosition(),a=r.x-t.x,o=r.y-t.y;this.nodes().forEach((t=>{if(t===e)return;if(t.isDragging())return;const r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+a,y:r.y+o}),t.startDrag(n)})),t=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((e=>{e.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(gue),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(gue,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){var r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),a=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),c=r.x*a.x-e.offsetX()*a.x,i=r.y*a.y-e.offsetY()*a.y;const l=(Ose.getAngle(e.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Hue({x:o.x+c*Math.cos(l)+i*Math.sin(-l),y:o.y+i*Math.cos(l)+c*Math.sin(l),width:r.width*a.x,height:r.height*a.y,rotation:l},-Ose.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],a=t.getAbsoluteTransform();r.forEach((function(t){var n=a.point(t);e.push(n)}))}));const t=new Rse;var n,r,a,o;t.rotate(-Ose.getAngle(this.rotation())),e.forEach((function(e){var c=t.point(e);void 0===n&&(n=a=c.x,r=o=c.y),n=Math.min(n,c.x),r=Math.min(r,c.y),a=Math.max(a,c.x),o=Math.max(o,c.y)})),t.invert();const c=t.point({x:n,y:r});return{x:c.x,y:c.y,width:a-n,height:o-r,rotation:Ose.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),bue.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new Gde({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Eue?10:"auto"}),n=this;t.on("mousedown touchstart",(function(e){n._handleMouseDown(e)})),t.on("dragstart",(e=>{t.stopDrag(),e.cancelBubble=!0})),t.on("dragend",(e=>{e.cancelBubble=!0})),t.on("mouseenter",(()=>{var n=Ose.getAngle(this.rotation()),r=function(e,t){if("rotater"===e)return"crosshair";t+=jse.degToRad(Mue[e]||0);var n=(jse.radToDeg(t)%360+360)%360;return jse._inRange(n,337.5,360)||jse._inRange(n,0,22.5)?"ns-resize":jse._inRange(n,22.5,67.5)?"nesw-resize":jse._inRange(n,67.5,112.5)?"ew-resize":jse._inRange(n,112.5,157.5)?"nwse-resize":jse._inRange(n,157.5,202.5)?"ns-resize":jse._inRange(n,202.5,247.5)?"nesw-resize":jse._inRange(n,247.5,292.5)?"ew-resize":jse._inRange(n,292.5,337.5)?"nwse-resize":(jse.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(e,n);t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0})),t.on("mouseout",(()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(t)}_createBack(){var e=new vde({name:"back",width:0,height:0,draggable:!0,sceneFunc(e){var t=this.getParent(),n=t.padding();e.beginPath(),e.rect(-n,-n,this.width()+2*n,this.height()+2*n),e.moveTo(this.width()/2,-n),t.rotateEnabled()&&e.lineTo(this.width()/2,-t.rotateAnchorOffset()*jse._sign(this.height())-n),e.fillStrokeShape(this)},hitFunc:(e,t)=>{if(this.shouldOverdrawWholeArea()){var n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+2*n,t.height()+2*n),e.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",(e=>{e.cancelBubble=!0})),e.on("dragmove",(e=>{e.cancelBubble=!0})),e.on("dragend",(e=>{e.cancelBubble=!0})),this.on("dragmove",(e=>{this.update()}))}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),n=t.width,r=t.height,a=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/a),this.cos=Math.abs(n/a),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var o=e.target.getAbsolutePosition(),c=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:c.x-o.x,y:c.y-o.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach((t=>{t._fire("transformstart",{evt:e.evt,target:t})}))}_handleMouseMove(e){var t,n,r,a=this.findOne("."+this._movingAnchorName),o=a.getStage();o.setPointersPositions(e);const c=o.getPointerPosition();let i={x:c.x-this._anchorDragOffset.x,y:c.y-this._anchorDragOffset.y};const l=a.getAbsolutePosition();this.anchorDragBoundFunc()&&(i=this.anchorDragBoundFunc()(l,i,e)),a.setAbsolutePosition(i);const s=a.getAbsolutePosition();if(l.x!==s.x||l.y!==s.y)if("rotater"!==this._movingAnchorName){var h=this.keepRatio()||e.shiftKey,d=this.centeredScaling()||e.altKey;if("top-left"===this._movingAnchorName){if(h){var u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(u.x-a.x(),2)+Math.pow(u.y-a.y(),2));var m=this.findOne(".top-left").x()>u.x?-1:1,p=this.findOne(".top-left").y()>u.y?-1:1;t=r*this.cos*m,n=r*this.sin*p,this.findOne(".top-left").x(u.x-t),this.findOne(".top-left").y(u.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(a.y());else if("top-right"===this._movingAnchorName){h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()},r=Math.sqrt(Math.pow(a.x()-u.x,2)+Math.pow(u.y-a.y(),2)),m=this.findOne(".top-right").x()<u.x?-1:1,p=this.findOne(".top-right").y()>u.y?-1:1,t=r*this.cos*m,n=r*this.sin*p,this.findOne(".top-right").x(u.x+t),this.findOne(".top-right").y(u.y-n));var v=a.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else"middle-left"===this._movingAnchorName?this.findOne(".top-left").x(a.x()):"middle-right"===this._movingAnchorName?this.findOne(".bottom-right").x(a.x()):"bottom-left"===this._movingAnchorName?(h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()},r=Math.sqrt(Math.pow(u.x-a.x(),2)+Math.pow(a.y()-u.y,2)),m=u.x<a.x()?-1:1,p=a.y()<u.y?-1:1,t=r*this.cos*m,n=r*this.sin*p,a.x(u.x-t),a.y(u.y+n)),v=a.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)):"bottom-center"===this._movingAnchorName?this.findOne(".bottom-right").y(a.y()):"bottom-right"===this._movingAnchorName?h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()},r=Math.sqrt(Math.pow(a.x()-u.x,2)+Math.pow(a.y()-u.y,2)),m=this.findOne(".bottom-right").x()<u.x?-1:1,p=this.findOne(".bottom-right").y()<u.y?-1:1,t=r*this.cos*m,n=r*this.sin*p,this.findOne(".bottom-right").x(u.x+t),this.findOne(".bottom-right").y(u.y+n)):console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(d=this.centeredScaling()||e.altKey){var f=this.findOne(".top-left"),z=this.findOne(".bottom-right"),g=f.x(),y=f.y(),M=this.getWidth()-z.x(),E=this.getHeight()-z.y();z.move({x:-g,y:-y}),f.move({x:M,y:E})}var b=this.findOne(".top-left").getAbsolutePosition();t=b.x,n=b.y;var H=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),V=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:H,height:V,rotation:Ose.getAngle(this.rotation())},e)}else{var C=this._getNodeRect();t=a.x()-C.width/2,n=-a.y()+C.height/2;let r=Math.atan2(-n,t)+Math.PI/2;C.height<0&&(r-=Math.PI);const o=Ose.getAngle(this.rotation())+r,c=Ose.getAngle(this.rotationSnapTolerance()),i=function(e,t){const n=function(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}(e);return Hue(e,t,n)}(C,function(e,t,n){let r=t;for(let a=0;a<e.length;a++){const o=Ose.getAngle(e[a]),c=Math.abs(o-t)%(2*Math.PI);Math.min(c,2*Math.PI-c)<n&&(r=o)}return r}(this.rotationSnaps(),o,c)-C.rotation);this._fitNodesInto(i,e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach((t=>{t._fire("transformend",{evt:e,target:t})})),this._movingAnchorName=null}}_fitNodesInto(e,t){var n=this._getNodeRect();if(jse._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(jse._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=this.flipEnabled();var a=new Rse;if(a.rotate(Ose.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=a.point({x:2*-this.padding(),y:0});if(e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,!r)return void this.update()}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=a.point({x:2*this.padding(),y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding(),!r)return void this.update()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=a.point({x:0,y:2*-this.padding()});if(e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!r)return void this.update()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=a.point({x:0,y:2*this.padding()});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!r)return void this.update()}if(this.boundBoxFunc()){const t=this.boundBoxFunc()(n,e);t?e=t:jse.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,c=new Rse;c.translate(n.x,n.y),c.rotate(n.rotation),c.scale(n.width/o,n.height/o);const i=new Rse;i.translate(e.x,e.y),i.rotate(e.rotation),i.scale(e.width/o,e.height/o);const l=i.multiply(c.invert());this._nodes.forEach((e=>{var n;const r=e.getParent().getAbsoluteTransform(),a=e.getTransform().copy();a.translate(e.offsetX(),e.offsetY());const o=new Rse;o.multiply(r.copy().invert()).multiply(l).multiply(r).multiply(a);const c=o.decompose();e.setAttrs(c),this._fire("transform",{evt:t,target:e}),e._fire("transform",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this.rotation(jse._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(jse._getRotation(t.rotation));var n=t.width,r=t.height,a=this.enabledAnchors(),o=this.resizeEnabled(),c=this.padding(),i=this.anchorSize();this.find("._anchor").forEach((e=>{e.setAttrs({width:i,height:i,offsetX:i/2,offsetY:i/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:i/2+c,offsetY:i/2+c,visible:o&&a.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:i/2+c,visible:o&&a.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:i/2-c,offsetY:i/2+c,visible:o&&a.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:i/2+c,visible:o&&a.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:i/2-c,visible:o&&a.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:i/2+c,offsetY:i/2-c,visible:o&&a.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:i/2-c,visible:o&&a.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:i/2-c,offsetY:i/2-c,visible:o&&a.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*jse._sign(r)-c,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Mde.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Vhe.prototype.toObject.call(this)}clone(e){return Vhe.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Vue.prototype.className="Transformer",Ase(Vue),Zse.addGetterSetter(Vue,"enabledAnchors",bue,(function(e){return e instanceof Array||jse.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===bue.indexOf(e)&&jse.warn("Unknown anchor name: "+e+". Available names are: "+bue.join(", "))})),e||[]})),Zse.addGetterSetter(Vue,"flipEnabled",!0,Xse()),Zse.addGetterSetter(Vue,"resizeEnabled",!0),Zse.addGetterSetter(Vue,"anchorSize",10,$se()),Zse.addGetterSetter(Vue,"rotateEnabled",!0),Zse.addGetterSetter(Vue,"rotationSnaps",[]),Zse.addGetterSetter(Vue,"rotateAnchorOffset",50,$se()),Zse.addGetterSetter(Vue,"rotationSnapTolerance",5,$se()),Zse.addGetterSetter(Vue,"borderEnabled",!0),Zse.addGetterSetter(Vue,"anchorStroke","rgb(0, 161, 255)"),Zse.addGetterSetter(Vue,"anchorStrokeWidth",1,$se()),Zse.addGetterSetter(Vue,"anchorFill","white"),Zse.addGetterSetter(Vue,"anchorCornerRadius",0,$se()),Zse.addGetterSetter(Vue,"borderStroke","rgb(0, 161, 255)"),Zse.addGetterSetter(Vue,"borderStrokeWidth",1,$se()),Zse.addGetterSetter(Vue,"borderDash"),Zse.addGetterSetter(Vue,"keepRatio",!0),Zse.addGetterSetter(Vue,"centeredScaling",!1),Zse.addGetterSetter(Vue,"ignoreStroke",!1),Zse.addGetterSetter(Vue,"padding",0,$se()),Zse.addGetterSetter(Vue,"node"),Zse.addGetterSetter(Vue,"nodes"),Zse.addGetterSetter(Vue,"boundBoxFunc"),Zse.addGetterSetter(Vue,"anchorDragBoundFunc"),Zse.addGetterSetter(Vue,"shouldOverdrawWholeArea",!1),Zse.addGetterSetter(Vue,"useSingleNodeRotation",!0),Zse.backCompat(Vue,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Cue extends vde{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Ose.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}function Lue(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Cue.prototype.className="Wedge",Cue.prototype._centroid=!0,Cue.prototype._attrsAffectingSize=["radius"],Ase(Cue),Zse.addGetterSetter(Cue,"radius",0,$se()),Zse.addGetterSetter(Cue,"angle",0,$se()),Zse.addGetterSetter(Cue,"clockwise",!1),Zse.backCompat(Cue,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var wue=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],kue=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function xue(e,t,n,r,a){var o=n-t,c=a-r;return 0===o?r+c/2:0===c?r:c*((e-t)/o)+r}function Sue(e,t,n){var r=4*(n*e.width+t),a=[];return a.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),a}function Tue(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function Oue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Zse.addGetterSetter(Vhe,"blurRadius",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"brightness",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"contrast",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossStrength",.5,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossWhiteLevel",.5,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossDirection","top-left",null,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossBlend",!1,null,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"enhance",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"hue",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"saturation",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"luminance",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"hue",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"saturation",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"value",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"kaleidoscopePower",2,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"kaleidoscopeAngle",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"threshold",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"noise",.2,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"pixelSize",8,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"levels",.5,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"blue",0,Wse,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"blue",0,Wse,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"alpha",1,(function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e})),Zse.addGetterSetter(Vhe,"threshold",.5,$se(),Zse.afterSetFilter),xde.Util._assign(xde,{Arc:Sde,Arrow:Nde,Circle:_de,Ellipse:Dde,Image:Pde,Label:$de,Tag:qde,Line:Ade,Path:Rde,Rect:Gde,RegularPolygon:Yde,Ring:Xde,Sprite:Qde,Star:Jde,Text:due,TextPath:vue,Transformer:Vue,Wedge:Cue,Filters:{Blur:function(e){var t=Math.round(this.blurRadius());t>0&&function(e,t){var n,r,a,o,c,i,l,s,h,d,u,m,p,v,f,z,g,y,M,E,b,H,V,C,L=e.data,w=e.width,k=e.height,x=t+t+1,S=w-1,T=k-1,O=t+1,A=O*(O+1)/2,R=new Lue,N=null,_=R,D=null,P=null,F=wue[t],I=kue[t];for(a=1;a<x;a++)_=_.next=new Lue,a===O&&(N=_);for(_.next=R,l=i=0,r=0;r<k;r++){for(z=g=y=M=s=h=d=u=0,m=O*(E=L[i]),p=O*(b=L[i+1]),v=O*(H=L[i+2]),f=O*(V=L[i+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,a=0;a<O;a++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(a=1;a<O;a++)o=i+((S<a?S:a)<<2),s+=(_.r=E=L[o])*(C=O-a),h+=(_.g=b=L[o+1])*C,d+=(_.b=H=L[o+2])*C,u+=(_.a=V=L[o+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next;for(D=R,P=N,n=0;n<w;n++)L[i+3]=V=u*F>>I,0!==V?(V=255/V,L[i]=(s*F>>I)*V,L[i+1]=(h*F>>I)*V,L[i+2]=(d*F>>I)*V):L[i]=L[i+1]=L[i+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=l+((o=n+t+1)<S?o:S)<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,i+=4;l+=w}for(n=0;n<w;n++){for(g=y=M=z=h=d=u=s=0,m=O*(E=L[i=n<<2]),p=O*(b=L[i+1]),v=O*(H=L[i+2]),f=O*(V=L[i+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,a=0;a<O;a++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(c=w,a=1;a<=t;a++)i=c+n<<2,s+=(_.r=E=L[i])*(C=O-a),h+=(_.g=b=L[i+1])*C,d+=(_.b=H=L[i+2])*C,u+=(_.a=V=L[i+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next,a<T&&(c+=w);for(i=n,D=R,P=N,r=0;r<k;r++)L[3+(o=i<<2)]=V=u*F>>I,V>0?(V=255/V,L[o]=(s*F>>I)*V,L[o+1]=(h*F>>I)*V,L[o+2]=(d*F>>I)*V):L[o]=L[o+1]=L[o+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=n+((o=r+O)<T?o:T)*w<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,i+=w}}(e,t)},Brighten:function(e){var t,n=255*this.brightness(),r=e.data,a=r.length;for(t=0;t<a;t+=4)r[t]+=n,r[t+1]+=n,r[t+2]+=n},Contrast:function(e){var t,n=Math.pow((this.contrast()+100)/100,2),r=e.data,a=r.length,o=150,c=150,i=150;for(t=0;t<a;t+=4)o=r[t],c=r[t+1],i=r[t+2],o/=255,o-=.5,o*=n,o+=.5,c/=255,c-=.5,c*=n,c+=.5,i/=255,i-=.5,i*=n,i+=.5,o=(o*=255)<0?0:o>255?255:o,c=(c*=255)<0?0:c>255?255:c,i=(i*=255)<0?0:i>255?255:i,r[t]=o,r[t+1]=c,r[t+2]=i},Emboss:function(e){var t=10*this.embossStrength(),n=255*this.embossWhiteLevel(),r=this.embossDirection(),a=this.embossBlend(),o=0,c=0,i=e.data,l=e.width,s=e.height,h=4*l,d=s;switch(r){case"top-left":o=-1,c=-1;break;case"top":o=-1,c=0;break;case"top-right":o=-1,c=1;break;case"right":o=0,c=1;break;case"bottom-right":o=1,c=1;break;case"bottom":o=1,c=0;break;case"bottom-left":o=1,c=-1;break;case"left":o=0,c=-1;break;default:jse.error("Unknown emboss direction: "+r)}do{var u=(d-1)*h,m=o;d+m<1&&(m=0),d+m>s&&(m=0);var p=(d-1+m)*l*4,v=l;do{var f=u+4*(v-1),z=c;v+z<1&&(z=0),v+z>l&&(z=0);var g=p+4*(v-1+z),y=i[f]-i[g],M=i[f+1]-i[g+1],E=i[f+2]-i[g+2],b=y,H=b>0?b:-b;if((M>0?M:-M)>H&&(b=M),(E>0?E:-E)>H&&(b=E),b*=t,a){var V=i[f]+b,C=i[f+1]+b,L=i[f+2]+b;i[f]=V>255?255:V<0?0:V,i[f+1]=C>255?255:C<0?0:C,i[f+2]=L>255?255:L<0?0:L}else{var w=n-b;w<0?w=0:w>255&&(w=255),i[f]=i[f+1]=i[f+2]=w}}while(--v)}while(--d)},Enhance:function(e){var t,n,r,a,o=e.data,c=o.length,i=o[0],l=i,s=o[1],h=s,d=o[2],u=d,m=this.enhance();if(0!==m){for(a=0;a<c;a+=4)(t=o[a+0])<i?i=t:t>l&&(l=t),(n=o[a+1])<s?s=n:n>h&&(h=n),(r=o[a+2])<d?d=r:r>u&&(u=r);var p,v,f,z,g,y,M,E,b;for(l===i&&(l=255,i=0),h===s&&(h=255,s=0),u===d&&(u=255,d=0),m>0?(v=l+m*(255-l),f=i-m*(i-0),g=h+m*(255-h),y=s-m*(s-0),E=u+m*(255-u),b=d-m*(d-0)):(v=l+m*(l-(p=.5*(l+i))),f=i+m*(i-p),g=h+m*(h-(z=.5*(h+s))),y=s+m*(s-z),E=u+m*(u-(M=.5*(u+d))),b=d+m*(d-M)),a=0;a<c;a+=4)o[a+0]=xue(o[a+0],i,l,f,v),o[a+1]=xue(o[a+1],s,h,y,g),o[a+2]=xue(o[a+2],d,u,b,E)}},Grayscale:function(e){var t,n,r=e.data,a=r.length;for(t=0;t<a;t+=4)n=.34*r[t]+.5*r[t+1]+.16*r[t+2],r[t]=n,r[t+1]=n,r[t+2]=n},HSL:function(e){var t,n,r,a,o,c=e.data,i=c.length,l=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,h=127*this.luminance(),d=1*l*Math.cos(s*Math.PI/180),u=1*l*Math.sin(s*Math.PI/180),m=.299+.701*d+.167*u,p=.587-.587*d+.33*u,v=.114-.114*d-.497*u,f=.299-.299*d-.328*u,z=.587+.413*d+.035*u,g=.114-.114*d+.293*u,y=.299-.3*d+1.25*u,M=.587-.586*d-1.05*u,E=.114+.886*d-.2*u;for(t=0;t<i;t+=4)n=c[t+0],r=c[t+1],a=c[t+2],o=c[t+3],c[t+0]=m*n+p*r+v*a+h,c[t+1]=f*n+z*r+g*a+h,c[t+2]=y*n+M*r+E*a+h,c[t+3]=o},HSV:function(e){var t,n,r,a,o,c=e.data,i=c.length,l=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),h=Math.abs(this.hue()+360)%360,d=l*s*Math.cos(h*Math.PI/180),u=l*s*Math.sin(h*Math.PI/180),m=.299*l+.701*d+.167*u,p=.587*l-.587*d+.33*u,v=.114*l-.114*d-.497*u,f=.299*l-.299*d-.328*u,z=.587*l+.413*d+.035*u,g=.114*l-.114*d+.293*u,y=.299*l-.3*d+1.25*u,M=.587*l-.586*d-1.05*u,E=.114*l+.886*d-.2*u;for(t=0;t<i;t+=4)n=c[t+0],r=c[t+1],a=c[t+2],o=c[t+3],c[t+0]=m*n+p*r+v*a,c[t+1]=f*n+z*r+g*a,c[t+2]=y*n+M*r+E*a,c[t+3]=o},Invert:function(e){var t,n=e.data,r=n.length;for(t=0;t<r;t+=4)n[t]=255-n[t],n[t+1]=255-n[t+1],n[t+2]=255-n[t+2]},Kaleidoscope:function(e){var t,n,r,a,o,c,i,l,s,h=e.width,d=e.height,u=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),p=Math.floor(h*(m%360)/360);if(!(u<1)){var v=jse.createCanvasElement();v.width=h,v.height=d;var f=v.getContext("2d").getImageData(0,0,h,d);jse.releaseCanvas(v),function(e,t,n){var r,a,o,c,i=e.data,l=t.data,s=e.width,h=e.height,d=n.polarCenterX||s/2,u=n.polarCenterY||h/2,m=0,p=0,v=0,f=0,z=Math.sqrt(d*d+u*u);a=s-d,o=h-u,z=(c=Math.sqrt(a*a+o*o))>z?c:z;var g,y,M,E,b=h,H=s,V=360/H*Math.PI/180;for(y=0;y<H;y+=1)for(M=Math.sin(y*V),E=Math.cos(y*V),g=0;g<b;g+=1)a=Math.floor(d+z*g/b*E),m=i[0+(r=4*((o=Math.floor(u+z*g/b*M))*s+a))],p=i[r+1],v=i[r+2],f=i[r+3],l[0+(r=4*(y+g*s))]=m,l[r+1]=p,l[r+2]=v,l[r+3]=f}(e,f,{polarCenterX:h/2,polarCenterY:d/2});for(var z=h/Math.pow(2,u);z<=8;)z*=2,u-=1;var g=z=Math.ceil(z),y=0,M=g,E=1;for(p+z>h&&(y=g,M=0,E=-1),n=0;n<d;n+=1)for(t=y;t!==M;t+=E)l=4*(h*n+Math.round(t+p)%h),a=f.data[l+0],o=f.data[l+1],c=f.data[l+2],i=f.data[l+3],s=4*(h*n+t),f.data[s+0]=a,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=i;for(n=0;n<d;n+=1)for(g=Math.floor(z),r=0;r<u;r+=1){for(t=0;t<g+1;t+=1)l=4*(h*n+t),a=f.data[l+0],o=f.data[l+1],c=f.data[l+2],i=f.data[l+3],s=4*(h*n+2*g-t-1),f.data[s+0]=a,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=i;g*=2}!function(e,t,n){var r,a,o,c,i,l,s=e.data,h=t.data,d=e.width,u=e.height,m=n.polarCenterX||d/2,p=n.polarCenterY||u/2,v=0,f=0,z=0,g=0,y=Math.sqrt(m*m+p*p);a=d-m,o=u-p,y=(l=Math.sqrt(a*a+o*o))>y?l:y;var M,E,b,H=u,V=d,C=n.polarRotation||0;for(a=0;a<d;a+=1)for(o=0;o<u;o+=1)c=a-m,i=o-p,M=Math.sqrt(c*c+i*i)*H/y,E=(E=(180*Math.atan2(i,c)/Math.PI+360+C)%360)*V/360,b=Math.floor(E),v=s[0+(r=4*(Math.floor(M)*d+b))],f=s[r+1],z=s[r+2],g=s[r+3],h[0+(r=4*(o*d+a))]=v,h[r+1]=f,h[r+2]=z,h[r+3]=g}(f,e,{polarRotation:0})}},Mask:function(e){var t=function(e,t){var n=Sue(e,0,0),r=Sue(e,e.width-1,0),a=Sue(e,0,e.height-1),o=Sue(e,e.width-1,e.height-1),c=t||10;if(Tue(n,r)<c&&Tue(r,o)<c&&Tue(o,a)<c&&Tue(a,n)<c){for(var i=function(e){for(var t=[0,0,0],n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}([r,n,o,a]),l=[],s=0;s<e.width*e.height;s++){var h=Tue(i,[e.data[4*s],e.data[4*s+1],e.data[4*s+2]]);l[s]=h<c?0:255}return l}}(e,this.threshold());return t&&function(e,t){for(var n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}(e,t=function(e,t,n){for(var r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],a=Math.round(Math.sqrt(r.length)),o=Math.floor(a/2),c=[],i=0;i<n;i++)for(var l=0;l<t;l++){for(var s=i*t+l,h=0,d=0;d<a;d++)for(var u=0;u<a;u++){var m=i+d-o,p=l+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=r[d*a+u];h+=e[m*t+p]*v}}c[s]=h}return c}(t=function(e,t,n){for(var r=[1,1,1,1,1,1,1,1,1],a=Math.round(Math.sqrt(r.length)),o=Math.floor(a/2),c=[],i=0;i<n;i++)for(var l=0;l<t;l++){for(var s=i*t+l,h=0,d=0;d<a;d++)for(var u=0;u<a;u++){var m=i+d-o,p=l+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=r[d*a+u];h+=e[m*t+p]*v}}c[s]=h>=1020?255:0}return c}(t=function(e,t,n){for(var r=[1,1,1,1,0,1,1,1,1],a=Math.round(Math.sqrt(r.length)),o=Math.floor(a/2),c=[],i=0;i<n;i++)for(var l=0;l<t;l++){for(var s=i*t+l,h=0,d=0;d<a;d++)for(var u=0;u<a;u++){var m=i+d-o,p=l+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=r[d*a+u];h+=e[m*t+p]*v}}c[s]=2040===h?255:0}return c}(t,e.width,e.height),e.width,e.height),e.width,e.height)),e},Noise:function(e){var t,n=255*this.noise(),r=e.data,a=r.length,o=n/2;for(t=0;t<a;t+=4)r[t+0]+=o-2*o*Math.random(),r[t+1]+=o-2*o*Math.random(),r[t+2]+=o-2*o*Math.random()},Pixelate:function(e){var t,n,r,a,o,c,i,l,s,h,d,u,m,p,v=Math.ceil(this.pixelSize()),f=e.width,z=e.height,g=Math.ceil(f/v),y=Math.ceil(z/v),M=e.data;if(v<=0)jse.error("pixelSize value can not be <= 0");else for(u=0;u<g;u+=1)for(m=0;m<y;m+=1){for(a=0,o=0,c=0,i=0,s=(l=u*v)+v,d=(h=m*v)+v,p=0,t=l;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(a+=M[0+(r=4*(f*n+t))],o+=M[r+1],c+=M[r+2],i+=M[r+3],p+=1);for(a/=p,o/=p,c/=p,i/=p,t=l;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(M[0+(r=4*(f*n+t))]=a,M[r+1]=o,M[r+2]=c,M[r+3]=i)}},Posterize:function(e){var t,n=Math.round(254*this.levels())+1,r=e.data,a=r.length,o=255/n;for(t=0;t<a;t+=1)r[t]=Math.floor(r[t]/o)*o},RGB:function(e){var t,n,r=e.data,a=r.length,o=this.red(),c=this.green(),i=this.blue();for(t=0;t<a;t+=4)n=(.34*r[t]+.5*r[t+1]+.16*r[t+2])/255,r[t]=n*o,r[t+1]=n*c,r[t+2]=n*i,r[t+3]=r[t+3]},RGBA:function(e){var t,n,r=e.data,a=r.length,o=this.red(),c=this.green(),i=this.blue(),l=this.alpha();for(t=0;t<a;t+=4)n=1-l,r[t]=o*l+r[t]*n,r[t+1]=c*l+r[t+1]*n,r[t+2]=i*l+r[t+2]*n},Sepia:function(e){var t,n,r,a,o=e.data,c=o.length;for(t=0;t<c;t+=4)n=o[t+0],r=o[t+1],a=o[t+2],o[t+0]=Math.min(255,.393*n+.769*r+.189*a),o[t+1]=Math.min(255,.349*n+.686*r+.168*a),o[t+2]=Math.min(255,.272*n+.534*r+.131*a)},Solarize:function(e){var t=e.data,n=e.width,r=4*n,a=e.height;do{var o=(a-1)*r,c=n;do{var i=o+4*(c-1),l=t[i],s=t[i+1],h=t[i+2];l>127&&(l=255-l),s>127&&(s=255-s),h>127&&(h=255-h),t[i]=l,t[i+1]=s,t[i+2]=h}while(--c)}while(--a)},Threshold:function(e){var t,n=255*this.threshold(),r=e.data,a=r.length;for(t=0;t<a;t+=1)r[t]=r[t]<n?0:255}}});var Aue,Rue,Nue={exports:{}},_ue={exports:{}};function Due(){if(Rue)return Aue;Rue=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Aue=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,a){for(var o,c,i=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),l=1;l<arguments.length;l++){for(var s in o=Object(arguments[l]))t.call(o,s)&&(i[s]=o[s]);if(e){c=e(o);for(var h=0;h<c.length;h++)n.call(o,c[h])&&(i[c[h]]=o[c[h]])}}return i},Aue}var Pue,Fue,Iue,Bue,jue={exports:{}},Uue={},Wue={};function $ue(){return Iue||(Iue=1,"production"===ite.env.NODE_ENV?jue.exports=(Pue||(Pue=1,function(e){var t,n,r,a;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,i=c.now();e.unstable_now=function(){return c.now()-i}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var l=null,s=null,h=function(){if(null!==l)try{var t=e.unstable_now();l(!0,t),l=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==l?setTimeout(t,0,e):(l=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},r=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},a=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof m&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var p=!1,v=null,f=-1,z=5,g=0;e.unstable_shouldYield=function(){return e.unstable_now()>=g},a=function(){},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<e?Math.floor(1e3/e):5};var y=new MessageChannel,M=y.port2;y.port1.onmessage=function(){if(null!==v){var t=e.unstable_now();g=t+z;try{v(!0,t)?M.postMessage(null):(p=!1,v=null)}catch(e){throw M.postMessage(null),e}}else p=!1},t=function(e){v=e,p||(p=!0,M.postMessage(null))},n=function(t,n){f=d((function(){t(e.unstable_now())}),n)},r=function(){u(f),f=-1}}function E(e,t){var n=e.length;e.push(t);e:for(;;){var r=n-1>>>1,a=e[r];if(!(void 0!==a&&0<V(a,t)))break e;e[r]=t,e[n]=a,n=r}}function b(e){return void 0===(e=e[0])?null:e}function H(e){var t=e[0];if(void 0!==t){var n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,a=e.length;r<a;){var o=2*(r+1)-1,c=e[o],i=o+1,l=e[i];if(void 0!==c&&0>V(c,n))void 0!==l&&0>V(l,c)?(e[r]=l,e[i]=n,r=i):(e[r]=c,e[o]=n,r=o);else{if(!(void 0!==l&&0>V(l,n)))break e;e[r]=l,e[i]=n,r=i}}}return t}return null}function V(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var C=[],L=[],w=1,k=null,x=3,S=!1,T=!1,O=!1;function A(e){for(var t=b(L);null!==t;){if(null===t.callback)H(L);else{if(!(t.startTime<=e))break;H(L),t.sortIndex=t.expirationTime,E(C,t)}t=b(L)}}function R(e){if(O=!1,A(e),!T)if(null!==b(C))T=!0,t(N);else{var r=b(L);null!==r&&n(R,r.startTime-e)}}function N(t,a){T=!1,O&&(O=!1,r()),S=!0;var o=x;try{for(A(a),k=b(C);null!==k&&(!(k.expirationTime>a)||t&&!e.unstable_shouldYield());){var c=k.callback;if("function"==typeof c){k.callback=null,x=k.priorityLevel;var i=c(k.expirationTime<=a);a=e.unstable_now(),"function"==typeof i?k.callback=i:k===b(C)&&H(C),A(a)}else H(C);k=b(C)}if(null!==k)var l=!0;else{var s=b(L);null!==s&&n(R,s.startTime-a),l=!1}return l}finally{k=null,x=o,S=!1}}var _=a;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){T||S||(T=!0,t(N))},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return b(C)},e.unstable_next=function(e){switch(x){case 1:case 2:case 3:var t=3;break;default:t=x}var n=x;x=t;try{return e()}finally{x=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=_,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=x;x=e;try{return t()}finally{x=n}},e.unstable_scheduleCallback=function(a,o,c){var i=e.unstable_now();switch(c="object"==typeof c&&null!==c&&"number"==typeof(c=c.delay)&&0<c?i+c:i,a){case 1:var l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}return a={id:w++,callback:o,priorityLevel:a,startTime:c,expirationTime:l=c+l,sortIndex:-1},c>i?(a.sortIndex=c,E(L,a),null===b(C)&&a===b(L)&&(O?r():O=!0,n(R,c-i))):(a.sortIndex=l,E(C,a),T||S||(T=!0,t(N))),a},e.unstable_wrapCallback=function(e){var t=x;return function(){var n=x;x=t;try{return e.apply(this,arguments)}finally{x=n}}}}(Uue)),Uue):jue.exports=function(){return Fue||(Fue=1,e=Wue,"production"!==ite.env.NODE_ENV&&function(){var t,n,r,a;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,i=c.now();e.unstable_now=function(){return c.now()-i}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var l=null,s=null,h=function(){if(null!==l)try{var t=e.unstable_now();l(!0,t),l=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==l?setTimeout(t,0,e):(l=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},r=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},a=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.requestAnimationFrame,p=window.cancelAnimationFrame;"function"!=typeof m&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof p&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var v=!1,f=null,z=-1,g=5,y=0;e.unstable_shouldYield=function(){return e.unstable_now()>=y},a=function(){},e.unstable_forceFrameRate=function(e){e<0||e>125?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):g=e>0?Math.floor(1e3/e):5};var M=new MessageChannel,E=M.port2;M.port1.onmessage=function(){if(null!==f){var t=e.unstable_now();y=t+g;try{f(!0,t)?E.postMessage(null):(v=!1,f=null)}catch(e){throw E.postMessage(null),e}}else v=!1},t=function(e){f=e,v||(v=!0,E.postMessage(null))},n=function(t,n){z=d((function(){t(e.unstable_now())}),n)},r=function(){u(z),z=-1}}function b(e,t){var n=e.length;e.push(t),function(e,t,n){for(var r=n;;){var a=r-1>>>1,o=e[a];if(!(void 0!==o&&C(o,t)>0))return;e[a]=t,e[r]=o,r=a}}(e,t,n)}function H(e){var t=e[0];return void 0===t?null:t}function V(e){var t=e[0];if(void 0!==t){var n=e.pop();return n!==t&&(e[0]=n,function(e,t){for(var n=0,r=e.length;n<r;){var a=2*(n+1)-1,o=e[a],c=a+1,i=e[c];if(void 0!==o&&C(o,t)<0)void 0!==i&&C(i,o)<0?(e[n]=i,e[c]=t,n=c):(e[n]=o,e[a]=t,n=a);else{if(!(void 0!==i&&C(i,t)<0))return;e[n]=i,e[c]=t,n=c}}}(e,n)),t}return null}function C(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var L=[],w=[],k=1,x=null,S=3,T=!1,O=!1,A=!1;function R(e){for(var t=H(w);null!==t;){if(null===t.callback)V(w);else{if(!(t.startTime<=e))return;V(w),t.sortIndex=t.expirationTime,b(L,t)}t=H(w)}}function N(e){if(A=!1,R(e),!O)if(null!==H(L))O=!0,t(_);else{var r=H(w);null!==r&&n(N,r.startTime-e)}}function _(t,a){O=!1,A&&(A=!1,r()),T=!0;var o=S;try{return function(t,r){var a=r;for(R(a),x=H(L);null!==x&&(!(x.expirationTime>a)||t&&!e.unstable_shouldYield());){var o=x.callback;if("function"==typeof o){x.callback=null,S=x.priorityLevel;var c=o(x.expirationTime<=a);a=e.unstable_now(),"function"==typeof c?x.callback=c:x===H(L)&&V(L),R(a)}else V(L);x=H(L)}if(null!==x)return!0;var i=H(w);return null!==i&&n(N,i.startTime-a),!1}(t,a)}finally{x=null,S=o,T=!1}}var D=a;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){O||T||(O=!0,t(_))},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_getFirstCallbackNode=function(){return H(L)},e.unstable_next=function(e){var t;switch(S){case 1:case 2:case 3:t=3;break;default:t=S}var n=S;S=t;try{return e()}finally{S=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=D,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=S;S=e;try{return t()}finally{S=n}},e.unstable_scheduleCallback=function(a,o,c){var i,l,s=e.unstable_now();if("object"==typeof c&&null!==c){var h=c.delay;i="number"==typeof h&&h>0?s+h:s}else i=s;switch(a){case 1:l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}var d=i+l,u={id:k++,callback:o,priorityLevel:a,startTime:i,expirationTime:d,sortIndex:-1};return i>s?(u.sortIndex=i,b(w,u),null===H(L)&&u===H(w)&&(A?r():A=!0,n(N,i-s))):(u.sortIndex=d,b(L,u),O||T||(O=!0,t(_))),u},e.unstable_wrapCallback=function(e){var t=S;return function(){var n=S;S=t;try{return e.apply(this,arguments)}finally{S=n}}}}()),Wue;var e}()),jue.exports}
343
+ const h7=Z8("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]),d7=Z8("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);Z8("youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]);Z8("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);Z8("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);Z8("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);Z8("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);var u7=function(t){var r=t.amplitude,a=t.variant,o=t.isActive,l=t.className,h=void 0===l?"":l,d=t.onClick,u=t.disabled,m=void 0!==u&&u,p=t.isConnecting,v=c(Array(40).fill(4)),f=v[0],z=v[1],g=i(null),y=function(){var e=Math.min(Math.max(r,0),1),t=Math.max(e,.2),n=Array(40).fill(0).map((function(e,n){var r=Math.sin(n+Date.now()/100)+.5*Math.random();return 5+9*Math.abs(r)*t}));z(n),g.current=requestAnimationFrame(y)};s((function(){return o?g.current=requestAnimationFrame(y):(z(Array(40).fill(4)),g.current&&cancelAnimationFrame(g.current)),function(){g.current&&cancelAnimationFrame(g.current)}}),[o,r]);var E=o?"#364152":"#D0D4DB",b="microphone"===a?o||p?o7:a7:o?l7:s7;return e("div",M({className:h,style:{position:"relative",height:"3rem",zIndex:50,width:"100%",overflow:"hidden",display:"flex",alignItems:"center"}},{children:[n("div",M({style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",height:"2rem",gap:"0.25rem"}},{children:f.map((function(e,t){return n("div",{style:{flexShrink:0,width:"4px",borderRadius:"9999px",transition:"all 100ms",backgroundColor:E,height:"".concat(e,"px"),opacity:o?1:.4}},t)}))})),n("button",M({onClick:d,disabled:m,"aria-label":"".concat(a," button"),style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%, -50%)",width:"2rem",height:"2rem",borderRadius:"9999px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 200ms",backgroundColor:"white",border:"1px solid ".concat(E),cursor:m?"not-allowed":"pointer"}},{children:n(b,{color:E,className:p?"animate-spin":"",style:{width:"1.25rem",height:"1.25rem"}})}))]}))};C(".welcome-message{align-items:flex-start;animation:fadeSlideIn 1.2s ease-out forwards;border-radius:.5rem;color:#333;display:fixed;font-size:1rem;line-height:1.75rem;max-width:100%;opacity:0;overflow-wrap:break-word;padding:1rem;transform:translateY(10px);white-space:pre-wrap;word-break:break-word}@keyframes fadeSlideIn{to{opacity:1;transform:translateY(0)}}");var m7=function(t){var r=t.label,a=t.onToggle,o=c(!1),l=o[0],h=o[1],d=i(null);return s((function(){var e=d.current;e&&l&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[l]),e("span",M({ref:d,onClick:function(){var e=!l;console.log("newstate: ",e),h(e),a(r,e)},style:{cursor:"pointer",backgroundColor:l?"#E8F5E9":"#fff",color:l?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){l||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){l||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[n("span",M({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:l?"scale(1.2)":"scale(1)",opacity:l?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:l?"✓":"+"})),n("span",{children:r})]}))};function p7(e){return"string"==typeof e?e:Array.isArray(e)?e.map(p7).join(""):"object"==typeof e&&null!==e&&"props"in e?p7(e.props.children):""}var v7=function(t){var r=t.label,a=t.onToggle,o=t.isSelected,l=void 0!==o&&o,h=c(l),d=h[0],u=h[1],m=i(null);s((function(){u(l)}),[l]);return s((function(){var e=m.current;e&&d&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[d]),e("span",M({ref:m,onClick:function(){var e=!d;console.log("newstate: ",e),u(e),a(p7(r),e)},style:{cursor:"pointer",backgroundColor:d?"#E8F5E9":"#fff",color:d?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){d||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){d||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[n("span",M({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:d?"scale(1.2)":"scale(1)",opacity:d?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:d?"✓":"+"})),n("span",{children:r})]}))},f7=function(r){var o=r.index,d=r.content,u=r.messages,m=r.handleStream,p=r.scrollToBottom,v=c([]),f=v[0],z=v[1],g=c(!1),y=g[0],b=g[1],H=c(!1),C=H[0],L=H[1],w=c([]),k=w[0],x=w[1],S=c(!1),T=S[0],O=S[1],A=c(!1),R=A[0],N=A[1],_=c({}),D=_[0],P=_[1],F=c([]),I=F[0],B=F[1],j=c([]),U=j[0],W=j[1],$=c(d),q=$[0],G=$[1];s((function(){C||G(d)}),[d,C]);var Y=l((function(e,t){var n=Array.isArray(e)?e[0]:e;b(!0),z((function(e){return t?e.includes(n)?e:V(V([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}),[]),K=l((function(e,t){var n=Array.isArray(e)?e[0]:e;O(!0),x((function(e){return t?e.includes(n)?e:V(V([],e,!0),[n],!1):e.filter((function(e){return e!==n}))})),null==p||p()}),[p]),X=l((function(e,t,n){var r=Array.isArray(t)?t[0]:t;P((function(t){var a,o=t[e]||{selected:[],showSelected:!1,submitted:!1};return M(M({},t),((a={})[e]=M(M({},o),{showSelected:!0,selected:n?o.selected.includes(r)?o.selected:V(V([],o.selected,!0),[r],!1):o.selected.filter((function(e){return e!==r}))}),a))})),null==p||p()}),[p]),Q=l((function(e){return D[e]||{selected:[],showSelected:!1,submitted:!1}}),[D]),J=l((function(e,t){P((function(n){var r;return M(M({},n),((r={})[e]=M(M({},n[e]||{selected:[],showSelected:!1,submitted:!1}),t),r))}))}),[]),Z={deletesimilarlearning:{group:"similarLearning",action:"delete",displayName:"Delete similar learning"},mergesimilarlearning:{group:"similarLearning",action:"merge",displayName:"Merge similar learning"},editsimilarlearning:{group:"similarLearning",action:"edit",displayName:"Edit similar learning"},deletesimilarlearnings:{group:"similarLearnings",action:"delete",displayName:"Delete similar learnings"},mergesimilarlearnings:{group:"similarLearnings",action:"merge",displayName:"Merge similar learnings"},editsimilarlearnings:{group:"similarLearnings",action:"edit",displayName:"Edit similar learnings"},deleteconflictinglearning:{group:"conflictingLearning",action:"delete",displayName:"Delete conflicting learning"},editconflictinglearning:{group:"conflictingLearning",action:"edit",displayName:"Edit conflicting learning"},deleteconflictinglearnings:{group:"conflictingLearnings",action:"delete",displayName:"Delete conflicting learnings"},editconflictinglearnings:{group:"conflictingLearnings",action:"edit",displayName:"Edit conflicting learnings"}},ee=l((function(t){return function(r){r.node;var a=E(r,["node"]),o=a.label||a.children||"Unknown label",c=Array.isArray(o)?o[0]:o,i=Q(t),l=Z[t],s=Object.keys(Z).filter((function(e){return Z[e].group===l.group})),h=s.some((function(e){return e!==t&&Q(e).submitted}));return i.submitted?i.selected.includes(c)?e("span",M({style:{backgroundColor:"#E8F5E9",color:"#2E7D32",padding:"4px 8px",borderRadius:"4px",fontWeight:"500",display:"inline-block",margin:"2px"}},{children:["✓ ",o]})):null:h?null:n(v7,{label:o,isSelected:i.selected.includes(c),onToggle:function(e,n){X(t,e,n)}})}}),[Q,X]),te=l((function(e){return a.Children.toArray(e).filter((function(e){if(!e||"object"!=typeof e)return!0;for(var t=p7(e),n=function(e,n){if(t.includes(n.displayName)){var r=Object.keys(Z).filter((function(e){return Z[e].group===n.group}));if(r.some((function(t){return t!==e&&Q(t).submitted})))return{value:!1}}},r=0,a=Object.entries(Z);r<a.length;r++){var o=a[r],c=n(o[0],o[1]);if("object"==typeof c)return c.value}return!0}))}),[Q]),ne=i(d);s((function(){ne.current!==d&&(P({}),ne.current=d)}),[d]);var re=h((function(){return{img:function(e){e.node;var t=E(e,["node"]);return n("img",M({},t,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==t?void 0:t.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var t=E(e,["node"]);return n("p",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==t?void 0:t.children}))},code:function(e){e.node;var t=E(e,["node"]);return n("span",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==t?void 0:t.children}))},ol:function(e){e.node;var t=E(e,["node"]),r=te(null==t?void 0:t.children);return n("ol",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:r}))},ul:function(e){e.node;var t=E(e,["node"]),r=te(null==t?void 0:t.children);return n("ul",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:r}))},wta:function(t){t.node;var r=E(t,["node"]);r.key||r["data-key"];var a=r.label||r.children||"Unknown label",o=Array.isArray(a)?a[0]:a;return C?f.includes(o)?e("span",M({style:{backgroundColor:"#E8F5E9",color:"#2E7D32",padding:"4px 8px",borderRadius:"4px",fontWeight:"500",display:"inline-block",margin:"2px"}},{children:["✓ ",a]})):null:n(m7,{label:a,onToggle:function(e,t){Y(e,t)}})},editwta:function(t){t.node;var r=E(t,["node"]);r.key||r["data-key"];var a=r.label||r.children||"Unknown label",o=Array.isArray(a)?a[0]:a;return R?k.includes(o)?e("span",M({style:{backgroundColor:"#E8F5E9",color:"#2E7D32",padding:"4px 8px",borderRadius:"4px",fontWeight:"500",display:"inline-block",margin:"2px"}},{children:["✓ ",a]})):null:n(v7,{label:a,onToggle:function(e,t){K(e,t)}})},deletesimilarlearning:ee("deletesimilarlearning"),mergesimilarlearning:ee("mergesimilarlearning"),editsimilarlearning:ee("editsimilarlearning"),deletesimilarlearnings:ee("deletesimilarlearnings"),mergesimilarlearnings:ee("mergesimilarlearnings"),editsimilarlearnings:ee("editsimilarlearnings"),deleteconflictinglearning:ee("deleteconflictinglearning"),editconflictinglearning:ee("editconflictinglearning"),deleteconflictinglearnings:ee("deleteconflictinglearnings"),editconflictinglearnings:ee("editconflictinglearnings")}}),[d,u,U,D,te,ee]);!function(e,t){s((function(){for(var n,r=0,a=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];r<a.length;r++){for(var o=a[r],c=(null==o?void 0:o.responsedata)||"",i=/<wta>([\s\S]*?)<\/wta>/gi,l=[],s=void 0;null!==(s=i.exec(c));)console.log("match wta suggestion",s),l.push(s[1]);l.length&&t(l)}}),[e,t])}(u,B);!function(e){s((function(){for(var t,n=0,r=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];n<r.length;n++){for(var a=r[n],o=(null==a?void 0:a.responsedata)||"",c=/<editwta>([\s\S]*?)<\/editwta>/gi,i=[],l=void 0;null!==(l=c.exec(o));)console.log("match wta suggestion",l),i.push(l[1]);i.length&&W(i)}}),[e,W])}(u);var ae=h((function(){if(!Array.isArray(f)||!Array.isArray(I))return"";var e=f.map((function(e){return I.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[f,I]),oe=h((function(){if(!Array.isArray(k)||!Array.isArray(U))return"";var e=k.map((function(e){var t;return null===(t=U.map((function(e){return null==e?void 0:e.replaceAll("**","")})))||void 0===t?void 0:t.indexOf(e)})).filter((function(e){return-1!==e})).map((function(e){return e+1}));return e.join(" and ")}),[k,U]);return e(t,{children:[n(vM,M({components:re,rehypePlugins:[sC]},{children:q}),o),n("div",M({style:{display:"flex",maxWidth:"100%"}},{children:n("div",M({style:{width:"100%"}},{children:(null==f?void 0:f.length)>0&&y?e("span",{children:["It looks like you've chosen ",f.length>1?"suggestions":"suggestion"," ",ae,". Would you like me to proceed with them?",n("p",{children:n("button",M({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t,n=f.map((function(e){return"<wta>".concat(e,"</wta>")})).join(" "),r=q.replace(/<wta>[\s\S]*?<\/wta>(?:\s*(?:or\s*)?<wta>[\s\S]*?<\/wta>)*/g,n);G(r),L(!0),b(!1),m(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Add when to apply conditions ".concat(null===(t=f.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,"")))}},{children:"Yes"}))})]}):n("span",{})}))})),n("div",M({style:{display:"flex",maxWidth:"100%"}},{children:n("div",M({style:{width:"100%"}},{children:(null==k?void 0:k.length)>0&&T?e("span",{children:["It looks like you've chosen ",k.length>1?"options":"option"," ",oe,". Would you like me to proceed with them?",n("p",{children:n("button",M({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t;m(new KeyboardEvent("keydown",{key:"Enter"}),!1,"".concat(null===(t=k.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,""))),O(!1),N(!0)}},{children:"Yes"}))})]}):n("span",{})}))})),function(){var t=Object.entries(D).filter((function(e){e[0];var t=e[1];return t.selected.length>0&&t.showSelected}));if(0===t.length)return null;var r=t[0],a=r[0],o=r[1],c=Z[a];return n("div",M({style:{display:"flex",maxWidth:"100%"}},{children:n("div",M({style:{width:"100%"}},{children:e("span",{children:["It looks like you've chosen ",o.selected.length>1?"options":"option"," for ",c.displayName,". Would you like me to proceed with them?",n("p",{children:n("button",M({style:{padding:"0.5rem 1rem",margin:"1rem 0rem",backgroundColor:"#4CAF50",color:"white",border:"none",borderRadius:"8px",cursor:"pointer",fontSize:"0.75rem",fontWeight:"500",boxShadow:"0 2px 5px rgba(0, 0, 0, 0.2)",transition:"background-color 0.3s",fontFamily:"Plus Jakarta Sans, sans-serif"},onClick:function(e){var t;m(new KeyboardEvent("keydown",{key:"Enter"}),!1,"".concat(null===(t=o.selected.join(" or "))||void 0===t?void 0:t.replace(/\b\d+[A-Z]?\.\s*/g,""))),J(a,{showSelected:!1,submitted:!0})}},{children:"Yes"}))})]})}))}))}()]})};function z7(e){return e.replace(/\bFalse\b/g,"false").replace(/\bTrue\b/g,"true").replace(/([{,]\s*)'([^']+?)'\s*:/g,'$1"$2":').replace(/:\s*'([^']*?)'/g,(function(e,t){var n=t.replace(/"/g,'\\"');return': "'.concat(n,'"')})).replace(/\bNone\b/g,"null")}function g7(e){var t=e.baseUrl,n=e.organizationName,r=e.payload,a=e.additionalHeaders,o="".concat(t,"/api/chatbot/publishAgenticFeedbackForVariantIngestion?name=ilnewtest&organizationName=").concat(encodeURIComponent(n));return fetch(o,{method:"POST",headers:M({"Content-Type":"application/json"},null!=a?a:{}),credentials:"include",body:"string"==typeof r?r:JSON.stringify(r)}).catch((function(e){throw console.error("[InstantLearningService] Fetch error:",e),e}))}var y7,M7,E7=function(){return n("svg",M({width:"20px",height:"20px",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{d:"M9.91158 12H7.45579H4L2.02268 4.13539C2.0111 4.0893 2.00193 4.04246 2.00046 3.99497C1.97811 3.27397 2.77209 2.77366 3.46029 3.10388L22 12L3.46029 20.8961C2.77983 21.2226 1.99597 20.7372 2.00002 20.0293C2.00038 19.9658 2.01455 19.9032 2.03296 19.8425L3.5 15",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))},b7=function(t){var r=t.resetChatHistory,a=t.isStreamEnd;return e("div",M({className:j8,style:{width:"100%",padding:"0.75rem 0rem",display:"flex",alignItems:"center",justifyContent:"space-between",backgroundColor:"#fff",borderBottom:"1px solid #e5e7eb",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.04)"}},{children:[e("span",M({style:{fontSize:"1.25rem",fontWeight:700,color:"#1f2937",flex:1,marginLeft:"0.5rem",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[n("span",M({style:{color:"#5928ED"}},{children:"InstantLearning.AI"}))," Chat"]})),n(LJ,M({title:"New chat",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n("div",M({onClick:function(){console.log(B8,"hello"),a&&r()},style:{height:"1.8rem",width:"1.8rem",marginLeft:"1rem",marginRight:"0.5rem",cursor:a?"pointer":"not-allowed",backgroundColor:"transparent",transition:"transform 0.2s ease-in-out, opacity 0.2s",opacity:a?.8:.4,pointerEvents:a?"auto":"none"},onMouseOver:function(e){a&&(e.currentTarget.style.opacity="1")},onMouseOut:function(e){a&&(e.currentTarget.style.opacity="0.8")}},{children:n(B8,{})}))}))]}))},H7=function(e,t,n,r){return b(void 0,void 0,void 0,(function(){var a,o,c,i,l,s,h,d,u,m;return H(this,(function(p){switch(p.label){case 0:a=e.delete_current_learning,o=e.deleted_similar_learning_ids,c=e.deleted_conflicting_learning_ids,console.log("Processing delete tool call:",e),i=V(V([],o||[],!0),c||[],!0),l=0,s=i,p.label=1;case 1:if(!(l<s.length))return[3,6];h=s[l],p.label=2;case 2:return p.trys.push([2,4,,5]),d={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:h,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(h),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},console.log("Deleting learning with ID: ".concat(h)),[4,g7({baseUrl:t,organizationName:n,chatAssistantName:r,payload:d})];case 3:return(u=p.sent()).ok?console.log("Successfully deleted learning ".concat(h)):console.error("Failed to delete learning ".concat(h,":"),u.status,u.statusText),[3,5];case 4:return m=p.sent(),console.error("Error deleting learning ".concat(h,":"),m),[3,5];case 5:return l++,[3,1];case 6:return a&&console.log("Delete current learning flag is true - this will be handled later"),[2]}}))}))},V7=function(t){var r=t.label,a=t.onToggle,o=c(!1),l=o[0],h=o[1],d=i(null);return s((function(){var e=d.current;e&&l&&(e.style.boxShadow="0 2px 8px rgba(0, 0, 0, 0.1)",e.style.transform="scale(1)",e.style.backgroundColor="#E8F5E9",e.style.color="#2E7D32")}),[l]),e("span",M({ref:d,onClick:function(){var e=!l;h(e),a(r,e)},style:{cursor:"pointer",backgroundColor:l?"#E8F5E9":"#fbfaff",color:l?"#2E7D32":"#000000de",transition:"all 0.2s ease-in-out",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.2)",transform:"scale(1)"},onMouseEnter:function(e){l||(e.currentTarget.style.boxShadow="0 4px 12px rgba(30, 136, 229, 0.3)",e.currentTarget.style.transform="scale(1.02)",e.currentTarget.style.backgroundColor="#f0f7ff",e.currentTarget.style.color="#1E88E5")},onMouseLeave:function(e){l||(e.currentTarget.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.2)",e.currentTarget.style.transform="scale(1)",e.currentTarget.style.backgroundColor="#fbfaff",e.currentTarget.style.color="#000000de")}},{children:[n("span",M({style:{fontWeight:"bold",fontSize:"16px",transition:"all 0.3s ease",transform:l?"scale(1.2)":"scale(1)",opacity:l?1:.9,paddingLeft:"0.25rem",paddingRight:"0.25rem"}},{children:l?"✓":"+"})),n("span",{children:r})]}))},C7=function(r){r.chatAssistantLogoUrl;var a=r.chatAssistantName,o=r.organizationName,d=r.baseUrl,u=r.setInstantLearningSuggestions,m=r.formDataState,p=r.setFormDataState;r.hasUserFilledForm;var v=r.setHasUserFilledForm,f=r.baseWebsocketUrl,z=r.setIsNewChatClicked;r.selectedText,r.ChatIconComponent,r.ggcAssistantName;var g=r.ThinkingBulbIconComponent;r.hasUserWrittenModification;var y=r.setExtractedModification,C=r.setSave,L=r.setExtractedTooltip,w=r.setIsSaveLoading;r.isSaveLoading,r.save,r.instantLearningSuggestions,r.template;var k=r.setShouldTriggerSave,x=r.validationWtaResponse,S=r.setValidationWtaResponse,T=r.learningWtaResponse,O=r.setLearningWtaResponse,A=r.isFormSaveClicked,R=r.setIsFormSavedClicked,N=r.onDeleteLearning,_=r.deleteLearningTrigger,D=r.setDeleteLearningTrigger;r.onMergeLearning;var P=r.mergeLearningTrigger,F=r.setMergeLearningTrigger,I=r.onResetLearningData,B=r.setEditConflictingLearningTrigger,j=r.setEditSimilarLearningTrigger,U=r.sendMessageInChat,W=r.setSendMessageInChat,$=r.setIsMergeLoading,q=a,G=i("".concat(q,"-").concat(o,"-").concat(N8())),Y=i("".concat(N8())),K=d,X=i(null),Q=i(null),J=c([]),Z=J[0],ee=J[1],te=c(!1);te[0];var ne=te[1],re=c(""),ae=re[0],oe=re[1],ce=c(""),ie=ce[0],le=ce[1],se=c([]),he=se[0],de=se[1],ue=c(!1),me=ue[0],pe=ue[1],ve=c(!1);ve[0];var fe=ve[1],ze=c(!0),ge=ze[0],ye=ze[1],Me=c(!0),Ee=Me[0],be=Me[1],He=c("");He[0];var Ve=He[1],Ce=c(""),Le=Ce[0],we=Ce[1],ke=c(!1),xe=ke[0],Se=ke[1],Te=c(!1),Oe=Te[0],Ae=Te[1],Re=c(!1),Ne=Re[0],_e=Re[1],De=c([]);De[0];var Pe=De[1],Fe=c(new Set),Ie=Fe[0],Be=Fe[1],je=c(new Set),Ue=je[0],We=je[1],$e=i(""),qe=i(""),Ge=i(new Set),Ye=h((function(){return""===(null==ae?void 0:ae.trim())||xe}),[ae,xe]),Ke=i(null),Xe=c("100%"),Qe=Xe[0],Je=Xe[1];h((function(){var e,t,n;return!(""===(null===(e=null==m?void 0:m.original)||void 0===e?void 0:e.trim())||(null==m?void 0:m.isTooltipEnabled)&&""===(null===(t=null==m?void 0:m.tooltip)||void 0===t?void 0:t.trim())||(null==m?void 0:m.isModificationEnabled)&&""===(null===(n=null==m?void 0:m.modification)||void 0===n?void 0:n.trim()))}),[m]),s((function(){var e='Please tell me how I should correct "'.concat((null==m?void 0:m.original)||"",'"? ');le(e)}),[m]),s((function(){var e=X.current,t=function(){var e=X.current;if(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;_e(!(n-(t+r)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[Ne,ge,he]);var Ze=l((function(e){return b(void 0,void 0,void 0,(function(){var t,n,r,a,c,i,l;return H(this,(function(s){switch(s.label){case 0:if(t=JSON.stringify({deleted_similar_learning_ids:e.deleted_similar_learning_ids||[],deleted_conflicting_learning_ids:e.deleted_conflicting_learning_ids||[],delete_current_learning:e.delete_current_learning||!1}),Ge.current.has(t))return console.log("Delete operation already processed, skipping callback execution:",t),[2];Ge.current.add(t),console.log("Processing new delete operation:",t),s.label=1;case 1:return s.trys.push([1,3,,4]),[4,H7(e,d,o,q)];case 2:return s.sent(),n=e.deleted_similar_learning_ids,r=void 0===n?[]:n,a=e.deleted_conflicting_learning_ids,c=void 0===a?[]:a,i=V(V([],r||[],!0),c||[],!0),Be((function(e){var t=new Set(e);return i.forEach((function(e){return t.add(e)})),console.log("Added deleted learning IDs to tracking set:",Array.from(t)),t})),console.log("UI state updated after deletion of learnings:",i),[3,4];case 3:throw l=s.sent(),Ge.current.delete(t),console.error("Error processing delete operation:",l),l;case 4:return[2]}}))}))}),[d,o,q,Be]),et=l((function(e){return b(void 0,void 0,void 0,(function(){var t,n,r,a,c,i,l,s,h,u,v,f;return H(this,(function(z){switch(z.label){case 0:$(!0),console.log("🔴 MERGE CALLBACK - Processing merge tool call:",e),z.label=1;case 1:if(z.trys.push([1,6,7,8]),t=e.merge_learnings,n=e.similar_learnings,r=e.conditions_whentoapply,a=e.conditions_whennottoapply,console.log("🔴 MERGE CALLBACK - Extracted data:"),console.log("merge_learnings:",t),console.log("similar_learnings:",n),console.log("conditions_whentoapply:",r),console.log("conditions_whennottoapply:",a),!t||!n||!Array.isArray(n))return console.log("Invalid merge tool data, skipping"),[2];console.log(" MERGE CALLBACK - Current formDataState before replacement:",m),console.log(" MERGE CALLBACK - Current whenToApply:",null==m?void 0:m.whenToApply),console.log(" MERGE CALLBACK - Current whenNotToApply:",null==m?void 0:m.whenNotToApply),r&&Array.isArray(r)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenToApply conditions:",r),c=r.join(" OR "),console.log(" MERGE CALLBACK - New whenToApply string:",c),p((function(e){console.log(" MERGE CALLBACK - Previous formDataState:",e);var t=M(M({},e),{whenToApply:c,_mergeUpdate:!0,_mergeWTA:r});return console.log("MERGE CALLBACK - New formDataState:",t),t}))),a&&Array.isArray(a)&&(console.log(" MERGE CALLBACK - UNCONDITIONALLY replacing whenNotToApply conditions:",a),i=a.join(" OR "),console.log(" MERGE CALLBACK - New whenNotToApply string:",i),p((function(e){console.log(" MERGE CALLBACK - Previous formDataState for WNTA:",e);var t=M(M({},e),{whenNotToApply:i,_mergeUpdate:!0,_mergeWNTA:a});return console.log(" MERGE CALLBACK - New formDataState for WNTA:",t),t}))),We((function(e){var t=new Set(e);return n.forEach((function(e){return t.add(e)})),console.log("Added merged learning IDs to tracking set:",Array.from(t)),t})),l=0,s=n,z.label=2;case 2:return l<s.length?(h=s[l],console.log("Sending delete request for merged learning ID: ".concat(h)),u={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:h,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(h),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},[4,g7({baseUrl:d,organizationName:o,chatAssistantName:q,payload:u})]):[3,5];case 3:(v=z.sent()).ok?console.log("Successfully deleted merged learning ID ".concat(h)):console.error("Failed to delete merged learning ID ".concat(h,":"),v.statusText),z.label=4;case 4:return l++,[3,2];case 5:return[3,8];case 6:return f=z.sent(),console.error("Error processing merge operation:",f),[3,8];case 7:return console.log("switched off"),$(!1),[7];case 8:return[2]}}))}))}),[N,We,p,$]),tt=function(e,t,n){return h((function(){for(var r,a=[],o=/['"]conditions_whentoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\2).)*\2\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\3).)*\3\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])\s*,\s*['"]conditions_whennottoapply['"]\s*:\s*(\[\s*\]|\[\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\5).)*\5\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\}(?:\s*,\s*\{\s*['"]when_not_to_apply['"]\s*:\s*(['"])(?:\\.|(?!\6).)*\6\s*,\s*['"]confidence_score['"]\s*:\s*\d+\s*\})*\s*\])/,c=/['"]is_valid['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflictingConditions['"]\s*:\s*\[\s*(?:\{[\s\S]*?['"]conflictType['"]\s*:\s*['"][^'"]+['"][\s\S]*?\}\s*,?\s*)*\]\s*,\s*['"]save['"]\s*:\s*(true|false|True|False)/,i=/['"]is_valid_db['"]\s*:\s*(true|false|True|False)\s*,\s*['"]conflicting_learnings['"]\s*:\s*\{[\s\S]*?\}\s*,\s*['"]similar_learnings['"]\s*:\s*\{[\s\S]*?\}\s*,\s*["']save["']\s*:\s*(true|false|True|False)/,l=/['"]delete_current_learning['"]\s*:\s*(true|false|True|False)\s*,\s*['"]deleted_similar_learning_ids['"]\s*:\s*\[[\s\S]*?\]\s*,\s*['"]deleted_conflicting_learning_ids['"]\s*:\s*\[[\s\S]*?\]/,s=/{\s*['"]merge_learnings['"]\s*:\s*(?:True|true)[\s\S]+?}/,h=/({[\s\S]*}|\[[\s\S]*\])/,d=0,u=(null===(r=e[e.length-1])||void 0===r?void 0:r.orchestratorAndAgentsMessages)||[];d<u.length;d++){var m=u[d],p=(null==m?void 0:m.responsedata)||"";console.log("🔍 RESPONSE DATA:",String(p)),String(p).includes("merge_learnings")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(p))),String(p).includes("'merge_learnings'")&&(console.log("🔍 FOUND merge_learnings in response!"),console.log("🔍 Full response:",String(p)));var v=p.match(o);if(v)try{var f=q8.parse("{".concat(v[0],"}"));a.push(f)}catch(e){console.error("Failed to parse JSON:",e)}var z=p.match(c);if(console.log("validationObj before cond "),z)try{var g=z7(z[0]||""),y=q8.parse("{".concat(g,"}"));console.log("validationObj before set ",y),S(y),console.log("validationObj after set in chat",x)}catch(e){console.error("Failed to parse validation JSON:",e)}try{var M=z7(p||""),E=q8.parse(M);if(E&&"object"==typeof E&&"is_valid_db"in E&&"conflicting_learnings"in E&&"similar_learnings"in E)console.log("Found validation data in response:",E),O(E),console.log("dbVal after set in chat",T);else if(V=p.match(i)){var b=z7(V[0]||""),H=q8.parse("{".concat(b,"}"));O(H),console.log("dbVal after set in chat (regex fallback)",T)}}catch(e){var V;if(console.log("JSON parsing failed, trying regex fallback for validation data"),V=p.match(i))try{b=z7(V[0]||""),H=q8.parse("{".concat(b,"}"));O(H),console.log("dbVal after set in chat (regex fallback)",T)}catch(e){console.error("Failed to parse validation JSON with regex fallback:",e)}}var C=p.match(l);if(C)try{var L=z7(C[0]||""),w=q8.parse("{".concat(L,"}"));console.log("Delete tool detected:",w),t&&t(w)}catch(e){console.error("Failed to parse delete tool JSON:",e)}console.log("🔍 Testing merge tool regex on response data...");var k=p.match(s);if(console.log("🔍 Merge tool regex match result:",k),k){console.log("🔍 MERGE TOOL REGEX MATCHED!");try{var A=z7(k[0]),R=q8.parse(A);console.log("✅ Correctly parsed merge tool object:",R),n&&n(R)}catch(e){console.error("Failed to parse merge tool JSON:",e)}}var N=p.match(h);if(N&&p.includes("edit_actions"))try{console.log("Edit tool match found:",N[0]);A=z7(N[0]);var _=q8.parse(A);console.log("Edit tool detected and parsed successfully:",_),_.conflicting_learnings&&(B(_.conflicting_learnings),console.log("Setting edit conflicting learning trigger:",_.conflicting_learnings)),_.similar_learnings&&(j(_.similar_learnings),console.log("Setting edit similar learning trigger:",_.similar_learnings))}catch(e){console.error("Failed to parse edit tool JSON:",e)}}return a}),[e,t])}(he,Ze,et);s((function(){var e=(null==tt?void 0:tt[(null==tt?void 0:tt.length)-1])||null;e&&(u(e),console.log("Parsed suggestions:",tt))}),[tt]),s((function(){if(T&&0!==Ie.size){var e=T.conflicting_learnings&&Object.values(T.conflicting_learnings).some((function(e){return Ie.has(e.id)})),t=T.similar_learnings&&Object.values(T.similar_learnings).some((function(e){return Ie.has(e.id)}));if(e||t){var n=JSON.stringify({deletedIds:Array.from(Ie).sort()});if($e.current!==n){var r=M({},T);if(r.conflicting_learnings){var a=Object.values(r.conflicting_learnings).filter((function(e){return!Ie.has(e.id)}));console.log("[ChatComponent] Re-keying conflicting learnings:",{originalKeys:Object.keys(r.conflicting_learnings),remainingCount:a.length,remainingLearnings:a.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var o={};a.forEach((function(e,t){var n=String.fromCharCode(65+t);o[n]=e,console.log("[ChatComponent] Conflicting learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),r.conflicting_learnings=o,console.log("[ChatComponent] Final conflicting learnings keys:",Object.keys(o))}if(r.similar_learnings){var c=Object.values(r.similar_learnings).filter((function(e){return!Ie.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings:",{originalKeys:Object.keys(r.similar_learnings),remainingCount:c.length,remainingLearnings:c.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var i={};c.forEach((function(e,t){var n=String.fromCharCode(65+t);i[n]=e,console.log("[ChatComponent] Similar learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),r.similar_learnings=i,console.log("[ChatComponent] Final similar learnings keys:",Object.keys(i))}$e.current=n,console.log("Filtered learningWtaResponse after deletion:",r),O(r)}}}}),[Ie,T,O]),s((function(){if(T&&0!==Ue.size&&(T.similar_learnings&&Object.values(T.similar_learnings).some((function(e){return Ue.has(e.id)})))){var e=JSON.stringify({mergedIds:Array.from(Ue).sort()});if(qe.current!==e){var t=M({},T);if(t.similar_learnings){var n=Object.values(t.similar_learnings).filter((function(e){return!Ue.has(e.id)}));console.log("[ChatComponent] Re-keying similar learnings after merge:",{originalKeys:Object.keys(t.similar_learnings),remainingCount:n.length,remainingLearnings:n.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var r={};n.forEach((function(e,t){var n=String.fromCharCode(65+t);r[n]=e,console.log("[ChatComponent] Similar learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),t.similar_learnings=r,console.log("[ChatComponent] Final similar learnings keys after merge:",Object.keys(r))}qe.current=e,console.log("Filtered learningWtaResponse after merge:",t),O(t)}}}),[Ue,T,O]);var nt=function(e){return h((function(){for(var t,n=[],r=/['"](\w+)['"]\s*:\s*['"](.*?)['"]/g,a=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];a<o.length;a++){var c=o[a],i=((null==c?void 0:c.responsedata)||"").match(r);if(i)try{var l=q8.parse("{".concat(i[0],"}"));n.push(l)}catch(e){console.error("Failed to parse JSON for header message:",e)}}return n}),[e])}(he);s((function(){var e=(null==nt?void 0:nt[(null==nt?void 0:nt.length)-1])||null;e&&y(e.modification)}),[nt]);!function(e,t){s((function(){for(var n,r=0,a=(null===(n=e[e.length-1])||void 0===n?void 0:n.orchestratorAndAgentsMessages)||[];r<a.length;r++){for(var o=a[r],c=(null==o?void 0:o.responsedata)||"",i=/<wta>([\s\S]*?)<\/wta>/gi,l=[],s=void 0;null!==(s=i.exec(c));)console.log("match wta suggestion",s),l.push(s[1]);l.length&&t(l)}}),[e,t])}(he,Pe);var rt=function(e){return h((function(){for(var t,n=[],r=/^\{\s*(['"])(\w+)\1\s*:\s*(['"])(.*?)\3\s*\}$/,a=0,o=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];a<o.length;a++){var c=o[a],i=((null==c?void 0:c.responsedata)||"").match(r);if(i){console.log("match: ",i[0]);try{var l=q8.parse(i[0]);n.push(l)}catch(e){console.error("Failed to parse JSON:",e)}}}return n}),[e])}(he);s((function(){var e=(null==rt?void 0:rt[(null==rt?void 0:rt.length)-1])||null;e&&(console.log("latestParseTooltip: ",e),L(null==e?void 0:e.tooltip))}),[rt]);var at=function(e){var t=c([]),n=t[0],r=t[1];return s((function(){for(var t,n=[],a=/\{\s*['"]save['"]\s*:\s*(True|False|true|false)\s*\}/,o=0,c=(null===(t=e[e.length-1])||void 0===t?void 0:t.orchestratorAndAgentsMessages)||[];o<c.length;o++){var i=c[o],l=((null==i?void 0:i.responsedata)||"").match(a);if(l)try{var s=l[0].replace(/\bTrue\b/,"true").replace(/\bFalse\b/,"false").replace(/'/g,'"');console.log("corrected:",s);var h=q8.parse(s);!0===h.save&&k(!0),n.push(h)}catch(e){console.error("Failed to parse JSON:",e)}}r(n)}),[e]),n}(he);s((function(){var e=(null==at?void 0:at[(null==at?void 0:at.length)-1])||null;if(e&&"boolean"==typeof e.save){w(!0);var t=setTimeout((function(){w(!1),C(e.save)}),200);return function(){clearTimeout(t)}}}),[at]),s((function(){A&&(ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,"Save it"),R(!1))}),[A]),s((function(){if(_&&N){var e="Delete learning ".concat(_);ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,e),D&&D(null)}}),[_,N,D]),s((function(){U&&(ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,U),W(""))}),[U]),s((function(){ct(),it();var e=function(){var e,t=(null===(e=null==Ke?void 0:Ke.current)||void 0===e?void 0:e.clientHeight)||0,n="calc(100% - ".concat(t,"px - 10px");Je(n)};return e(),window.addEventListener("resize",e),function(){return window.removeEventListener("resize",e)}}),[]);var ot=l((function(){var e=X.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),_e(!1)}),100)}),[]);s((function(){(null==Z?void 0:Z.length)>0&&ot()}),[Z]);var ct=function(){var e={method:"get",maxBodyLength:1/0,url:"".concat(K,"/api/chatbot/getChatSettings?name=").concat(q,"&organizationName=").concat(o),headers:{}};Sk.request(e).then((function(e){var t,n,r;(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.chatSettings)&&""!==(null===(r=null===(n=null==e?void 0:e.data)||void 0===n?void 0:n.chatSettings)||void 0===r?void 0:r.chatInitialMessage)&&be(!0)})).catch((function(e){console.error(e)}))},it=function(){return b(void 0,void 0,void 0,(function(){var e,t;return H(this,(function(n){e="".concat(K,"/api/chat/history?name=").concat(q,"&organizationName=").concat(o);try{t={method:"GET",params:{guestSessionId:G.current},withCredentials:!0},Sk.get(e,t).then((function(e){var t=e.data;t.length>0?(de(t),ot()):be(!0)})).catch((function(e){console.error(e)}))}catch(e){pe(!1),console.error(e)}return[2]}))}))};function lt(e){var t=null==e?void 0:e.replace(/<a [^>]*>.*?<\/a>/g,(function(e){return null==e?void 0:e.replace(/\*/g,"&ast;")}));return t}var st=function(e,t,n,r,a,o){var c,i,l,s,h,d,u,m,p,v,f,z,g,y,E,b,H,C;console.log("userInput: ",a);var L={role:"assistant",content:"",id:N8()};if(null===(s=null===(l=null===(i=null===(c=null==e?void 0:e.chatStream)||void 0===c?void 0:c.continueChatResult)||void 0===i?void 0:i.message)||void 0===l?void 0:l.content)||void 0===s?void 0:s.includes("WaitMessage: "))pe(!1),fe(!0),L.content=function(e){var t="WaitMessage: ",n=e.indexOf(t);if(-1!==n){var r=e.substring(n+13);return null==r?void 0:r.replaceAll("WaitMessage: ","")}return""}((null===(u=null===(d=null===(h=null==e?void 0:e.chatStream)||void 0===h?void 0:h.continueChatResult)||void 0===d?void 0:d.message)||void 0===u?void 0:u.content)+"\n\n"),de(V(V([],he,!0),[{role:"user",content:a,time:r,isFirstQuestionSent:o||!1,id:(null===(p=null===(m=null==e?void 0:e.chatStream)||void 0===m?void 0:m.continueChatResult)||void 0===p?void 0:p.requestId)||"",reply:""},L],!1));else{pe(!1),fe(!1),L.content=null===(g=lt(null===(z=null===(f=null===(v=null==e?void 0:e.chatStream)||void 0===v?void 0:v.continueChatResult)||void 0===f?void 0:f.message)||void 0===z?void 0:z.content))||void 0===g?void 0:g.replaceAll("WaitMessage: ","");var w=function(e,t,n){var r,a,o,c,i,l,s,h,d,u,m,p,v,f,z,g,y,E,b,H,C,L,w,k,x,S,T,O,A,R,N,_,D,P,F,I,B,j,U,W,$,q,G,Y,K,X,Q,J,Z,ee,te,ne,re,ae,oe,ce,ie,le,se,he,de,ue,me,pe,ve,fe,ze,ge,ye,Me,Ee,be,He,Ve,Ce,Le,we,ke,xe,Se,Te,Oe,Ae,Re,Ne,_e,De,Pe,Fe,Ie,Be,je,Ue,We,$e,qe,Ge,Ye,Ke,Xe,Qe,Je,Ze,et,tt,nt,rt,at,ot,ct,it,st,ht,dt,ut,mt,pt,vt,ft,zt,gt,yt,Mt,Et,bt,Ht,Vt,Ct,Lt,wt,kt,xt,St,Tt,Ot,At,Rt,Nt,_t,Dt,Pt,Ft,It,Bt,jt,Ut,Wt,$t,qt,Gt,Yt,Kt,Xt,Qt,Jt,Zt,en,tn,nn,rn,an,on,cn,ln,sn,hn,dn,un,mn,pn;console.log("event",e,Object.keys(e)),console.log("content: ",null==e?void 0:e.data);var vn={role:"assistant",content:"",id:N8()};if(!1===(null===(o=null===(a=null===(r=null==e?void 0:e.data)||void 0===r?void 0:r.chatStream)||void 0===a?void 0:a.continueChatResult)||void 0===o?void 0:o.thinking_break)&&!0===(null===(l=null===(i=null===(c=null==e?void 0:e.data)||void 0===c?void 0:c.chatStream)||void 0===i?void 0:i.continueChatResult)||void 0===l?void 0:l.is_orchestrator)&&!1===(null===(d=null===(h=null===(s=null==e?void 0:e.data)||void 0===s?void 0:s.chatStream)||void 0===h?void 0:h.continueChatResult)||void 0===d?void 0:d.isEnd)&&(vn.content=null===(f=lt(null===(v=null===(p=null===(m=null===(u=null==e?void 0:e.data)||void 0===u?void 0:u.chatStream)||void 0===m?void 0:m.continueChatResult)||void 0===p?void 0:p.message)||void 0===v?void 0:v.content))||void 0===f?void 0:f.replaceAll("WaitMessage: ","")),!0===(null===(y=null===(g=null===(z=null==e?void 0:e.data)||void 0===z?void 0:z.chatStream)||void 0===g?void 0:g.continueChatResult)||void 0===y?void 0:y.thinking_break)&&!0===(null===(H=null===(b=null===(E=null==e?void 0:e.data)||void 0===E?void 0:E.chatStream)||void 0===b?void 0:b.continueChatResult)||void 0===H?void 0:H.is_orchestrator)&&!1===(null===(w=null===(L=null===(C=null==e?void 0:e.data)||void 0===C?void 0:C.chatStream)||void 0===L?void 0:L.continueChatResult)||void 0===w?void 0:w.isEnd)&&(vn.content="",t.push({responsedata:null===(T=null===(S=null===(x=null===(k=null==e?void 0:e.data)||void 0===k?void 0:k.chatStream)||void 0===x?void 0:x.continueChatResult)||void 0===S?void 0:S.message)||void 0===T?void 0:T.content,responseFrom:null===(R=null===(A=null===(O=null==e?void 0:e.data)||void 0===O?void 0:O.chatStream)||void 0===A?void 0:A.continueChatResult)||void 0===R?void 0:R.responded_by,header_message:null===(D=null===(_=null===(N=null==e?void 0:e.data)||void 0===N?void 0:N.chatStream)||void 0===_?void 0:_.continueChatResult)||void 0===D?void 0:D.header_message,finalResponseStatus:!1,explainability_id:null!==(B=null===(I=null===(F=null===(P=null==e?void 0:e.data)||void 0===P?void 0:P.chatStream)||void 0===F?void 0:F.continueChatResult)||void 0===I?void 0:I.explainability_id)&&void 0!==B?B:"",isParallelToolResponse:!1})),!1===(null===(W=null===(U=null===(j=null==e?void 0:e.data)||void 0===j?void 0:j.chatStream)||void 0===U?void 0:U.continueChatResult)||void 0===W?void 0:W.thinking_break)&&!0===(null===(G=null===(q=null===($=null==e?void 0:e.data)||void 0===$?void 0:$.chatStream)||void 0===q?void 0:q.continueChatResult)||void 0===G?void 0:G.is_orchestrator)&&!0===(null===(X=null===(K=null===(Y=null==e?void 0:e.data)||void 0===Y?void 0:Y.chatStream)||void 0===K?void 0:K.continueChatResult)||void 0===X?void 0:X.isEnd)&&(vn.content=null===(te=lt(null===(ee=null===(Z=null===(J=null===(Q=null==e?void 0:e.data)||void 0===Q?void 0:Q.chatStream)||void 0===J?void 0:J.continueChatResult)||void 0===Z?void 0:Z.message)||void 0===ee?void 0:ee.content))||void 0===te?void 0:te.replaceAll("WaitMessage: ","")),!1===(null===(ae=null===(re=null===(ne=null==e?void 0:e.data)||void 0===ne?void 0:ne.chatStream)||void 0===re?void 0:re.continueChatResult)||void 0===ae?void 0:ae.thinking_break)&&!1===(null===(ie=null===(ce=null===(oe=null==e?void 0:e.data)||void 0===oe?void 0:oe.chatStream)||void 0===ce?void 0:ce.continueChatResult)||void 0===ie?void 0:ie.is_orchestrator)&&!1===(null===(he=null===(se=null===(le=null==e?void 0:e.data)||void 0===le?void 0:le.chatStream)||void 0===se?void 0:se.continueChatResult)||void 0===he?void 0:he.isEnd)){if((gn=null===(ue=null===(de=null==e?void 0:e.data)||void 0===de?void 0:de.chatStream)||void 0===ue?void 0:ue.continueChatResult).explainability_id&&gn.responded_by){var fn=gn.explainability_id,zn=gn.responded_by;n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})}n.has(null===(pe=null===(me=null==e?void 0:e.data)||void 0===me?void 0:me.chatStream)||void 0===pe?void 0:pe.continueChatResult.explainability_id)?t[Hn=null==(yn=n.get(null===(ze=null===(fe=null===(ve=null==e?void 0:e.data)||void 0===ve?void 0:ve.chatStream)||void 0===fe?void 0:fe.continueChatResult)||void 0===ze?void 0:ze.explainability_id))?void 0:yn.index]={responsedata:null===(Ee=null===(Me=null===(ye=null===(ge=null==e?void 0:e.data)||void 0===ge?void 0:ge.chatStream)||void 0===ye?void 0:ye.continueChatResult)||void 0===Me?void 0:Me.message)||void 0===Ee?void 0:Ee.content,responseFrom:null===(Ve=null===(He=null===(be=null==e?void 0:e.data)||void 0===be?void 0:be.chatStream)||void 0===He?void 0:He.continueChatResult)||void 0===Ve?void 0:Ve.responded_by,header_message:null===(we=null===(Le=null===(Ce=null==e?void 0:e.data)||void 0===Ce?void 0:Ce.chatStream)||void 0===Le?void 0:Le.continueChatResult)||void 0===we?void 0:we.header_message,finalResponseStatus:!0,explainability_id:null!==(Te=null===(Se=null===(xe=null===(ke=null==e?void 0:e.data)||void 0===ke?void 0:ke.chatStream)||void 0===xe?void 0:xe.continueChatResult)||void 0===Se?void 0:Se.explainability_id)&&void 0!==Te?Te:"",isParallelToolResponse:!0}:t=V(V([],t,!0),[{responsedata:null===(Ne=null===(Re=null===(Ae=null===(Oe=null==e?void 0:e.data)||void 0===Oe?void 0:Oe.chatStream)||void 0===Ae?void 0:Ae.continueChatResult)||void 0===Re?void 0:Re.message)||void 0===Ne?void 0:Ne.content,responseFrom:null===(Pe=null===(De=null===(_e=null==e?void 0:e.data)||void 0===_e?void 0:_e.chatStream)||void 0===De?void 0:De.continueChatResult)||void 0===Pe?void 0:Pe.responded_by,header_message:null===(Be=null===(Ie=null===(Fe=null==e?void 0:e.data)||void 0===Fe?void 0:Fe.chatStream)||void 0===Ie?void 0:Ie.continueChatResult)||void 0===Be?void 0:Be.header_message,finalResponseStatus:!0,explainability_id:null!==($e=null===(We=null===(Ue=null===(je=null==e?void 0:e.data)||void 0===je?void 0:je.chatStream)||void 0===Ue?void 0:Ue.continueChatResult)||void 0===We?void 0:We.explainability_id)&&void 0!==$e?$e:"",isParallelToolResponse:!1}],!1)}if(!0===(null===(Ye=null===(Ge=null===(qe=null==e?void 0:e.data)||void 0===qe?void 0:qe.chatStream)||void 0===Ge?void 0:Ge.continueChatResult)||void 0===Ye?void 0:Ye.thinking_break)&&!1===(null===(Qe=null===(Xe=null===(Ke=null==e?void 0:e.data)||void 0===Ke?void 0:Ke.chatStream)||void 0===Xe?void 0:Xe.continueChatResult)||void 0===Qe?void 0:Qe.is_orchestrator)&&!1===(null===(et=null===(Ze=null===(Je=null==e?void 0:e.data)||void 0===Je?void 0:Je.chatStream)||void 0===Ze?void 0:Ze.continueChatResult)||void 0===et?void 0:et.isEnd)){var gn,yn;(gn=null===(nt=null===(tt=null==e?void 0:e.data)||void 0===tt?void 0:tt.chatStream)||void 0===nt?void 0:nt.continueChatResult).explainability_id&&gn.responded_by&&(fn=gn.explainability_id,zn=gn.responded_by,n.has(fn)||n.set(fn,{responded_by:zn,index:t.length})),n.has(null===(ot=null===(at=null===(rt=null==e?void 0:e.data)||void 0===rt?void 0:rt.chatStream)||void 0===at?void 0:at.continueChatResult)||void 0===ot?void 0:ot.explainability_id)?t[Hn=null==(yn=n.get(null===(st=null===(it=null===(ct=null==e?void 0:e.data)||void 0===ct?void 0:ct.chatStream)||void 0===it?void 0:it.continueChatResult)||void 0===st?void 0:st.explainability_id))?void 0:yn.index]={responsedata:null===(mt=null===(ut=null===(dt=null===(ht=null==e?void 0:e.data)||void 0===ht?void 0:ht.chatStream)||void 0===dt?void 0:dt.continueChatResult)||void 0===ut?void 0:ut.message)||void 0===mt?void 0:mt.content,responseFrom:null===(ft=null===(vt=null===(pt=null==e?void 0:e.data)||void 0===pt?void 0:pt.chatStream)||void 0===vt?void 0:vt.continueChatResult)||void 0===ft?void 0:ft.responded_by,header_message:null===(yt=null===(gt=null===(zt=null==e?void 0:e.data)||void 0===zt?void 0:zt.chatStream)||void 0===gt?void 0:gt.continueChatResult)||void 0===yt?void 0:yt.header_message,finalResponseStatus:!1,explainability_id:null!==(Ht=null===(bt=null===(Et=null===(Mt=null==e?void 0:e.data)||void 0===Mt?void 0:Mt.chatStream)||void 0===Et?void 0:Et.continueChatResult)||void 0===bt?void 0:bt.explainability_id)&&void 0!==Ht?Ht:"",isParallelToolResponse:!0}:t.push({responsedata:null===(wt=null===(Lt=null===(Ct=null===(Vt=null==e?void 0:e.data)||void 0===Vt?void 0:Vt.chatStream)||void 0===Ct?void 0:Ct.continueChatResult)||void 0===Lt?void 0:Lt.message)||void 0===wt?void 0:wt.content,responseFrom:null===(St=null===(xt=null===(kt=null==e?void 0:e.data)||void 0===kt?void 0:kt.chatStream)||void 0===xt?void 0:xt.continueChatResult)||void 0===St?void 0:St.responded_by,header_message:null===(At=null===(Ot=null===(Tt=null==e?void 0:e.data)||void 0===Tt?void 0:Tt.chatStream)||void 0===Ot?void 0:Ot.continueChatResult)||void 0===At?void 0:At.header_message,finalResponseStatus:!1,explainability_id:null!==(Dt=null===(_t=null===(Nt=null===(Rt=null==e?void 0:e.data)||void 0===Rt?void 0:Rt.chatStream)||void 0===Nt?void 0:Nt.continueChatResult)||void 0===_t?void 0:_t.explainability_id)&&void 0!==Dt?Dt:"",isParallelToolResponse:!1})}var Mn=null===(Bt=null===(It=null===(Ft=null===(Pt=null==e?void 0:e.data)||void 0===Pt?void 0:Pt.chatStream)||void 0===Ft?void 0:Ft.continueChatResult)||void 0===It?void 0:It.message)||void 0===Bt?void 0:Bt.annotations,En=(null===($t=null===(Wt=null===(Ut=null===(jt=null==e?void 0:e.data)||void 0===jt?void 0:jt.chatStream)||void 0===Ut?void 0:Ut.continueChatResult)||void 0===Wt?void 0:Wt.message)||void 0===$t?void 0:$t.userFeedbackId)||"",bn={role:"assistant",content:vn.content,orchestratorAndAgentsMessages:t,time:new Date,requestId:null!==(Kt=null===(Yt=null===(Gt=null===(qt=null==e?void 0:e.data)||void 0===qt?void 0:qt.chatStream)||void 0===Gt?void 0:Gt.continueChatResult)||void 0===Yt?void 0:Yt.requestId)&&void 0!==Kt?Kt:"",citations:null===(Zt=null===(Jt=null===(Qt=null===(Xt=null==e?void 0:e.data)||void 0===Xt?void 0:Xt.chatStream)||void 0===Qt?void 0:Qt.continueChatResult)||void 0===Jt?void 0:Jt.message)||void 0===Zt?void 0:Zt.citations,guides_utilized:null!==(an=null===(rn=null===(nn=null===(tn=null===(en=null==e?void 0:e.data)||void 0===en?void 0:en.chatStream)||void 0===tn?void 0:tn.continueChatResult)||void 0===nn?void 0:nn.message)||void 0===rn?void 0:rn.guides_utilized)&&void 0!==an?an:[],annotations:Mn,resourceId:null===(ln=null===(cn=null===(on=null==e?void 0:e.data)||void 0===on?void 0:on.chatStream)||void 0===cn?void 0:cn.continueChatResult)||void 0===ln?void 0:ln.resourceId,userFeedbackId:En,citationDisplayType:null!==(mn=null===(un=null===(dn=null===(hn=null===(sn=null==e?void 0:e.data)||void 0===sn?void 0:sn.chatStream)||void 0===hn?void 0:hn.continueChatResult)||void 0===dn?void 0:dn.message)||void 0===un?void 0:un.citationDisplayType)&&void 0!==mn?mn:""};if(Mn)for(var Hn=0;Hn<(null==Mn?void 0:Mn.length);Hn++){var Vn=Mn[Hn];bn=M(M({},bn),{content:null===(pn=null==bn?void 0:bn.content)||void 0===pn?void 0:pn.replace(null==Vn?void 0:Vn.text,(null==Vn?void 0:Vn.text)+"<sup>".concat(Hn,"</sup>"))})}return bn}({data:e},n,t);console.log("assistantObject",w),de(V(V([],he,!0),[{role:"user",content:a||"",time:r,isFirstQuestionSent:o||!1,requestId:null!==(b=null===(E=null===(y=null==e?void 0:e.chatStream)||void 0===y?void 0:y.continueChatResult)||void 0===E?void 0:E.requestId)&&void 0!==b?b:""},w],!1)),ye(null===(C=null===(H=null==e?void 0:e.chatStream)||void 0===H?void 0:H.continueChatResult)||void 0===C?void 0:C.isEnd)}},ht=function(e,t,n){var r,a,c,i,l,s,h,d=(null==n?void 0:n.trim())||(null==ae?void 0:ae.trim())||"";if(!("Enter"!==e.key||e.shiftKey||""===(null==n?void 0:n.trim())&&""===(null==ae?void 0:ae.trim())||xe)){Se(!0);var u=new Date;de(V(V([],he.map((function(e,t){var n;return M(M({},e),{content:null===(n=lt(e.content))||void 0===n?void 0:n.replace("WaitMessage: ","")})})),!0),[{role:"user",content:d,time:u,isFirstQuestionSent:!1}],!1));var p=new Map,v=[];ne(!1);var z={WEBSOCKET_URL:f,organizationName:o,chatAssistantName:q,selectedAIModel:"gpt-4",replyMessage:"",userName:"Guest User",userEmailId:"guestUser@example.com",userId:"Guest User",query:(null==n?void 0:n.trim())||(null==ae?void 0:ae.trim())||"",requestId:"requestId-".concat(N8()),customPrompt:"",enableForBackend:!1,guestSessionId:G.current,chatPreviewId:Y.current,customMetaData:M(M({},m),{whenToApply:null===(a=null===(r=null==m?void 0:m.whenToApply)||void 0===r?void 0:r.split(" OR "))||void 0===a?void 0:a.filter((function(e){return""!==e})),whenNotToApply:null===(i=null===(c=null==m?void 0:m.whenNotToApply)||void 0===c?void 0:c.split(" OR "))||void 0===i?void 0:i.filter((function(e){return""!==e})),isFirstQuestion:0===he.length,validation:null!=x?x:null,conflicting_learnings:null!==(l=null==T?void 0:T.conflicting_learnings)&&void 0!==l?l:"",similar_learnings:null!==(s=null==T?void 0:T.similar_learnings)&&void 0!==s?s:""}),customMetaDataDebug:{conflicting_learnings_keys:(null==T?void 0:T.conflicting_learnings)?Object.keys(T.conflicting_learnings):[],similar_learnings_keys:(null==T?void 0:T.similar_learnings)?Object.keys(T.similar_learnings):[],conflicting_count:(null==T?void 0:T.conflicting_learnings)?Object.keys(T.conflicting_learnings).length:0,similar_count:(null==T?void 0:T.similar_learnings)?Object.keys(T.similar_learnings).length:0},aiModel:"",onStreamEvent:function(e){return st(e,p,v,u,d,t)},onStreamEnd:function(e){Se(!1)},onError:function(e){return console.error("Stream error:",e)}};if(""!==(null==ae?void 0:ae.trim())||(null==n?void 0:n.trim())){pe(!0),null===(h=Q.current)||void 0===h||h.blur(),oe(""),ot();for(var g="Thanks for sharing your thoughts. I'm putting together the most helpful suggestions now, so we can make sure this really fits your needs.".split(" "),y="",E=function(e){setTimeout((function(){y+=g[e]+" ",we(y.trim())}),25*e)},b=0;b<g.length;b++)E(b);S8.startChatStream(z)}}},dt=i(new Set);return s((function(){if(P&&!xe){if(dt.current.has(P))return void console.log("[ChatComponent] ⚠️ Duplicate merge trigger ignored:",P);console.log("[ChatComponent] 🔴 MERGE TRIGGER RECEIVED:",P),dt.current.add(P);var e=null,t="A";if(null==T?void 0:T.similar_learnings){var n=Object.values(T.similar_learnings),r=n.findIndex((function(e){return(null==e?void 0:e.id)===P}));-1!==r&&(e=n[r],t=String.fromCharCode(65+r))}if(e){var a="Merge Similar Learning ".concat(t," with current learning");console.log("[ChatComponent] ✅ Sending merge message to chat:",a),ht(new KeyboardEvent("keydown",{key:"Enter"}),!1,a),console.log("[ChatComponent] Message sent successfully")}else console.log("[ChatComponent] ❌ Learning not found for ID:",P);F&&(F(null),console.log("[ChatComponent] Trigger cleared"))}else P&&xe&&console.log("[ChatComponent] ⚠️ Merge trigger received but streaming in progress:",P)}),[P,xe,F]),h((function(){return{img:function(e){e.node;var t=E(e,["node"]);return n("img",M({},t,{style:{height:"100%",width:"100%",objectFit:"contain"},alt:(null==t?void 0:t.alt)||"",className:"w-full sm:max-w-lg md:max-w-2xl lg:max-w-4xl mx-auto"}))},p:function(e){e.node;var t=E(e,["node"]);return n("p",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"block",fontSize:"1rem",lineHeight:"1.625rem",marginBottom:"1rem",marginTop:"10px"}},{children:null==t?void 0:t.children}))},code:function(e){e.node;var t=E(e,["node"]);return n("span",M({},t,{style:{maxWidth:"100%",wordWrap:"break-word",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"normal",overflow:"hidden",display:"inline-flex",fontSize:"1rem",lineHeight:"1.625rem"}},{children:null==t?void 0:t.children}))},ol:function(e){e.node;var t=E(e,["node"]);return n("ol",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==t?void 0:t.children}))},ul:function(e){e.node;var t=E(e,["node"]);return n("ul",M({},t,{style:{display:"flex",flexDirection:"column",gap:"1rem",listStyle:"decimal",paddingLeft:"2.5rem"}},{children:null==t?void 0:t.children}))},wta:function(e){e.node;var t=E(e,["node"]);t.key||t["data-key"];var r=t.label||t.children||"Unknown label";return n(V7,{label:r,onToggle:function(e,t){!function(e,t){var n=Array.isArray(e)?e[0]:e;null==Z||Z.length,ne(!0),ee((function(e){return t?e.includes(n)?e:V(V([],e,!0),[n],!1):e.filter((function(e){return e!==n}))}))}(e,t)}})}}}),[]),e("div",M({className:j8,style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#fbfaff",border:"1px solid #d1d5db",overflow:"hidden"}},{children:[e("div",M({style:{width:"100%",height:"100%",backgroundColor:"#fbfaff",maxWidth:"100%",overflow:"hidden"}},{children:[n("div",M({ref:Ke},{children:n(b7,{resetChatHistory:function(){var e="".concat(K,"/api/chat/resetHistory?name=").concat(q,"&organizationName=").concat(o);S(null),O(null);try{var t={method:"GET",params:{guestSessionId:G.current},withCredentials:!0};Sk.get(e,t).then((function(){y(""),L(""),z(!0),ne(!1),ee([]),Ve(""),Be(new Set),$e.current="",Ge.current.clear(),dt.current.clear(),F&&F(null),Y.current="".concat(N8()),v(!1),de([]),be(!0),I?(console.log("[ChatComponent] 🔄 Calling onResetLearningData callback"),I()):console.log("[ChatComponent] ❌ onResetLearningData callback not available"),p((function(e){return M(M({},e),{modification:"",tooltip:"",whenToApply:"",whenNotToApply:"",isTooltipEnabled:!1,isModificationEnabled:!0})}))})).catch((function(e){console.error(e)}))}catch(e){pe(!1),console.error(e)}},isStreamEnd:ge})})),e("div",M({style:{width:"100%",height:Qe,maxHeight:Qe,overflowY:"auto",backgroundColor:"#fbfaff"},ref:X},{children:[n("div",M({className:"welcome-message",style:{alignItems:"flex-start",paddingLeft:"0.5rem",paddingTop:"1rem",maxWidth:"70%",fontSize:"1rem",lineHeight:"1.75rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333",fontWeight:"700",textAlign:"left"}},{children:n("span",{children:"I'm here to help fine-tune your learning so it works as accurately as it should."})})),e("div",M({style:{display:"flex",flexDirection:"row",fontFamily:"inherit",padding:"16px 10px 0px 16px",maxWidth:"80%"}},{children:[n("div",M({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.3rem"}},{children:e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),n("div",M({style:{display:"flex",flexDirection:"column",fontWeight:400,color:"#000"}},{children:n("div",M({style:{display:"inline-flex",flexDirection:"column",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:n("span",{children:n(vM,M({components:{p:function(e){e.node;var t=E(e,["node"]);return n("p",M({},t,{style:{margin:0}},{children:null==t?void 0:t.children}))}}},{children:ie}))})}))}))]})),he.length?he.map((function(t,r){return e("div",M({style:{display:"flex",padding:"0.5rem 1rem",maxWidth:"100%"}},{children:["assistant"==(null==t?void 0:t.role)&&n("div",M({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.5rem",marginRight:"1rem"}},{children:e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),e("div",M({style:{width:"100%"}},{children:["assistant"===t.role&&t.orchestratorAndAgentsMessages&&t.orchestratorAndAgentsMessages.length>0&&n(I8,{orchestratorAndAgentsMessages:null==t?void 0:t.orchestratorAndAgentsMessages,isStreamEnd:ge,isCurrentMessage:r===he.length-1,ThinkingBulbIconComponent:g}),"assistant"===(null==t?void 0:t.role)?n(f7,{index:r,content:null==t?void 0:t.content,messages:he,handleStream:ht}):n("span",{}),n("div",M({style:{display:"flex",justifyContent:"flex-end"}},{children:"user"===t.role?n("div",M({style:{backgroundColor:"#8694A10D",padding:"0 1rem",borderRadius:"8px",maxWidth:"80%"}},{children:n(f7,{index:r,content:null==t?void 0:t.content,messages:he,handleStream:ht,scrollToBottom:ot})})):n("span",{})}))]}))]}))})):Ee&&n(t,{}),me&&e("div",M({style:{display:"flex",padding:"16px 16px 0px 16px"}},{children:[n("div",M({style:{maxHeight:"32px",maxWidth:"32px",marginTop:"0.2rem"}},{children:e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]}))})),n("div",M({style:{display:"inline-flex",alignItems:"flex-start",paddingLeft:"1rem",paddingRight:"1rem",paddingBottom:"1rem",width:"100%",maxWidth:"100%",fontSize:"1rem",lineHeight:"1.75rem",marginBottom:"1rem",borderRadius:"0.5rem",overflowWrap:"break-word",wordBreak:"break-word",whiteSpace:"pre-wrap",color:"#333"}},{children:n("span",{children:Le})}))]}))]}))]})),e("div",M({style:{width:"95%",height:"content-fit",backgroundColor:"#fbfaff",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"end",position:"relative"}},{children:[n("div",M({style:{visibility:Ne?"visible":"hidden",position:"absolute",top:"-3rem",zIndex:0,pointerEvents:"none"}},{children:n("button",M({onClick:ot,style:{borderRadius:"9999px",padding:0,backgroundColor:"#fff",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",border:"1px solid #d1d5db",pointerEvents:"auto",cursor:"pointer",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1,height:"2.25rem",width:"2.25rem",margin:"0.3rem"}},{children:n("svg",M({fill:"#000000",width:"16px",height:"16px",viewBox:"0 0 24 24",id:"down","data-name":"Flat Color",xmlns:"http://www.w3.org/2000/svg"},{children:n("path",{id:"primary",d:"M19.71,13.29a1,1,0,0,0-1.42,0L13,18.59V3a1,1,0,0,0-2,0V18.59l-5.29-5.3a1,1,0,0,0-1.42,1.42l7,7a1,1,0,0,0,1.42,0l7-7A1,1,0,0,0,19.71,13.29Z"})}))}))})),n("div",M({style:{width:"100%",backgroundColor:"#fff",display:"flex",alignItems:"end",gap:"0.5rem",border:"1px solid #E5E7EB",borderRadius:"8px"}},{children:e("div",M({style:{width:"100%",display:"flex"}},{children:[n("textarea",{ref:Q,placeholder:"Tell me more about this learning...",value:ae||"",onChange:function(e){return oe(e.target.value)},onFocus:function(){return Ae(!0)},onBlur:function(){return Ae(!1)},onKeyDown:function(e){return ht(e)},style:{flexGrow:1,padding:"0.5rem",borderRadius:"0.5rem",border:"none",fontSize:"1rem",lineHeight:"1.5rem",resize:"none",backgroundColor:"#fff",color:"inherit",minHeight:Oe?"120px":"50px",height:Oe?"120px":"50px",maxHeight:"120px",overflowY:"auto",fontFamily:"inherit",outline:"none",transition:"min-height 0.3s ease, background-color 0.3s ease",boxSizing:"border-box"}}),e("span",M({style:{display:"flex",flexDirection:"column",justifyContent:"end",alignItems:"end"}},{children:[" ",n("button",M({onClick:function(e){ht(new KeyboardEvent("keydown",{key:"Enter"}))},disabled:Ye,style:{padding:"0.5rem 0.75rem",borderRadius:"0.375rem",border:"none",backgroundColor:"white",color:Ye?"#d1d5db":"#5928ed",fontWeight:"bold",fontSize:"1rem",cursor:Ye?"not-allowed":"pointer",transition:"background-color 0.3s, color 0.3s",height:"50px"}},{children:n(E7,{})}))]}))]}))}))]})),e("div",M({style:{width:"95%",display:"flex",gap:"0.25rem",flexDirection:"row"}},{children:[n(LJ,M({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n("span",M({style:{width:"50%"}},{children:n(u7,{amplitude:1,variant:"speaker",isActive:!1,onClick:function(){return null},disabled:!1})}))})),n(LJ,M({title:"Coming soon",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n("span",M({style:{width:"50%"}},{children:n(u7,{amplitude:1,variant:"microphone",isActive:!1,onClick:function(){return null},disabled:!1})}))}))]}))]}))},L7={},w7={exports:{}},k7={exports:{}};function x7(){return y7||(y7=1,function(e){function t(n){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports}(k7)),k7.exports}function S7(){return M7||(M7=1,function(e){var t=x7().default;function n(r,a){if("function"==typeof WeakMap)var o=new WeakMap,c=new WeakMap;return(e.exports=n=function(e,n){if(!n&&e&&e.__esModule)return e;var r,a,i={__proto__:null,default:e};if(null===e||"object"!=t(e)&&"function"!=typeof e)return i;if(r=n?c:o){if(r.has(e))return r.get(e);r.set(e,i)}for(var l in e)"default"!==l&&{}.hasOwnProperty.call(e,l)&&((a=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,l))&&(a.get||a.set)?r(i,l,a):i[l]=e[l]);return i},e.exports.__esModule=!0,e.exports.default=e.exports)(r,a)}e.exports=n,e.exports.__esModule=!0,e.exports.default=e.exports}(w7)),w7.exports}var T7,O7,A7={},R7=Te(rl);function N7(){return T7||(T7=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.createSvgIcon}});var t=R7}(A7)),A7}var _7,D7=function(){if(O7)return L7;O7=1;var e=p_(),t=S7();Object.defineProperty(L7,"__esModule",{value:!0}),L7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"}),"Delete");return L7.default=r,L7}(),P7=Se(D7),F7={};var I7,B7=function(){if(_7)return F7;_7=1;var e=p_(),t=S7();Object.defineProperty(F7,"__esModule",{value:!0}),F7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"}),"Lock");return F7.default=r,F7}(),j7=Se(B7),U7={};var W7,$7=function(){if(I7)return U7;I7=1;var e=p_(),t=S7();Object.defineProperty(U7,"__esModule",{value:!0}),U7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 00-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"}),"Edit");return U7.default=r,U7}(),q7=Se($7),G7={};var Y7,K7=function(){if(W7)return G7;W7=1;var e=p_(),t=S7();Object.defineProperty(G7,"__esModule",{value:!0}),G7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M7.41 8.59L12 13.17l4.59-4.58L18 10l-6 6-6-6 1.41-1.41z"}),"KeyboardArrowDown");return G7.default=r,G7}(),X7=Se(K7),Q7=function(t){var r,a,o=t.conflictingConditions,i=function(e){var t={};return e.forEach((function(e){var n="".concat(e.conflictType,"_").concat(e.reason);t[n]||(t[n]=[]),t[n].push(e)})),t},l=(null==o?void 0:o.filter((function(e){return e.condition_wta||e.condition_wnta})))||[],s=(r=i(l),a=[],Object.values(r).forEach((function(e){e.length>0&&a.push(e[0])})),a),h=c((function(){return s.map((function(e,t){return t}))})),d=h[0],u=h[1];return l&&0!==l.length?e(Yj,M({sx:{backgroundColor:"#FEF2F2",border:"1px solid #FCA5A5",boxShadow:"0 1px 4px rgba(0, 0, 0, 0.04)",padding:3,borderRadius:2,mt:3,mb:3,fontFamily:"Plus Jakarta Sans"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontSize:"1.15rem",fontWeight:700,color:"#B91C1C",fontFamily:"Plus Jakarta Sans"}},{children:"Conflicting Conditions Found"})),n(LJ,M({title:"The current learning contains conditions that conflicting. Please review and adjust them to ensure consistency.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(Yj,M({sx:{maxHeight:360,overflowY:"auto",pr:1.5}},{children:s.map((function(t,r){var a=[],o=function(e){return e.map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n\n")},c=[],s=[],h=i(l)["".concat(t.conflictType,"_").concat(t.reason)]||[];h.length>1?h.forEach((function(e){e.condition_wta&&c.push(e.condition_wta),e.condition_wnta&&s.push(e.condition_wnta)})):(t.condition_wta&&c.push(t.condition_wta),t.condition_wnta&&s.push(t.condition_wnta)),c.length>0&&a.push({label:"When To Apply",value:o(c)}),s.length>0&&a.push({label:"When Not To Apply",value:o(s)});var m=d.includes(r);return e(nP,M({expanded:m,onChange:function(){return function(e){u((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(r)},disableGutters:!0,sx:{mb:2,border:"1px solid #FCA5A5",fontFamily:"Plus Jakarta Sans",borderRadius:2,"&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(X7,{style:{color:"#991B1B",transition:"transform 0.3s ease-in-out"}}),"aria-controls":"panel-".concat(r,"-content"),id:"panel-".concat(r,"-header"),sx:{fontFamily:"Plus Jakarta Sans",color:"#991B1B",fontWeight:600,px:2,py:1.5}},{children:"Conflict in current conditions"})),e(hP,M({sx:{px:2,pb:2}},{children:[n(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:2===a.length?"row":"column"},gap:2,mb:2}},{children:a.map((function(t,r){return e(Yj,M({sx:{flex:2===a.length?1:"none",border:"1px solid #FCA5A5",borderRadius:2,padding:2,backgroundColor:"#FFFFFF"}},{children:[n(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:t.label})),n(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:t.value}))]}),r)}))})),e(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#1F2937",lineHeight:1.6,fontFamily:"Plus Jakarta Sans"}},{children:[n("strong",{children:"Reason:"})," ",t.reason]}))]}))]}),r)}))}))]})):null},J7={};var Z7,eee=function(){if(Y7)return J7;Y7=1;var e=p_(),t=S7();Object.defineProperty(J7,"__esModule",{value:!0}),J7.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"}),"HelpOutline");return J7.default=r,J7}(),tee=Se(eee),nee={};var ree=function(){if(Z7)return nee;Z7=1;var e=p_(),t=S7();Object.defineProperty(nee,"__esModule",{value:!0}),nee.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M17 20.41L18.41 19 15 15.59 13.59 17 17 20.41zM7.5 8H11v5.59L5.59 19 7 20.41l6-6V8h3.5L12 3.5 7.5 8z"}),"MergeType");return nee.default=r,nee}(),aee=Se(ree);function oee(e){return e?e.replace(/[^a-zA-Z\s]/g,"").replace(/\s+/g," ").trim():""}function cee(e){var t={topic:"",modification:"",tooltip:""};if(!(null==e?void 0:e.trim()))return t;var n=e.replace(/\*/g,"").replace(/\s+/g," ").trim();console.log("Clean variant:",n);var r=/<(sup|tooltip|info)>[\s*]*([^<]*?)[\s*]*<\/\1>/i,a=n.match(r),o=a?a[2].replace(/\*/g,"").trim():"";console.log("Extracted tooltip:",o);var c=n.replace(r,"").trim();console.log("Main text after tooltip removal:",c);var i=c.match(/.*?replace\s+(.*?)(?:\s+with\s*|$)/i),l="",s="";if(i){l=i[1].trim();var h=c.match(/\s+with\s+(.*?)$/i);s=h?h[1].trim():""}else{var d=c.match(/^(.*?)(?:\s+with\s+(.*?))?$/i);d&&(l=d[1].trim(),s=d[2]?d[2].trim():"")}return l=oee(l),s=oee(s),o=oee(o),console.log("Extracted parts after cleaning:",{mainText:c,topic:l,modification:s,tooltip:o}),l&&(s||o)?(console.log("Final results:",{topic:l,modification:s,tooltip:o}),{topic:l,modification:s,tooltip:o}):(console.log("Validation failed - returning default"),t)}var iee=function(r){var a=r.conflictingConditions,o=r.baseUrl,l=r.organizationName,h=r.chatAssistantName;r.curlPayload;var d=r.onDeleted;r.onMerged;var u=r.onDeleteLearning,m=r.onMergeMessage,p=r.setSendMessageInChat,v=r.editConflictingLearningTrigger,f=r.editSimilarLearningTrigger;r.operationStatus,r.onOperationComplete;var z=r.onSetOperationStatus,g=a||[],y=g[0],E=g[1],C=y||[],L=E||[];console.log("[ConflictsDisplayDB] Component props:",{baseUrl:o,organizationName:l,chatAssistantName:h,conflictingLearningsCount:C.length,similarLearningsCount:L.length,hasOnDeletedCallback:!!d});var w=c((function(){return C.length>0?[0]:[]})),k=w[0],x=w[1],S=c((function(){return L.length>0?[0]:[]})),T=S[0],O=S[1],A=c(new Set),R=A[0],N=A[1],_=c(new Set),D=_[0],P=_[1],F=c(new Set),I=F[0],B=F[1],j=c({}),U=j[0],W=j[1],$=c({}),q=$[0],G=$[1],Y=c({}),K=Y[0],X=Y[1],Q=c({}),J=Q[0],Z=Q[1],ee=i(!0);s((function(){return function(){ee.current=!1}}),[]),s((function(){v&&"object"==typeof v&&Object.keys(v).length>0&&(console.log("Edit conflicting learning response received:",v),Object.entries(v).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,o,c,i,l,s,h;return H(this,(function(d){return n&&n.edit_actions&&n.edit_actions.action&&(console.log("Processing conflicting learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=e.join(" OR "),o=r.join(" OR "),c=cee(n.variant),i=c.topic,l=c.modification,s=c.tooltip,h=C.findIndex((function(e){return e.id===t})),-1!==h&&(C[h]=M(M({},C[h]),{feedback:M(M({},C[h].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:o})})),W((function(e){var n;return M(M({},e),((n={})[t]={topic:i,modification:l,tooltip:s,whenToApply:a,whenNotToApply:o},n))}))),[2]}))}))})),Object.keys(v).forEach((function(e){B((function(t){var n=new Set(t);return n.delete(e),n})),P((function(t){var n=new Set(t);return n.delete(e),n})),W((function(t){var n=M({},t);return delete n[e],n})),G((function(t){var n=M({},t);return delete n[e],n})),X((function(t){var n=M({},t);return delete n[e],n}))})))}),[v]),s((function(){f&&"object"==typeof f&&Object.keys(f).length>0&&(console.log("Edit similar learning response received:",f),Object.entries(f).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,o,c,i,l,s,h;return H(this,(function(d){return n&&n.edit_actions&&n.edit_actions.action&&(console.log("Processing similar learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=e.join(" OR "),o=r.join(" OR "),c=cee(n.variant),i=c.topic,l=c.modification,s=c.tooltip,h=L.findIndex((function(e){return e.id===t})),-1!==h&&(L[h]=M(M({},L[h]),{feedback:M(M({},L[h].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:o})})),W((function(e){var n;return M(M({},e),((n={})[t]={topic:i,modification:l,tooltip:s,whenToApply:a,whenNotToApply:o},n))}))),[2]}))}))})),Object.keys(f).forEach((function(e){B((function(t){var n=new Set(t);return n.delete(e),n})),P((function(t){var n=new Set(t);return n.delete(e),n})),W((function(t){var n=M({},t);return delete n[e],n})),G((function(t){var n=M({},t);return delete n[e],n})),X((function(t){var n=M({},t);return delete n[e],n}))})))}),[f]);var te=function(e,t){G((function(n){var r;return M(M({},n),((r={})[e]=t,r))}))},ne=function(e){G((function(t){var n;return M(M({},t),((n={})[e]=null,n))}))},re=function(e){X((function(t){var n;return M(M({},t),((n={})[e]=null,n))}))},ae=function(t){var r=function(e){var t=Math.min(e,1);return Math.round(100*t)}(t.score),a=function(e){return e>=80?{bg:"#10B981",text:"#f2f2f2"}:e>=50?{bg:"#F59E0B",text:"#f2f2f2"}:{bg:"#cc0000",text:"#f2f2f2"}}(r);return n(LJ,M({title:"AI Confidence Score",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.75rem",padding:"0.25rem 0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1.5,py:.5,mr:1,borderRadius:"16px",backgroundColor:a.bg,color:a.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",cursor:"default",transition:"all 0.2s ease-in-out"}},{children:[n("svg",M({width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:a.text})}))})),e(iF,M({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",color:a.text}},{children:[r,"%"]}))]}))}))},oe=function(r,a,c,i){var s,v,f,g;console.log("[ConflictsDisplayDB] Rendering ".concat(c," learning:"),{id:r.id,variant:r.feedback.variant,similarity_score:r.similarity_score,type:c});var y="conflict"===c?k.includes(a):T.includes(a),E="conflict"===c?"#991B1B":"#F87171",C="conflict"===c?"Conflicting with: ".concat(r.feedback.variant):"Similar to: ".concat(r.feedback.variant),L=!!J[r.id],w="conflict"===c?"Why it's conflicting?":"Why it's similar?",S=U[r.id],A=I.has(r.id),_=q[r.id],F=K[r.id],j=S||{whenToApply:Array.isArray(r.feedback.when_to_apply)?r.feedback.when_to_apply.join(", "):r.feedback.when_to_apply||"",whenNotToApply:Array.isArray(r.feedback.when_not_to_apply)?r.feedback.when_not_to_apply.join(", "):r.feedback.when_not_to_apply||""};return e(nP,M({expanded:y,onChange:function(){return function(e,t){"conflict"===t?x((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)})):O((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(a,c)},disableGutters:!0,sx:{mb:2,border:"2px solid #acb5c2",borderRadius:2,fontFamily:"Plus Jakarta Sans","&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(X7,{style:{color:E}}),"aria-controls":"panel-".concat(c,"-").concat(a,"-content"),id:"panel-".concat(c,"-").concat(a,"-header"),"aria-label":"".concat(i?"".concat(i,": "):"").concat(C),sx:{fontFamily:"Plus Jakarta Sans",color:E,fontWeight:600,px:2,py:1.5}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",width:"100%",justifyContent:"space-between"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[i&&e(iF,M({component:"span",sx:{fontSize:"0.9rem",fontWeight:700,color:E,mr:1,fontFamily:"Plus Jakarta Sans"}},{children:[i,"."]})),n(iF,M({sx:{fontSize:"0.95rem",fontWeight:600,color:E,fontFamily:"Plus Jakarta Sans"}},{children:C}))]})),n(ae,{score:r.similarity_score})]}))})),e(hP,M({sx:{px:2,pb:2}},{children:[e(nP,M({expanded:L,onChange:function(){return e=r.id,void Z((function(t){var n;return M(M({},t),((n={})[e]=!t[e],n))}));var e},disableGutters:!0,elevation:0,sx:{backgroundColor:"transparent",border:"1px solid #fde68a",borderRadius:2,mb:2,"&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(X7,{style:{color:"#92400e"}}),sx:{backgroundColor:"#fef3c7",borderRadius:L?"8px 8px 0 0":2,minHeight:"auto","& .MuiAccordionSummary-content":{margin:"12px 0"}}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",gap:.5}},{children:[n(iF,M({sx:{fontSize:"0.85rem",fontWeight:600,color:"#92400e",fontFamily:"Plus Jakarta Sans"}},{children:w})),n(LJ,M({title:"Click to expand for more details",arrow:!0},{children:n(tee,{style:{color:"#92400e",fontSize:"1rem",cursor:"pointer"}})}))]}))})),n(hP,M({sx:{p:1.5,backgroundColor:"#fffbeb"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#b45309",fontFamily:"Plus Jakarta Sans"}},{children:r.reason}))}))]})),S&&e(Yj,M({sx:{mb:2,p:2,border:"1px solid #991B1B",borderRadius:2}},{children:[n(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:"#991B1B",fontWeight:600,mb:1,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:"Edit Learning"})),e(Yj,M({sx:{display:"flex",gap:2,alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontFamily:"Plus Jakarta Sans"}},{children:"Replace"})),n(j2,{value:j.topic,onChange:function(e){return W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{topic:e.target.value}),n))}))},disabled:A,size:"small",sx:{flex:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans",backgroundColor:"#FFFFFF"}}}),n(iF,M({sx:{fontFamily:"Plus Jakarta Sans"}},{children:"with"})),n(j2,{value:j.modification,onChange:function(e){return W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{modification:e.target.value}),n))}))},disabled:A,size:"small",sx:{flex:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans",backgroundColor:"#FFFFFF"}}})]})),n(j2,{fullWidth:!0,size:"small",label:"Tooltip (Optional)",value:j.tooltip,onChange:function(e){return W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{tooltip:e.target.value}),n))}))},disabled:A,sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans",backgroundColor:"#FFFFFF"}}})]})),e(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:"row"},gap:2,mb:2}},{children:[e(Yj,M({sx:{flex:1,scale:S?1.02:1,border:S&&"whenToApply"===_?"1px solid #991B1B":S?"1px solid #B91C1C":"1px solid #FCA5A5",borderRadius:2,padding:2,transition:"all 0.2s ease-in-out",boxShadow:S&&"whenToApply"===_?"0 0 0 1px rgba(153, 27, 27, 0.1)":"none"}},{children:[e(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:S&&"whenToApply"===_?"#991B1B":S?"#B91C1C":"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:["When To Apply",n("span",M({style:{color:"#e4050b"}},{children:"*"}))]})),S||A?n(j2,{fullWidth:!0,multiline:!0,rows:3,value:A?Array.isArray(r.feedback.when_to_apply)?r.feedback.when_to_apply.join("\n"):r.feedback.when_to_apply||"":j.whenToApply,disabled:A,onChange:function(e){return!A&&W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{whenToApply:e.target.value}),n))}))},onFocus:function(){return!A&&te(r.id,"whenToApply")},onBlur:function(){return!A&&ne(r.id)},sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#FFFFFF",border:"1px solid #991B1B",borderRadius:1},"& .MuiOutlinedInput-notchedOutline":{border:"none"}}}):n(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:Array.isArray(r.feedback.when_to_apply)?r.feedback.when_to_apply.join("\n"):r.feedback.when_to_apply}))]})),e(Yj,M({sx:{flex:1,scale:S?1.02:1,border:S&&"whenToApply"===_?"1px solid #991B1B":S?"1px solid #B91C1C":"1px solid #FCA5A5",borderRadius:2,padding:2,transition:"all 0.2s ease-in-out",boxShadow:S&&"whenNotToApply"===_?"0 0 0 1px rgba(153, 27, 27, 0.1)":"none"}},{children:[n(iF,M({variant:"caption",sx:{fontSize:"0.9rem",color:S&&"whenNotToApply"===_?"#991B1B":S?"#B91C1C":"#6B7280",fontWeight:600,mb:.5,display:"block",fontFamily:"Plus Jakarta Sans"}},{children:"When Not To Apply"})),S||A?n(j2,{fullWidth:!0,multiline:!0,rows:3,value:A?Array.isArray(r.feedback.when_not_to_apply)?r.feedback.when_not_to_apply.join("\n"):r.feedback.when_not_to_apply||"":j.whenNotToApply,disabled:A,onChange:function(e){return!A&&W((function(t){var n;return M(M({},t),((n={})[r.id]=M(M({},t[r.id]),{whenNotToApply:e.target.value}),n))}))},onFocus:function(){return!A&&te(r.id,"whenNotToApply")},onBlur:function(){return!A&&ne(r.id)},sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif",backgroundColor:"#FFFFFF",border:"1px solid #B91C1C",borderRadius:1},"& .MuiOutlinedInput-notchedOutline":{border:"none"}}}):n(iF,M({variant:"body2",sx:{fontSize:"1rem",color:"#374151",whiteSpace:"pre-line",fontFamily:"Plus Jakarta Sans"}},{children:Array.isArray(r.feedback.when_not_to_apply)?r.feedback.when_not_to_apply.join("\n"):r.feedback.when_not_to_apply}))]}))]})),S?e(Yj,"save"===F?M({sx:{mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#6B7280",mb:1,fontFamily:"Plus Jakarta Sans",fontWeight:500,fontStyle:"italic"}},{children:"Are you sure you want to save this learning with the edited changes?"})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:1}},{children:[I.has(r.id)&&n(iF,M({variant:"body2",sx:{fontSize:"0.8rem",color:"#545454",fontFamily:"Plus Jakarta Sans",fontWeight:500,fontStyle:"italic",mr:1}},{children:"I got it, Editing your conditions..."})),n(zU,M({size:"small",variant:"contained",onClick:function(){return function(e,t,n){return b(void 0,void 0,void 0,(function(){var r,a,o,c,i,l,s,h;return H(this,(function(d){if(!(r=U[e.id]))return[2];P((function(t){return new Set(t).add(e.id)})),B((function(t){return new Set(t).add(e.id)}));try{console.log("[Edit-UI] Sending edit request to API:",e.id,r),a=e.feedback.variant.match(/<[^>]+>[^<]+<\/[^>]+>/),o=a?a[0]:"<tooltip>$1</tooltip>",c=o.match(/<([^>]+)>/),i=c?c[1]:"tooltip",l="Replace ".concat(r.topic," with ").concat(r.modification).concat(r.tooltip?" <".concat(i,">").concat(r.tooltip,"</").concat(i,">"):""),s=(null===(h=r.whenNotToApply)||void 0===h?void 0:h.trim())?"and WNTA: ".concat(r.whenNotToApply):"and remove the WNTA conditions",p("Edit ".concat(t," learning ").concat(n," variant to ").concat(l," with WTA: ").concat(r.whenToApply," ").concat(s)),ee.current&&z&&z({status:"success",message:"Processing edit request..."})}catch(t){console.error("[Edit-UI] error sending edit request:",t),ee.current&&z&&z({status:"error",message:"Error sending edit request: ".concat(t instanceof Error?t.message:"Unknown error")}),B((function(t){var n=new Set(t);return n.delete(e.id),n})),P((function(t){var n=new Set(t);return n.delete(e.id),n}))}return[2]}))}))}(r,c,i||"")},disabled:D.has(r.id)||I.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:I.has(r.id)?"#10B981":"#1565c0",textTransform:"none",color:"white",height:32,px:1.5,fontWeight:600,minWidth:I.has(r.id)?100:"auto","&:disabled":{backgroundColor:"#f3f4f6",color:"#9CA3AF",height:32}}},{children:I.has(r.id)?e(t,{children:[n(SW,{size:16,style:{color:"black",marginRight:6}}),"Saving..."]}):D.has(r.id)?n(SW,{size:16,style:{color:"white"}}):"Yes"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return re(r.id)},disabled:D.has(r.id)||I.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"No"}))]}))]}):M({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:2,mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#6B7280",fontFamily:"Plus Jakarta Sans",fontWeight:500,fontStyle:"italic"}},{children:"You are now editing this learning. Changes are applied upon saving."})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",gap:1}},{children:[n(zU,M({size:"small",variant:"contained",onClick:function(){return e=r.id,void X((function(t){var n;return M(M({},t),((n={})[e]="save",n))}));var e},disabled:D.has(r.id)||!(null===(s=j.whenToApply)||void 0===s?void 0:s.trim())||!(null===(v=j.topic)||void 0===v?void 0:v.trim())||!(null===(f=j.modification)||void 0===f?void 0:f.trim())&&!(null===(g=j.tooltip)||void 0===g?void 0:g.trim()),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"#1565c0",border:"1px solid #624ea6",textTransform:"none",color:"white",height:32,px:1.5,fontWeight:600,"&:disabled":{backgroundColor:"#f3f4f6",color:"#9CA3AF",borderColor:"#d1d5db",height:32}}},{children:"Save"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return e=r.id,W((function(t){var n=M({},t);return delete n[e],n})),G((function(t){var n=M({},t);return delete n[e],n})),void X((function(t){var n=M({},t);return delete n[e],n}));var e},disabled:D.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"Cancel"}))]}))]})):"merge"===F?e(Yj,M({sx:{mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#6B7280",mb:2,fontFamily:"Plus Jakarta Sans",fontStyle:"italic"}},{children:"Merging will delete this learning and move its conditions into the current one. Do you want to proceed?"})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",gap:1}},{children:[n(zU,M({size:"small",variant:"contained",disabled:!1,onClick:function(){console.log("[Merge-DB] Merge button clicked for learning:",r.id),console.log("[Merge-DB] Sending merge message to chat"),m?(console.log("[Merge-DB] 🔵 MERGE BUTTON CLICKED - Sending merge request for learning:",r.id),console.log("[Merge-DB] Learning data:",r),m(r.id),ee.current&&z&&z({status:"success",message:"Merge request sent to chat for learning: ".concat(r.feedback.variant)})):(console.log("[Merge-DB] No onMergeMessage callback provided"),ee.current&&z&&z({status:"error",message:"Unable to send merge request - chat integration not available"})),X((function(e){var t;return M(M({},e),((t={})[r.id]=null,t))}))},sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"#10B981",textTransform:"none",color:"white",height:32,px:1.5,fontWeight:600,"&:hover":{backgroundColor:"#059669"}}},{children:R.has(r.id)?n(SW,{size:16,style:{color:"white"}}):"Yes"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return re(r.id)},disabled:R.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"No"}))]}))]})):F&&"object"==typeof F&&"delete"===F.action?e(Yj,M({sx:{mt:2}},{children:[n(iF,M({variant:"body2",sx:{fontSize:"0.9rem",color:"#B91C1C",mb:2,fontFamily:"Plus Jakarta Sans",fontStyle:"italic"}},{children:"This action cannot be undone, are you sure you want to delete this learning?"})),e(Yj,M({sx:{display:"flex",justifyContent:"flex-end",gap:1}},{children:[n(zU,M({size:"small",variant:"outlined",disabled:R.has(r.id),onClick:function(e){return b(void 0,void 0,void 0,(function(){return H(this,(function(t){e.stopPropagation(),console.log("[Delete-DB] Delete confirmation clicked for learning:",r.id),console.log("[Delete-DB] Setting deleting state for:",r.id),N((function(e){return new Set(e).add(r.id)}));try{u&&(u(F.label),console.log("[Delete-DB] Delete callback called for learning:",r.feedback.variant)),d&&d(r.id),ee.current&&z&&z({status:"success",message:"Successfully deleted learning: ".concat(r.feedback.variant)})}catch(e){console.error("[Delete-DB] error",e),ee.current&&z&&z({status:"error",message:"Error deleting learning: ".concat(e instanceof Error?e.message:"Unknown error")})}finally{ee.current&&(N((function(e){var t=new Set(e);return t.delete(r.id),t})),X((function(e){var t=M({},e);return delete t[r.id],t})))}return[2]}))}))},startIcon:n(P7,{}),sx:{fontFamily:"Plus Jakarta Sans",color:E,textTransform:"none",borderColor:E,"&:hover":{borderColor:E,backgroundColor:"".concat(E,"10")},"&:disabled":{color:"#9CA3AF",borderColor:"#9CA3AF"}}},{children:R.has(r.id)?n(SW,{size:16,style:{color:E}}):"Yes"})),n(zU,M({size:"small",variant:"outlined",onClick:function(){return re(r.id)},disabled:R.has(r.id),sx:{fontFamily:"Plus Jakarta Sans",color:"#6B7280",textTransform:"none",borderColor:"#6B7280","&:hover":{borderColor:"#374151",backgroundColor:"#F3F4F6"}}},{children:"No"}))]}))]})):e(Yj,M({sx:{display:"flex",gap:1,justifyContent:"flex-end",mt:2}},{children:["similar"===c&&n(LJ,M({title:"Merge this similar learning into the current one",arrow:!0},{children:n("span",M({style:{display:"inline-flex"}},{children:n(zU,M({size:"small",variant:"contained",onClick:function(){return e=r.id,void X((function(t){var n;return M(M({},t),((n={})[e]="merge",n))}));var e},startIcon:n(aee,{}),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"white",border:"1px solid #10B981",textTransform:"none",color:"#10B981",height:32,px:1.5,fontWeight:600,"&:hover":{backgroundColor:"#10B98110"}}},{children:"Merge"}))}))})),n(LJ,M({title:o&&l&&h?"Correct Me":"Edit unavailable: missing context",arrow:!0},{children:n("span",M({style:{display:"inline-flex"}},{children:n(zU,M({size:"small",color:"primary",variant:"contained",disabled:!(o&&l&&h)||D.has(r.id),onClick:function(){return function(e){var t=cee(e.feedback.variant);W((function(n){var r;return M(M({},n),((r={})[e.id]={topic:t.topic,modification:t.modification,tooltip:t.tooltip,whenToApply:Array.isArray(e.feedback.when_to_apply)?e.feedback.when_to_apply.join(", "):e.feedback.when_to_apply||"",whenNotToApply:Array.isArray(e.feedback.when_not_to_apply)?e.feedback.when_not_to_apply.join(", "):e.feedback.when_not_to_apply||""},r))}))}(r)},startIcon:n(q7,{}),sx:{fontFamily:"Plus Jakarta Sans",backgroundColor:"white",border:"1px solid #624ea6",textTransform:"none",color:"#1565c0",height:32,px:1.5,"&:hover":{backgroundColor:"#1565c020"},fontWeight:600}},{children:"Correct Me"}))}))})),n(LJ,M({title:o&&l&&h?"Delete":"Delete unavailable: missing context",arrow:!0},{children:n("span",M({style:{display:"inline-flex"}},{children:n(zU,M({size:"small",variant:"outlined",disabled:!(o&&l&&h)||R.has(r.id),onClick:function(e){e.stopPropagation(),function(e,t,n){var r="".concat("conflict"===n?"Conflicting":"Similar"," Learning ").concat(t);X((function(t){var n;return M(M({},t),((n={})[e]={action:"delete",label:r},n))}))}(r.id,i||"A",c)},startIcon:n(P7,{}),sx:{fontFamily:"Plus Jakarta Sans",color:"#cc0000",textTransform:"none",borderColor:"#cc0000","&:hover":{borderColor:"#cc0000",backgroundColor:"#cc000010"},"&:disabled":{color:"#9CA3AF",borderColor:"#9CA3AF"}}},{children:"Delete"}))}))}))]}))]}))]}),"".concat(c,"-").concat(a))};if(!(C&&0!==C.length||L&&0!==L.length))return null;var ce=function(e){return"similar"===e?"We've identified existing learnings that are similar to the current one. You may want to edit or delete them to avoid duplication or confusion.":"Some existing learnings may contradict the current one. Review them carefully, as they could cause instability when applied together."},ie=function(t,r){if(0===t.length)return null;var a=function(e,t){return 1===e?"similar"===t?"1 Similar Learning Found":"1 Conflicting Learning Found":"".concat(e,"similar"===t?" Similar Learnings Found":" Conflicting Learnings Found")}(t.length,r);return e(Yj,M({sx:{border:"1px solid #FCA5A5",boxShadow:"0 4px 10px rgba(0,0,0,0.05)",p:3,borderRadius:3,mt:3,mb:3,fontFamily:"Plus Jakarta Sans",transition:"all 0.2s ease-in-out","&:hover":{boxShadow:"0 6px 14px rgba(0,0,0,0.08)",transform:"translateY(-2px)"}}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2,justifyContent:"",fontFamily:"Plus Jakarta Sans"}},{children:[n(iF,M({sx:{fontSize:"1.2rem",fontWeight:700,color:"#B91C1C",fontFamily:"Plus Jakarta Sans"}},{children:a})),n(LJ,M({title:ce(r),placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",p:1,borderRadius:1.5,color:"#fff",fontFamily:"Plus Jakarta Sans"}}}},{children:n(Yj,M({sx:{width:24,height:24,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",ml:1,fontFamily:"Plus Jakarta Sans"}},{children:n(n7,{size:16,color:"#B91C1C"})}))}))]})),n(Yj,M({sx:{maxHeight:360,overflowY:"auto",pr:1.5,fontFamily:"Plus Jakarta Sans","&::-webkit-scrollbar":{width:"6px"},"&::-webkit-scrollbar-thumb":{backgroundColor:"#FCA5A5",borderRadius:"8px"},"&::-webkit-scrollbar-track":{backgroundColor:"#FEE2E2"}}},{children:t.map((function(e,t){return oe(e,t,r,function(e){return String.fromCharCode(65+e)}(t))}))}))]}),r)};return e(t,{children:[ie(C,"conflict"),ie(L,"similar")]})},lee=function(t){var r,a,o=t.organizationName,d=t.selectedText,u=t.scopeOptions,m=t.devModeTag,p=t.chatAssistantName,v=t.chatLogo,f=void 0===v?null:v,z=t.submitFunction;t.setShowChat,t.showChat;var g=t.formDataState,y=t.setFormDataState,C=t.instantLearningSuggestions;t.setHasUserFilledForm,t.hasUserFilledForm;var L=t.isNewChatClicked,w=t.setIsNewChatClicked,k=t.setHasUserWrittenModification,x=t.extractedModification,S=t.save,T=t.extractedTooltip;t.isSaveLoading,t.shouldTriggerSave;var O=t.baseUrl;t.topic_table,t.variant_table,t.scope_table,t.embedding_column_name,t.embedding_model;var A=t.validationWtaResponse,R=t.setValidationWtaResponse,N=t.learningWtaResponse,_=t.setLearningWtaResponse,D=t.setIsFormSavedClicked,P=t.onDeleteLearning,F=t.onMergeLearning,I=t.mergeLearningTrigger,B=t.resetLearningTrigger,j=t.editConflictingLearningTrigger,U=t.editSimilarLearningTrigger,W=t.setSendMessageInChat,$=t.isMergeLoading,q=t.setIsMergeLoading,G=c({context:"",issue_with_response:"",original:null!=d?d:"",modification:"",whenToApply:"",whenNotToApply:"",tooltip:"",scope:u[0].value,isTooltipEnabled:!1,isModificationEnabled:!0,isDevMode:!1}),Y=G[0],K=G[1],X=c(!1),Q=X[0],J=X[1],Z=c(!1),ee=Z[0],te=Z[1],ne=c(!1),re=ne[0],ae=ne[1],oe=c(!1),ce=oe[0],ie=oe[1],le=c([]),se=le[0],he=le[1],de=c([]),ue=de[0],me=de[1],pe=c(!1),ve=pe[0],fe=pe[1],ze=c(!1),ge=ze[0],ye=ze[1];s((function(){q(!1)}),[]);var Me=c(!1),Ee=Me[0],be=Me[1],He=c(!1);He[0];var Ve=He[1],Ce=c(null),Le=Ce[0];Ce[1];var we=c(!1);we[0],we[1];var ke=c(null);ke[0],ke[1];var xe=c(null),Se=xe[0],Te=xe[1],Oe=c(!1),Ae=Oe[0],Re=Oe[1],Ne=c(!1);Ne[0];var _e=Ne[1],De=c(null),Pe=De[0],Fe=De[1],Ie=c(null),Be=Ie[0],je=Ie[1],Ue=c(new Set),We=Ue[0],$e=Ue[1],qe=c(null),Ge=qe[0],Ye=qe[1];s((function(){try{j&&"object"==typeof j&&Object.keys(j).length>0&&(console.log("Processing conflicting learning edit actions:",j),Object.entries(j).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,c,i,l,s,h,d;return H(this,(function(u){switch(u.label){case 0:if(!(n&&n.edit_actions&&n.edit_actions.action))return[3,6];if(console.log("Processing conflicting learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=Array.isArray(e)?e.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():e||"",c=Array.isArray(r)?r.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():r||"",Fe((function(e){if(!e)return e;var r=M({},e);return Object.keys(r).forEach((function(e){r[e]&&r[e].id===t&&(r[e]=M(M({},r[e]),{feedback:M(M({},r[e].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:c})}))})),r})),console.log("Updated form with conflicting learning conditions:",{whenToApply:a,whenNotToApply:c}),!(O&&o&&p))return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),i=Pe?Object.values(Pe).find((function(e){return e&&e.id===t})):null,i?i.feedback?(l=cee(n.variant),s={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isUpdateAction:!0,isAgentsFeedback:!0,variant:{id:t,variant:n.variant,conditions_whentoapply:a,conditions_whennottoapply:c,scope:{name:"Custom",value:{scopeId:"askmod-scope-id",scopeName:"askmod"}},topic:{id:null,value:l.topic||"default"},categories:[],originalQuestion:"",parameterizedQuestion:null,created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),created_by:null,updated_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),updated_by:"madumbu.kathyayani@techolution.com",instantLearningType:"iL",appliedTagsIL:[],tagMappingInfoIL:{}}}},console.log("[LearningDetailsForm] Saving edited conditions for conflicting learning ".concat(t,":"),s),[4,g7({baseUrl:O,organizationName:o,chatAssistantName:p,payload:s})]):(console.error("[LearningDetailsForm] Learning feedback not found for ID: ".concat(t)),[2]):(console.error("[LearningDetailsForm] Learning object not found for ID: ".concat(t)),[2]);case 2:return(h=u.sent()).ok?(console.log("edit notifc"),Ye({status:"success",message:"Successfully saved edited conditions for this learning"}),console.log("[LearningDetailsForm] Successfully saved edited conditions for conflicting learning ".concat(t))):(console.error("[LearningDetailsForm] Failed to save edited conditions for conflicting learning ".concat(t,":"),h.status,h.statusText),Ye({status:"error",message:"Failed to save edited conditions for this learning"})),[3,4];case 3:return d=u.sent(),Ye({status:"error",message:"Error saving edited conditions for learning"}),console.error("[LearningDetailsForm] Error saving edited conditions for conflicting learning ".concat(t,":"),d),[3,4];case 4:return[3,6];case 5:console.log("[LearningDetailsForm] Missing required context for edit API call"),u.label=6;case 6:return[2]}}))}))}))),U&&"object"==typeof U&&Object.keys(U).length>0&&(console.log("Processing similar learning edit actions:",U),Object.entries(U).forEach((function(e){var t=e[0],n=e[1];return b(void 0,void 0,void 0,(function(){var e,r,a,c,i,l,s,h,d;return H(this,(function(u){switch(u.label){case 0:if(!(n&&n.edit_actions&&n.edit_actions.action))return[3,6];if(console.log("Processing similar learning edit action:",t,n),e=n.conditions_whentoapply||[],r=n.conditions_whennottoapply||[],a=Array.isArray(e)?e.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():e||"",c=Array.isArray(r)?r.join(" ").replace(/\s+and\s+/gi," and ").replace(/\s+/g," ").trim():r||"",je((function(e){if(!e)return e;var r=M({},e);return Object.keys(r).forEach((function(e){r[e]&&r[e].id===t&&(r[e]=M(M({},r[e]),{feedback:M(M({},r[e].feedback),{variant:n.variant,when_to_apply:a,when_not_to_apply:c})}))})),r})),console.log("Updated form with similar learning conditions:",{whenToApply:a,whenNotToApply:c}),!(O&&o&&p))return[3,5];u.label=1;case 1:return u.trys.push([1,3,,4]),i=Be?Object.values(Be).find((function(e){return e&&e.id===t})):null,i?i.feedback?(l=cee(n.variant),s={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isUpdateAction:!0,isAgentsFeedback:!0,variant:{id:t,variant:n.variant,conditions_whentoapply:a,conditions_whennottoapply:c,scope:{name:"Custom",value:{scopeId:"askmod-scope-id",scopeName:"askmod"}},topic:{id:null,value:l.topic||"default"},categories:[],originalQuestion:"",parameterizedQuestion:null,created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),created_by:null,updated_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),updated_by:"madumbu.kathyayani@techolution.com",instantLearningType:"iL",appliedTagsIL:[],tagMappingInfoIL:{}}}},console.log("[LearningDetailsForm] Saving edited conditions for similar learning ".concat(t,":"),s),[4,g7({baseUrl:O,organizationName:o,chatAssistantName:p,payload:s})]):(console.error("[LearningDetailsForm] Learning feedback not found for ID: ".concat(t)),[2]):(console.error("[LearningDetailsForm] Learning object not found for ID: ".concat(t)),[2]);case 2:return(h=u.sent()).ok?(console.log("edit notifc"),Ye({status:"success",message:"Successfully saved edited conditions for this similar learning"}),console.log("[LearningDetailsForm] Successfully saved edited conditions for this similar learning")):(console.error("[LearningDetailsForm] Failed to save edited conditions for similar learning ".concat(t,":"),h.status,h.statusText),Ye({status:"error",message:"Failed to save edited conditions for this learning"})),[3,4];case 3:return d=u.sent(),console.error("[LearningDetailsForm] Error saving edited conditions for similar learning ".concat(t,":"),d),[3,4];case 4:return[3,6];case 5:console.log("[LearningDetailsForm] Missing required context for edit API call"),u.label=6;case 6:return[2]}}))}))})))}catch(e){console.error("Error processing edit tool actions:",e)}}),[j,U,Fe,je,O,o,p]);var Ke=l((function(e){return b(void 0,void 0,void 0,(function(){var t,n,r,a;return H(this,(function(c){switch(c.label){case 0:if(console.log("[LearningDetailsForm] Merging learning from chat:",e),!Be)return console.log("No similar learnings data available"),[2];if(!(t=Object.values(Be).find((function(t){return t&&t.id===e}))))return console.log("Learning with ID ".concat(e," not found in similar learnings")),[2];if(console.log("Found learning to merge:",t),console.log("🔵 LEARNING DETAILS FORM - Merge button clicked, waiting for merge response to provide correct conditions"),q(!0),je((function(t){if(!t)return{};var n={};return Object.keys(t).forEach((function(r){t[r].id!==e&&(n[r]=t[r])})),n})),$e((function(t){return new Set(t).add(e)})),setTimeout((function(){Fe((function(e){return je((function(t){return e&&0!==Object.keys(e).length||t&&0!==Object.keys(t).length||_e(!1),t})),e}))}),100),console.log("[LearningDetailsForm] Successfully merged learning from chat"),!(O&&o&&p))return[3,5];c.label=1;case 1:return c.trys.push([1,3,,4]),n={status:"approved",metadata:{userName:"M Kathyayani",userEmailId:"madumbu.kathyayani@techolution.com",llm:"claude-3.5-sonnet",isVariantFlow:!0,isDeleteAction:!0,isAgentsFeedback:!0,variant:{id:e,scope:{name:"User",value:[{name:"M Kathyayani",email:"madumbu.kathyayani@techolution.com",userId:"8059658c-a65c-4e14-89aa-a5195f5d09f5"}]},topic:{id:null,value:"default"},variant:"Learning ID: ".concat(e),question:"",categories:[],created_at:(new Date).toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!0}),originalQuestion:"",parameterizedQuestion:"",conditions_whentoapply:"",conditions_whennottoapply:"",parentId:null}}},console.log("[LearningDetailsForm] Deleting merged learning with ID: ".concat(e)),[4,g7({baseUrl:O,organizationName:o,chatAssistantName:p,payload:n})];case 2:return(r=c.sent()).ok?(Ye({status:"success",message:"Learning merged successfully."}),console.log("[LearningDetailsForm] Successfully deleted merged learning ".concat(e))):(console.error("[LearningDetailsForm] Failed to delete merged learning",r.status,r.statusText),Ye({status:"error",message:"Failed to complete merge for learning."})),[3,4];case 3:return a=c.sent(),console.error("[LearningDetailsForm] Error deleting merged learning ".concat(e,":"),a),[3,4];case 4:return[3,6];case 5:console.log("[LearningDetailsForm] Missing required context for delete API call"),c.label=6;case 6:return[2]}}))}))}),[Be,y,he,me,O,o,p]);s((function(){I&&(Ke(I),F&&F(I))}),[I,F,Ke]),s((function(){B&&(console.log("[LearningDetailsForm] 🔄 RESET TRIGGER RECEIVED - Clearing all learning data"),console.log("[LearningDetailsForm] Before reset - DBCWtaApiResponse:",Pe?Object.keys(Pe).length:0,"items"),console.log("[LearningDetailsForm] Before reset - DBSWtaApiResponse:",Be?Object.keys(Be).length:0,"items"),Fe(null),je(null),_e(!1),Re(!1),$e(new Set),he([]),me([]),q(!1),K((function(e){return M(M({},e),{whenToApply:"",whenNotToApply:"",tooltip:"",modification:"",isTooltipEnabled:!1,isModificationEnabled:!0})})),console.log("[LearningDetailsForm] ✅ Learning data reset completed"))}),[B]);var Xe=h((function(){var e,t,n,r,a=""!==(null===(e=null==Y?void 0:Y.original)||void 0===e?void 0:e.trim()),o=""!==(null===(t=null==Y?void 0:Y.whenToApply)||void 0===t?void 0:t.trim()),c=(null==se?void 0:se.length)>0,i=!(null==Y?void 0:Y.isTooltipEnabled)||""!==(null===(n=null==Y?void 0:Y.tooltip)||void 0===n?void 0:n.trim()),l=!0;return(null==Y?void 0:Y.isModificationEnabled)&&(l=""!==(null===(r=null==Y?void 0:Y.modification)||void 0===r?void 0:r.trim())),a&&o&&c&&(i||l)}),[Y,se,C]),Qe=h((function(){var e=Ae&&Se,t=Pe&&Object.keys(Pe).length>0,n=Be&&Object.keys(Be).length>0;return!!e||t||n}),[Ae,Se,Pe,Be]),Je=i(null);s((function(){Y.isModificationEnabled||K((function(e){return M(M({},e),{modification:""})})),Y.isTooltipEnabled||K((function(e){return M(M({},e),{tooltip:""})}))}),[Y.isModificationEnabled,Y.isTooltipEnabled]),s((function(){if(""===x&&(null==Y?void 0:Y.isTooltipEnabled)&&K((function(e){return M(M({},e),{isModificationEnabled:!1})})),""!==x||(null==Y?void 0:Y.isTooltipEnabled)||K((function(e){return M(M({},e),{modification:""})})),x&&""!==x){K((function(e){return M(M({},e),{modification:x,isModificationEnabled:!0})})),ie(!0);var e=setTimeout((function(){ie(!1)}),400);return function(){return clearTimeout(e)}}}),[x]),s((function(){""===T&&K((function(e){return M(M({},e),{isTooltipEnabled:!1})})),T&&""!==T&&K((function(e){return M(M({},e),{tooltip:T,isTooltipEnabled:!0})}))}),[T]),s((function(){L&&$e(new Set)}),[L]),s((function(){L&&(K((function(e){return M(M({},e),{modification:"",tooltip:"",isTooltipEnabled:!1,isModificationEnabled:!0,whenToApply:"",whenNotToApply:""})})),he([]),me([]),q(!1),w(!1),Ve(!1),Re(!1),_e(!1))}),[L]),s((function(){y(Y)}),[Y]),s((function(){(null==g?void 0:g._mergeUpdate)&&(console.log("🔵 LEARNING DETAILS FORM - Detected merge update:",g),g._mergeWTA&&(console.log("🔵 LEARNING DETAILS FORM - Updating suggestedWTA with merge data:",g._mergeWTA),he(g._mergeWTA)),g._mergeWNTA&&(console.log("🔵 LEARNING DETAILS FORM - Updating suggestedWnTA with merge data:",g._mergeWNTA),me(g._mergeWNTA)),y((function(e){return e._mergeUpdate,e._mergeWTA,e._mergeWNTA,E(e,["_mergeUpdate","_mergeWTA","_mergeWNTA"])})))}),[null==g?void 0:g._mergeUpdate,null==g?void 0:g._mergeWTA,null==g?void 0:g._mergeWNTA]),s((function(){""===Y.original.trim()||""===Y.modification.trim()&&""===Y.tooltip.trim()||Q||J(!0)}),[Y]),s((function(){if((null==se?void 0:se.length)>=0){var e=se.join(" OR ");Y.whenToApply!==e&&K((function(t){return M(M({},t),{whenToApply:e})}))}}),[JSON.stringify(se),Y.whenToApply]),s((function(){if((null==ue?void 0:ue.length)>=0){var e=ue.join(" OR ");Y.whenNotToApply!==e&&K((function(t){return M(M({},t),{whenNotToApply:e})}))}}),[JSON.stringify(ue),Y.whenNotToApply]),s((function(){if((null==se?void 0:se.length)>0&&!ve){te(!0);var e=setTimeout((function(){te(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(se)]),s((function(){if((null==ue?void 0:ue.length)>0&&!ge){ae(!0);var e=setTimeout((function(){ae(!1)}),400);return function(){return clearTimeout(e)}}}),[JSON.stringify(ue)]),s((function(){var e,t,n,r;if(C){fe(!1),ye(!1);var a=null===(e=null==C?void 0:C.conditions_whentoapply)||void 0===e?void 0:e.map((function(e){return e.when_to_apply})),o=null===(t=null==C?void 0:C.conditions_whennottoapply)||void 0===t?void 0:t.map((function(e){return e.when_not_to_apply}));(null===(n=null==C?void 0:C.conditions_whentoapply)||void 0===n?void 0:n.length)&&(he(a.filter((function(e){return""!==e}))),K((function(e){return M(M({},e),{whenToApply:null==a?void 0:a.join(" OR ")})}))),(null===(r=null==C?void 0:C.conditions_whennottoapply)||void 0===r?void 0:r.length)&&(me(o.filter((function(e){return""!==e}))),K((function(e){return M(M({},e),{whenNotToApply:null==o?void 0:o.join(" OR ")})})))}}),[C]);var Ze=i(null),et=l((function(){Ze.current&&clearTimeout(Ze.current),Ze.current=setTimeout((function(){k(!0)}),1e3)}),[]),tt=l((function(e){return function(t){K((function(n){var r;return M(M({},n),((r={})[e]=t.target.value,r))})),et()}}),[et]),nt=function(e){return e.replace(new RegExp("<".concat(m,">"),"gi"),"").replace(new RegExp("</".concat(m,">"),"gi"),"").replace(/<\/?[^>]+(>|$)/g,"")},rt=l((function(e){var t=nt(e);K((function(e){return M(M({},e),{tooltip:t})})),et()}),[et]),at=function(e){return function(t){var n=t.target.checked,r={};"isTooltipEnabled"===e?r={tooltip:n?Y.tooltip:"",isModificationEnabled:!n||Y.isModificationEnabled}:"isModificationEnabled"===e&&(r={modification:n?Y.modification:""}),K((function(t){var a;return M(M(M({},t),r),((a={})[e]=n,a))}))}};s((function(){if(S){console.log("'save: true' received. Forcibly clearing all conflict UI states."),Re(!1),Te(null),D(!0);b(void 0,void 0,void 0,(function(){return H(this,(function(e){return Qe?(console.error("Save action triggered via prop, but is blocked due to unresolved conflicts."),[2]):(console.log("Form submitted:",Y),be(!0),""===(null==Y?void 0:Y.modification)&&K((function(e){return M(M({},e),{isModificationEnabled:!1})})),""===(null==Y?void 0:Y.tooltip)&&K((function(e){return M(M({},e),{isTooltipEnabled:!1})})),z(Y,be),[2])}))}))}}),[S,Qe]);s((function(){A&&!1===A.is_valid?(Re(!0),Te(A.conflictingConditions),dt()):A&&A.is_valid?(Re(!1),Te(null),console.log("valid response received, calling handleSubmit")):(Re(!1),console.log("resetting validateWtaApiResponse"),Te(null))}),[A]),s((function(){if(N){var e=(null==N?void 0:N.conflicting_learnings)||{},t=(null==N?void 0:N.similar_learnings)||{};Object.keys(e).length,Object.keys(t).length;var n=Object.keys(e).reduce((function(t,n){var r=e[n];return We.has(r.id)||(t[n]=r),t}),{}),r=Object.keys(t).reduce((function(e,n){var r=t[n];return We.has(r.id)||(e[n]=r),e}),{});Fe(n),je(r);var a=Object.keys(n).length>0,o=Object.keys(r).length>0;a||o?(_e(!0),Re(!1),dt()):!0===(null==N?void 0:N.is_valid_db)&&_e(!1)}}),[N,We]);var ot,ct,it=i(null),lt=c(!1),st=lt[0],ht=lt[1],dt=function(){var e=it.current;e&&setTimeout((function(){e.scrollTo({top:e.scrollHeight,behavior:"smooth"}),ht(!1)}),200)};return s((function(){var e=it.current,t=function(){var e=it.current;if(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;ht(!(n-(t+r)<=35))}};return e&&(e.addEventListener("scroll",t),t()),function(){e&&e.removeEventListener("scroll",t)}}),[st]),e(Yj,M({p:0,className:j8,sx:{display:"flex",flexDirection:"column",height:"100%",width:"100%"}},{children:[n(Yj,{children:n(iF,M({sx:{fontSize:20,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Instant Learning"}))}),e(Yj,M({sx:{fontFamily:"Plus Jakarta Sans",display:"flex",flexDirection:"column",gap:2,justifyContent:"space-between",flexGrow:1,paddingTop:"20px",height:"calc(100% - 30px)",overflow:"auto"}},{children:[e(Yj,M({sx:{display:"flex",flexDirection:"column",gap:"20px",height:"calc(100% - 90px)",overflow:"auto",position:"relative"},ref:it},{children:[e(Yj,M({sx:{display:"flex",gap:2}},{children:[e(Yj,M({sx:{flex:1}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[e(iF,M({sx:{fontFamily:"Plus Jakarta Sans",fontSize:"1rem",fontWeight:600,display:"flex",alignItems:"center"}},{children:["Original"," ",n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Original word/phrase which needs to be replaced",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(YZ,{sx:{visibility:"hidden"},disabled:!0})]})),n(j2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}},id:"original",value:Y.original,onChange:tt("original"),fullWidth:!0,placeholder:"Enter original"})]})),e(Yj,M({sx:{flex:1}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[e(iF,M({sx:{fontFamily:"Plus Jakarta Sans",fontWeight:600,fontSize:"1rem",display:"flex",alignItems:"center"}},{children:["Modification",Y.isModificationEnabled&&!Y.isTooltipEnabled&&n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Modified word/phrase which Original needs to be replaced with",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(YZ,{checked:Y.isModificationEnabled,disabled:!Y.isTooltipEnabled,onChange:at("isModificationEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),Y.isModificationEnabled&&n(j2,{sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},boxShadow:ce?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"},id:"modification",value:Y.modification,onChange:tt("modification"),fullWidth:!0,placeholder:"Change ".concat(d," to...")})]}))]})),e(Yj,M({sx:{display:"flex",gap:2}},{children:[n(Yj,{sx:{flex:1}}),e(Yj,M({sx:{flex:1}},{children:[e(Yj,M({sx:{display:"flex",justifyContent:"space-between"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"}},{children:["Tooltip",Y.isTooltipEnabled&&n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Adds a tooltip to the modification or the original word",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),n(YZ,{checked:Y.isTooltipEnabled,onChange:at("isTooltipEnabled"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#5928ed"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#5928ed"}}})]})),Y.isTooltipEnabled&&e(Yj,M({sx:{display:"flex",alignItems:"center"}},{children:[n(iF,M({sx:{fontSize:14,fontWeight:600,fontFamily:"Plus Jakarta Sans"}},{children:"Dev Mode"})),n(YZ,{checked:Y.isDevMode,onChange:at("isDevMode"),sx:{"& .MuiSwitch-switchBase.Mui-checked":{color:"#4b5563"},"& .MuiSwitch-switchBase.Mui-checked + .MuiSwitch-track":{backgroundColor:"#4b5563"}}})]}))]})),Y.isTooltipEnabled&&n(j2,{id:"tooltip",inputRef:Je,value:function(){var e=nt(Y.tooltip);return Y.isDevMode?"<".concat(m,">").concat(e,"</").concat(m,">"):e}(),onChange:function(e){return rt(e.target.value)},onFocus:function(){setTimeout((function(){if(Y.isDevMode){var e=nt(Y.tooltip),t="<".concat(m,">").length+e.length,n=Je.current;n&&n.setSelectionRange(t,t)}}),0)},fullWidth:!0,placeholder:Y.isDevMode?"<".concat(m,">Enter tooltip content</").concat(m,">"):"Enter tooltip content",sx:{"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"}}})]}))]})),e(Yj,M({sx:{display:"flex",gap:2,height:"".concat(Y.isTooltipEnabled?"calc(100% - 248px)":"calc(100% - 200px)")}},{children:[(!(null==se?void 0:se.length)||$)&&e(Yj,M({sx:{flex:1}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",display:"flex",flexDirection:"column"}},{children:[e("div",M({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),n("div",M({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:e("div",M({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},$?{children:[n(SW,{size:24,sx:{color:"#5928ED",mb:1}}),n("div",M({style:{fontWeight:"700",color:"#5928ED"}},{children:"Merging conditions..."})),n("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"0.875rem",flexFlow:"wrap"}},{children:n("div",{children:"Processing merge response...."})}))]}:{children:[n("div",M({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),e("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[n("div",M({style:{}},{children:"Tell us about your learning in "})),n("span",M({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",n("span",{children:"Chat"})]}))]}))}))]}))]})),(null==se?void 0:se.length)>0&&!$&&e(Yj,M({sx:{flex:1,height:"100%"}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When To Apply",n(Yj,M({component:"span",sx:{color:"red"}},{children:"*"})),n(LJ,M({title:"Specific situations or conditions where this learning should be applied.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:ee?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[e(Yj,M({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[e(Yj,M({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[f&&n(Yj,{component:"img",src:f,alt:"Chat",sx:{width:14,height:14}}),e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==se?void 0:se.length)>0&&n(LJ,M({title:ve?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(UP,M({disabled:se.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return fe((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:n(ve?j7:q7,{fontSize:"small"})}))}))]})),n(Yj,M({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:n("ol",M({style:{paddingLeft:"0rem",fontFamily:"Plus Jakarta Sans",margin:0}},{children:ee?e(Yj,M({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[n(SW,{size:24}),n("span",{children:"Generating When to apply..."})]})):n(Yj,M({sx:{pt:"16px"}},{children:se.map((function(e,t){return{value:e,index:t}})).map((function(t,r){var a=t.value,o=t.index;return e(Yj,M({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:o<se.length-1?2:0,fontFamily:"Plus Jakarta Sans"},component:"li"},{children:[n(j2,{variant:"outlined",disabled:!ve,fullWidth:!0,multiline:!0,value:"".concat(a),onChange:function(e){var t=V([],se,!0);t[o]=e.target.value,R(null),_({similar_learnings:"",conflicting_learnings:""}),he(t),K((function(e){return M(M({},e),{whenToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:e(VG,M({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[o+1,"."]}))}}),ve&&n(UP,M({onClick:function(){if(se.length>1){var e=se.filter((function(e,t){return t!==o}));he(e),K((function(t){return M(M({},t),{whenToApply:e.join(" OR ")})}))}},sx:{mt:1}},{children:n(P7,{})}))]}),o)}))}))}))}))]}))]})),(!(null==ue?void 0:ue.length)||$)&&e(Yj,M({sx:{flex:1}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",n(LJ,M({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,flex:1,display:"flex",flexDirection:"column",height:"calc(100% - 64px)"}},{children:[e("div",M({style:{width:"100%",display:"flex",gap:"0.25rem"}},{children:[e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),n("div",M({style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"}},{children:e("div",M({style:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",gap:"0.5rem",paddingTop:"1rem",paddingBottom:"1rem"}},$?{children:[n(SW,{size:24,sx:{color:"#5928ED",mb:1}}),n("div",M({style:{fontWeight:"700",color:"#5928ED"}},{children:"Merging conditions..."})),n("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"0.875rem",flexFlow:"wrap"}},{children:n("div",{children:"Processing merge response..."})}))]}:{children:[n("div",M({style:{fontWeight:"700",color:"#6b7280"}},{children:"No suggestions found"})),e("div",M({style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",gap:"0.25rem",fontSize:"1rem",flexFlow:"wrap"}},{children:[n("div",M({style:{}},{children:"Tell us about your learning in "})),n("span",M({style:{color:"#5928ED",fontWeight:"700"}},{children:"InstantLearning.AI"}))," ",n("span",{children:"Chat"})]}))]}))}))]}))]})),(null==ue?void 0:ue.length)>0&&!$&&e(Yj,M({sx:{flex:1,height:"100%"}},{children:[e(iF,M({sx:{fontSize:"1rem",fontWeight:600,marginBottom:"8px",fontFamily:"Plus Jakarta Sans",display:"flex",alignItems:"center"},gutterBottom:!0},{children:["When Not To Apply",n(LJ,M({title:"Cases where this learning should not be applied to avoid incorrect responses.",placement:"top",arrow:!0,componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(n7,{size:16,style:{paddingLeft:"0.25rem"}})}))]})),e(Yj,M({sx:{border:"1px solid #ccc",borderRadius:"8px",padding:2,height:"calc(100% - 64px)",boxShadow:re?"0 0 12px 3px rgba(34, 197, 94, 0.6)":"none",transition:"box-shadow 0.3s ease-in-out"}},{children:[e(Yj,M({display:"flex",alignItems:"center",justifyContent:"space-between",sx:{mb:"8px"}},{children:[e(Yj,M({display:"flex",gap:"0.25rem",alignItems:"center"},{children:[f&&n(Yj,{component:"img",src:f,alt:"Chat",sx:{width:14,height:14}}),e("svg",M({width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:[n("g",M({id:"bi:stars","clip-path":"url(#clip0_6004_60631)"},{children:n("path",{id:"Vector",d:"M11.4867 9.37021C11.6517 8.87521 12.3507 8.87521 12.5157 9.37021L13.4832 12.2757C13.6961 12.9144 14.0549 13.4947 14.5311 13.9707C15.0073 14.4466 15.5879 14.8051 16.2267 15.0177L19.1307 15.9852C19.6257 16.1502 19.6257 16.8492 19.1307 17.0142L16.2252 17.9817C15.5865 18.1947 15.0062 18.5535 14.5302 19.0297C14.0543 19.5059 13.6958 20.0864 13.4832 20.7252L12.5157 23.6292C12.4801 23.7376 12.4112 23.832 12.3188 23.8989C12.2264 23.9658 12.1153 24.0019 12.0012 24.0019C11.8871 24.0019 11.7759 23.9658 11.6835 23.8989C11.5912 23.832 11.5223 23.7376 11.4867 23.6292L10.5192 20.7237C10.3064 20.0852 9.9478 19.505 9.47187 19.029C8.99594 18.5531 8.41572 18.1945 7.77718 17.9817L4.87168 17.0142C4.76329 16.9786 4.6689 16.9097 4.60198 16.8173C4.53506 16.725 4.49904 16.6138 4.49904 16.4997C4.49904 16.3856 4.53506 16.2745 4.60198 16.1821C4.6689 16.0897 4.76329 16.0208 4.87168 15.9852L7.77718 15.0177C8.41572 14.8049 8.99594 14.4463 9.47187 13.9704C9.9478 13.4945 10.3064 12.9142 10.5192 12.2757L11.4867 9.37021ZM5.69218 1.72171C5.71369 1.65675 5.75512 1.60022 5.8106 1.56016C5.86607 1.52009 5.93275 1.49853 6.00118 1.49853C6.06961 1.49853 6.13629 1.52009 6.19176 1.56016C6.24724 1.60022 6.28867 1.65675 6.31018 1.72171L6.89068 3.46471C7.15018 4.24171 7.75918 4.85071 8.53618 5.11021L10.2792 5.69071C10.3441 5.71222 10.4007 5.75365 10.4407 5.80912C10.4808 5.86459 10.5024 5.93128 10.5024 5.99971C10.5024 6.06813 10.4808 6.13482 10.4407 6.19029C10.4007 6.24576 10.3441 6.2872 10.2792 6.30871L8.53618 6.88921C8.15274 7.01647 7.80431 7.23149 7.51864 7.51717C7.23296 7.80284 7.01794 8.15127 6.89068 8.53471L6.31018 10.2777C6.28867 10.3427 6.24724 10.3992 6.19176 10.4393C6.13629 10.4793 6.06961 10.5009 6.00118 10.5009C5.93275 10.5009 5.86607 10.4793 5.8106 10.4393C5.75512 10.3992 5.71369 10.3427 5.69218 10.2777L5.11168 8.53471C4.98442 8.15127 4.7694 7.80284 4.48372 7.51717C4.19805 7.23149 3.84962 7.01647 3.46618 6.88921L1.72318 6.30871C1.65822 6.2872 1.60169 6.24576 1.56163 6.19029C1.52156 6.13482 1.5 6.06813 1.5 5.99971C1.5 5.93128 1.52156 5.86459 1.56163 5.80912C1.60169 5.75365 1.65822 5.71222 1.72318 5.69071L3.46618 5.11021C3.84962 4.98295 4.19805 4.76792 4.48372 4.48225C4.7694 4.19657 4.98442 3.84815 5.11168 3.46471L5.69218 1.72171ZM16.2957 0.148207C16.3105 0.105497 16.3382 0.068461 16.3751 0.0422495C16.4119 0.016038 16.456 0.00195312 16.5012 0.00195312C16.5464 0.00195313 16.5905 0.016038 16.6273 0.0422495C16.6641 0.068461 16.6919 0.105497 16.7067 0.148207L17.0937 1.30921C17.2662 1.82821 17.6727 2.23471 18.1917 2.40721L19.3527 2.79421C19.3954 2.80901 19.4324 2.83676 19.4586 2.87359C19.4848 2.91042 19.4989 2.9545 19.4989 2.99971C19.4989 3.04491 19.4848 3.08899 19.4586 3.12582C19.4324 3.16265 19.3954 3.1904 19.3527 3.20521L18.1917 3.59221C17.9361 3.67771 17.7039 3.82139 17.5134 4.01193C17.3229 4.20247 17.1792 4.43467 17.0937 4.69021L16.7067 5.85121C16.6919 5.89392 16.6641 5.93095 16.6273 5.95717C16.5905 5.98338 16.5464 5.99746 16.5012 5.99746C16.456 5.99746 16.4119 5.98338 16.3751 5.95717C16.3382 5.93095 16.3105 5.89392 16.2957 5.85121L15.9087 4.69021C15.8232 4.43467 15.6795 4.20247 15.489 4.01193C15.2984 3.82139 15.0662 3.67771 14.8107 3.59221L13.6512 3.20521C13.6085 3.1904 13.5714 3.16265 13.5452 3.12582C13.519 3.08899 13.5049 3.04491 13.5049 2.99971C13.5049 2.9545 13.519 2.91042 13.5452 2.87359C13.5714 2.83676 13.6085 2.80901 13.6512 2.79421L14.8122 2.40721C15.3312 2.23471 15.7377 1.82821 15.9102 1.30921L16.2957 0.148207Z",fill:"#5928ed"})})),n("defs",{children:n("clipPath",M({id:"clip0_6004_60631"},{children:n("rect",{width:"24",height:"24",fill:"white"})}))})]})),n(iF,M({variant:"body1",sx:{ml:f?1:0,fontWeight:"600",fontFamily:"Plus Jakarta Sans",color:"#5928ed"}},{children:"AI Suggestions"}))]})),(null==ue?void 0:ue.length)>0&&n(LJ,M({placement:"top",arrow:!0,title:ge?"Save & Lock":"Edit",componentsProps:{tooltip:{sx:{fontSize:"0.875rem",padding:"0.5rem",fontFamily:"Plus Jakarta Sans, sans-serif"}}}},{children:n(UP,M({disabled:ue.some((function(e){return""===(null==e?void 0:e.trim())})),onClick:function(){return ye((function(e){return!e}))},size:"small",sx:{color:"gray","&:hover":{color:"black"}}},{children:n(ge?j7:q7,{fontSize:"small"})}))}))]})),n(Yj,M({sx:{height:"calc(100% - 38px)",overflow:"auto"}},{children:n("ol",M({style:{paddingLeft:"0rem",margin:0}},{children:re?e(Yj,M({sx:{display:"flex",justifyContent:"center",py:2,gap:2}},{children:[n(SW,{size:24}),n("span",{children:"Generating When not to apply..."})]})):n(Yj,M({sx:{pt:"16px"}},{children:ue.map((function(e,t){return{value:e,index:t}})).map((function(t,r){var a=t.value,o=t.index;return e(Yj,M({sx:{display:"flex",alignItems:"flex-start",gap:1,mb:o<ue.length-1?2:0},component:"li"},{children:[n(j2,{variant:"outlined",disabled:!ge,fullWidth:!0,multiline:!0,value:"".concat(a),error:!a.trim(),onChange:function(e){var t=V([],ue,!0);t[o]=e.target.value,R(null),_({similar_learnings:"",conflicting_learnings:""}),me(t),K((function(e){return M(M({},e),{whenNotToApply:t.join(" OR ")})}))},sx:{backgroundColor:"#f9fafb",borderRadius:1,"& .MuiInputBase-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputBase-input.Mui-disabled":{color:"#000",WebkitTextFillColor:"#000"},"& .MuiInputLabel-root":{fontFamily:"Plus Jakarta Sans, sans-serif"},"& .MuiInputLabel-root.Mui-disabled":{color:"rgba(0, 0, 0, 0.6)"}},InputProps:{startAdornment:e(VG,M({position:"start",sx:{color:"#000",alignSelf:"flex-start",paddingTop:"12px"}},{children:[o+1,"."]}))}}),ge&&n(UP,M({onClick:function(){if(ue.length>1){var e=ue.filter((function(e,t){return t!==o}));me(e),K((function(t){return M(M({},t),{whenNotToApply:e.join(" OR ")})}))}},disabled:1===ue.length,sx:{mt:1}},{children:n(P7,{})}))]}),o)}))}))}))}))]}))]}))]})),Ae&&Se&&n(Q7,{conflictingConditions:Se}),(ct=Pe&&Object.keys(Pe).length>0||Be&&Object.keys(Be).length>0,console.log("[LearningDetailsForm] 🔍 Checking if warning cards should show:",ct),console.log("[LearningDetailsForm] DBCWtaApiResponse keys:",Pe?Object.keys(Pe).length:0),console.log("[LearningDetailsForm] DBSWtaApiResponse keys:",Be?Object.keys(Be).length:0),ct&&n(iee,{conflictingConditions:[Object.values(Pe||{}),Object.values(Be||{})],baseUrl:O,organizationName:o,chatAssistantName:p||"",curlPayload:null!==(a=null!==(r=null==Le?void 0:Le.curlPayload)&&void 0!==r?r:null===window||void 0===window?void 0:window.__DELETE_CURL__)&&void 0!==a?a:"",onDeleted:function(e){console.log("[LearningDetailsForm] Learning deleted:",e),$e((function(t){return new Set(t).add(e)})),Fe((function(t){if(!t)return{};var n=Object.values(t).filter((function(t){return t.id!==e}));console.log("[LearningDetailsForm] Re-keying conflicting learnings after delete:",{deletedId:e,remainingCount:n.length,remainingLearnings:n.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var r={};return n.forEach((function(e,t){var n=String.fromCharCode(65+t);r[n]=e,console.log("[LearningDetailsForm] Conflicting learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),console.log("[LearningDetailsForm] Final conflicting learnings object:",Object.keys(r)),r})),je((function(t){if(!t)return{};var n=Object.values(t).filter((function(t){return t.id!==e}));console.log("[LearningDetailsForm] Re-keying similar learnings after delete:",{deletedId:e,remainingCount:n.length,remainingLearnings:n.map((function(e){return{id:e.id,variant:e.feedback.variant}}))});var r={};return n.forEach((function(e,t){var n=String.fromCharCode(65+t);r[n]=e,console.log("[LearningDetailsForm] Similar learning ".concat(t," gets key '").concat(n,"':"),e.feedback.variant)})),console.log("[LearningDetailsForm] Final similar learnings object:",Object.keys(r)),r})),setTimeout((function(){Fe((function(e){return je((function(t){return e&&0!==Object.keys(e).length||t&&0!==Object.keys(t).length||_e(!1),t})),e}))}),100)},onMergeMessage:function(e){console.log("[LearningDetailsForm] 🟡 MERGE MESSAGE RECEIVED:",e),console.log("[LearningDetailsForm] onMergeLearning available:",!!F),F?(console.log("[LearningDetailsForm] Calling onMergeLearning with:",e),F(e)):console.log("[LearningDetailsForm] ❌ onMergeLearning not available")},onDeleteLearning:P,setSendMessageInChat:W,editConflictingLearningTrigger:j,editSimilarLearningTrigger:U,operationStatus:Ge,onOperationComplete:function(){return Ye(null)},onSetOperationStatus:Ye}))]})),e(Yj,M({sx:{display:"flex",gap:2}},{children:[e(Yj,M({sx:{flex:1}},{children:[n(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"Plus Jakarta Sans"},gutterBottom:!0},{children:"Scope"})),n(tq,M({sx:{width:"50%",fontFamily:"Plus Jakarta Sans"},variant:"outlined"},{children:e(iQ,M({id:"scope",value:Y.scope,onChange:(ot="scope",function(e){K((function(t){var n;return M(M({},t),((n={})[ot]=e.target.value,n))}))}),displayEmpty:!0,sx:{fontFamily:"Plus Jakarta Sans"},fullWidth:!0},{children:[n(dK,M({value:"",disabled:!0},{children:"Select scope"})),u.map((function(e,t){return n(dK,M({value:e.value,sx:{fontFamily:"Plus Jakarta Sans"}},{children:e.labelText}),t)}))]}))}))]})),n(Yj,M({sx:{flex:1,display:"flex",alignItems:"flex-end",justifyContent:"flex-end"}},{children:e(zU,M({variant:"contained",onClick:function(){return b(void 0,void 0,void 0,(function(){return H(this,(function(e){return Qe?(console.warn("Save blocked by button click: Unresolved conflicts are present."),dt(),[2]):(D(!0),[2])}))}))},sx:{width:"30%",height:"56px",fontFamily:"Plus Jakarta Sans",backgroundColor:"green",textTransform:"capitalize","&:hover":{backgroundColor:"#006400"},pointerEvents:Ee?"none":"auto"},disabled:!Xe||Qe},{children:[Ee&&n(SW,{sx:{marginRight:"8px",color:"#fff"},size:16}),Ee?"Saving":"Save"]}))}))]}))]})),Ge&&n(nJ,M({open:!0,autoHideDuration:4e3,onClose:function(){return Ye(null)},anchorOrigin:{vertical:"top",horizontal:"right"}},{children:n(tF,M({onClose:function(){return Ye(null)},severity:Ge.status,sx:{width:"100%"}},{children:Ge.message}))}))]}))},see=function(r){var a=r.open,o=r.selectedText,i=r.scopeOptions,l=r.devModeTag,h=r.submitFunction,d=r.chatAssistantName,u=r.organizationName,m=r.baseUrl,p=r.baseWebsocketUrl,v=r.chatAssistantLogoUrl,f=r.ChatIconComponent,z=r.ggcAssistantName,g=r.closeFunction,y=r.ThinkingBulbIconComponent,E=r.template,b=void 0===E?"":E;r.userQuery,r.topic,r.templateOptions;var H=r.topic_table,V=void 0===H?"".concat(u,"-instantLearning-topics"):H,C=r.variant_table,L=void 0===C?"".concat(u,"-instantLearning-variants"):C,w=r.scope_table,k=void 0===w?"".concat(u,"-instantLearning-scopes"):w,x=r.embedding_column_name,S=void 0===x?"variant_embedding":x,T=r.embedding_model,O=void 0===T?"mxbai-embed-large-v1":T,A=c(a),R=A[0],N=A[1],_=c(!1),D=_[0],P=_[1],F=c(!1),I=F[0],B=F[1],j=c({}),U=j[0],W=j[1],$=c(null),q=$[0],G=$[1],Y=c(!1),K=Y[0],X=Y[1],Q=c(!1),J=Q[0],Z=Q[1],ee=c(null),te=ee[0],ne=ee[1],re=c(""),ae=re[0],oe=re[1],ce=c(!1),ie=ce[0],le=ce[1],se=c(!1),he=se[0],de=se[1],ue=c(!1),me=ue[0],pe=ue[1],ve=c(!1),fe=ve[0],ze=ve[1],ge=c(null),ye=ge[0],Me=ge[1],Ee=function(){N(!1),g()},be=c(null),He=be[0],Ve=be[1],Ce=c(null),Le=Ce[0],we=Ce[1],ke=c(""),xe=ke[0],Se=ke[1],Te=c(null),Oe=Te[0],Ae=Te[1],Re=c(null),Ne=Re[0],_e=Re[1],De=c(!1),Pe=De[0],Fe=De[1],Ie=function(e){Me(e)},Be=c(null),je=Be[0],Ue=Be[1],We=c(!1),$e=We[0],qe=We[1],Ge=function(e){console.log("[InstantLearning] 🟠 HANDLE MERGE LEARNING CALLED:",e),console.log("[InstantLearning] Setting mergeLearningTrigger to:",e),Ue(e),console.log("[InstantLearning] mergeLearningTrigger set successfully")};return s((function(){console.log("[InstantLearning] 🔶 mergeLearningTrigger changed:",je)}),[je]),s((function(){console.log("[InstantLearning] 🔄 resetLearningTrigger changed:",$e)}),[$e]),n(t,{children:e(a$,M({open:R,onClose:Ee,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{width:"95vw",height:"100vh",display:"flex",flexDirection:"column",margin:0,maxWidth:"100vw"}}},{children:[n(UP,M({"aria-label":"close",onClick:Ee,sx:{position:"absolute",right:8,top:8,zIndex:1,color:function(e){return e.palette.grey[500]}}},{children:n("svg",M({width:"28px",height:"28px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"#000000"},{children:n("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M8 8.707l3.646 3.647.708-.707L8.707 8l3.647-3.646-.707-.708L8 7.293 4.354 3.646l-.707.708L7.293 8l-3.646 3.646.707.708L8 8.707z"})}))})),e(p$,M({sx:{flex:1,overflow:"auto",display:"flex",flexDirection:"row",gap:2}},{children:[n(Yj,M({sx:{minWidth:"350px",maxWidth:"35%",bgcolor:"#f5f5f5",p:0,borderRadius:1,display:"flex",flexDirection:"column"}},{children:n(C7,{chatAssistantLogoUrl:v||"",chatAssistantName:d,organizationName:u,baseUrl:m,setInstantLearningSuggestions:W,formDataState:q,setFormDataState:G,hasUserFilledForm:I,setHasUserFilledForm:B,baseWebsocketUrl:p,setIsNewChatClicked:X,selectedText:o,ChatIconComponent:f,ggcAssistantName:z||"",ThinkingBulbIconComponent:y,hasUserWrittenModification:J,setExtractedModification:ne,setSave:le,setExtractedTooltip:oe,setIsSaveLoading:pe,isSaveLoading:me,save:ie,instantLearningSuggestions:U,template:b,setShouldTriggerSave:ze,validationWtaResponse:He,setValidationWtaResponse:Ve,learningWtaResponse:Le,setLearningWtaResponse:we,isFormSaveClicked:he,setIsFormSavedClicked:de,onDeleteLearning:Ie,deleteLearningTrigger:ye,setDeleteLearningTrigger:Me,onMergeLearning:Ge,mergeLearningTrigger:je,setMergeLearningTrigger:Ue,onResetLearningData:function(){console.log("[InstantLearning] 🔄 RESET CALLBACK TRIGGERED - Setting resetLearningTrigger to true"),qe(!0),setTimeout((function(){qe(!1),console.log("[InstantLearning] 🔄 resetLearningTrigger reset to false")}),100)},setEditConflictingLearningTrigger:Ae,setEditSimilarLearningTrigger:_e,sendMessageInChat:xe,setSendMessageInChat:Se,setIsMergeLoading:Fe})})),n(Yj,M({sx:{minWidth:"65%",maxWidth:"65%",display:"flex",flexDirection:"column"}},{children:n(lee,{organizationName:u,selectedText:o,scopeOptions:i||[],devModeTag:l||"",chatAssistantName:d,submitFunction:h,setShowChat:P,showChat:D,formDataState:q,setFormDataState:G,instantLearningSuggestions:U,setHasUserFilledForm:B,hasUserFilledForm:I,isNewChatClicked:K,setIsNewChatClicked:X,setHasUserWrittenModification:Z,extractedModification:te,save:ie,extractedTooltip:ae,isSaveLoading:me,shouldTriggerSave:fe,baseUrl:m,topic_table:V,variant_table:L,scope_table:k,embedding_column_name:S,embedding_model:O,validationWtaResponse:He,setValidationWtaResponse:Ve,learningWtaResponse:Le,setLearningWtaResponse:we,setIsFormSavedClicked:de,onDeleteLearning:Ie,onMergeLearning:Ge,mergeLearningTrigger:je,resetLearningTrigger:$e,editConflictingLearningTrigger:Oe,editSimilarLearningTrigger:Ne,setSendMessageInChat:Se,isMergeLoading:Pe,setIsMergeLoading:Fe})}))]}))]}))})},hee=function(t){var r=t.color,a=void 0===r?"#4338ca":r;return e("svg",M({xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 56 56",style:{verticalAlign:"middle"}},{children:[n("defs",{children:e("linearGradient",M({id:"sparkleGradient",x1:"0%",y1:"0%",x2:"100%",y2:"0%"},{children:[n("stop",{offset:"0%",stopColor:a}),n("stop",{offset:"100%",stopColor:a})]}))}),n("path",{fill:a,d:"M 26.6875 12.6602 C 26.9687 12.6602 27.1094 12.4961 27.1797 12.2383 C 27.9062 8.3242 27.8594 8.2305 31.9375 7.4570 C 32.2187 7.4102 32.3828 7.2461 32.3828 6.9648 C 32.3828 6.6836 32.2187 6.5195 31.9375 6.4726 C 27.8828 5.6524 28.0000 5.5586 27.1797 1.6914 C 27.1094 1.4336 26.9687 1.2695 26.6875 1.2695 C 26.4062 1.2695 26.2656 1.4336 26.1953 1.6914 C 25.3750 5.5586 25.5156 5.6524 21.4375 6.4726 C 21.1797 6.5195 20.9922 6.6836 20.9922 6.9648 C 20.9922 7.2461 21.1797 7.4102 21.4375 7.4570 C 25.5156 8.2774 25.4687 8.3242 26.1953 12.2383 C 26.2656 12.4961 26.4062 12.6602 26.6875 12.6602 Z M 15.3438 28.7852 C 15.7891 28.7852 16.0938 28.5039 16.1406 28.0821 C 16.9844 21.8242 17.1953 21.8242 23.6641 20.5821 C 24.0860 20.5117 24.3906 20.2305 24.3906 19.7852 C 24.3906 19.3633 24.0860 19.0586 23.6641 18.9883 C 17.1953 18.0977 16.9609 17.8867 16.1406 11.5117 C 16.0938 11.0899 15.7891 10.7852 15.3438 10.7852 C 14.9219 10.7852 14.6172 11.0899 14.5703 11.5352 C 13.7969 17.8164 13.4687 17.7930 7.0469 18.9883 C 6.6250 19.0821 6.3203 19.3633 6.3203 19.7852 C 6.3203 20.2539 6.6250 20.5117 7.1406 20.5821 C 13.5156 21.6133 13.7969 21.7774 14.5703 28.0352 C 14.6172 28.5039 14.9219 28.7852 15.3438 28.7852 Z M 31.2344 54.7305 C 31.8438 54.7305 32.2891 54.2852 32.4062 53.6524 C 34.0703 40.8086 35.8750 38.8633 48.5781 37.4570 C 49.2344 37.3867 49.6797 36.8945 49.6797 36.2852 C 49.6797 35.6758 49.2344 35.2070 48.5781 35.1133 C 35.8750 33.7070 34.0703 31.7617 32.4062 18.9180 C 32.2891 18.2852 31.8438 17.8633 31.2344 17.8633 C 30.6250 17.8633 30.1797 18.2852 30.0860 18.9180 C 28.4219 31.7617 26.5938 33.7070 13.9140 35.1133 C 13.2344 35.2070 12.7891 35.6758 12.7891 36.2852 C 12.7891 36.8945 13.2344 37.3867 13.9140 37.4570 C 26.5703 39.1211 28.3281 40.8321 30.0860 53.6524 C 30.1797 54.2852 30.6250 54.7305 31.2344 54.7305 Z"})]}))};function dee(e,t){void 0===t&&(t=500);var n=c(e),r=n[0],a=n[1];return s((function(){var n=setTimeout((function(){a(e)}),t);return function(){clearTimeout(n)}}),[e,t]),r}var uee={"Azure OpenAI":["gpt-4o","gpt-4o-2024-08-06"],"VertexAI Anthropic":["claude-3.5-sonnet","claude-3-sonnet","claude-3-haiku","claude-3.5-haiku","claude-3.7-sonnet","claude-4-sonnet"],"Google VertexAI":["gemini-2.0-flash","gemini-2.5-flash-lite","gemini-2.5-pro","gemini-2.5-flash","gemini-1.5-pro","gemini-1.0-pro-002","gemini-1.0-pro","gemini-1.5-pro-001","gemini-1.5-pro-002","gemini-1.5-flash-001","gemini-1.5-flash-002"]},mee=function(r){var o,l=r.formState,h=r.setFormState,d=r.config,u=r.isLoadingSuggestions,m=r.onSave,p=r.isSaving,v=r.modelProvider,f=r.setModelProvider,z=r.modelName,g=r.setModelName,y=r.isCheckingExisting,E=r.suggestedFixes,b=r.onRejectFix,H=r.onAcceptFix,C=r.isFixing,L=r.isValidDb,w=r.isFormDirty,k=r.isSaveButtonDisabled,x=r.onValidate;r.validationResponse,r.onFixConflicts;var S=r.formCommand,T=r.setFormCommand,O=r.className,A=r.showValidateButton,R=c(!1),N=R[0],_=R[1],D=c(l),P=D[0],F=D[1],I=c({}),B=I[0],j=I[1],U=c({}),W=U[0],$=U[1],q=c(null),G=q[0],Y=q[1],K=dee(P,2500),X=i(null),Q=i(!1),J=function(t,r){if(C)return e(Yj,M({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",p:2,textAlign:"center",mt:2}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5,color:"#4338ca",mb:1}},{children:[n(SW,{size:20,color:"inherit"}),e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{})," AI fixing Rules...."]}))]})),n(iF,M({sx:{fontSize:"0.9rem",color:"#6b7280",fontFamily:"'Inter', sans-serif",mb:4}},{children:"Our AI is analyzing your requirements and creating new suggestions"})),e(iF,M({sx:{fontSize:"0.85rem",color:"#9ca3af",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:"4px","@keyframes bounce":{"0%, 60%, 100%":{transform:"translateY(0)"},"30%":{transform:"translateY(-8px)"}},"& span":{display:"inline-block",animation:"bounce 1.4s infinite"},"& span:nth-of-type(1)":{animationDelay:"0s"},"& span:nth-of-type(2)":{animationDelay:"0.2s"},"& span:nth-of-type(3)":{animationDelay:"0.4s"}}},{children:[n("span",{children:"●"}),n("span",{children:"●"}),n("span",{children:"●"}),"Please wait..."]}))]}));var a=t[0];return a?e(Yj,M({sx:{mt:2,p:2,border:"1px dashed #6366f1",borderRadius:"8px",backgroundColor:"#f5f3ff"}},{children:[e(Yj,M({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:1.5}},{children:[e(iF,M({variant:"subtitle2",sx:{fontWeight:600,color:"#4338ca",display:"flex",alignItems:"center",gap:1}},{children:[n(hee,{}),"AI Suggestions"]})),e(Yj,M({sx:{display:"flex",alignItems:"center",gap:.5}},{children:[void 0!==a.score&&n(LJ,M({title:"AI Confidence Score",arrow:!0},{children:Z(a.score)})),n(LJ,M({title:"Reject this suggestion"},{children:n(UP,M({size:"small",onClick:function(){return b(r,0)},sx:{color:"#ef4444"}},{children:n(d7,{size:18})}))})),n(LJ,M({title:"Replace all current rules with this one"},{children:n(UP,M({size:"small",onClick:function(){return H(r,a)},sx:{color:"#16a34a"}},{children:n(e7,{size:18})}))}))]}))]})),n(qD,M({elevation:0,sx:{p:"12px 16px",backgroundColor:"#fff",borderRadius:"8px",border:"1px solid #e0e0e0"}},{children:n(iF,M({sx:{fontSize:"15px",color:"#1f2937",lineHeight:1.6}},{children:a.text}))})),a.reason&&e(nP,M({expanded:W["".concat(r,"-").concat(0)]||!1,onChange:function(){return function(e,t){var n="".concat(e,"-").concat(t);$((function(e){var t;return M(M({},e),((t={})[n]=!e[n],t))}))}(r,0)},disableGutters:!0,elevation:0,sx:{border:"1px solid #c7d2fe",borderRadius:"8px",overflow:"hidden",mt:1.5,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#4f46e5"}),sx:{backgroundColor:"#eef2ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #c7d2fe",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.85rem",fontWeight:600,color:"#4338ca",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:14}),"Reasoning"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#fdfdff"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:a.reason}))}))]}))]})):null};s((function(){if(!N){F(l);var e={wta:l.wta.map((function(e){return{text:e.text}})),wnta:l.wnta.map((function(e){return{text:e.text}}))};X.current=JSON.stringify(e)}}),[l,N]),s((function(){if(Q.current)Q.current=!1;else if(!(G&&G.wta.length>0&&0===K.wta.length)){if(G){var e=K.wta.length-G.wta.length;if(e>0)if(K.wta.slice(-e).every((function(e){return""===e.text.trim()})))return;var t=K.wnta.length-G.wnta.length;if(t>0)if(K.wnta.slice(-t).every((function(e){return""===e.text.trim()})))return}var n={wta:K.wta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}})),wnta:K.wnta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}}))},r=JSON.stringify(n);N&&!p&&G&&r!==JSON.stringify(G)&&r!==X.current&&(x(K,z),X.current=r,console.log("Debounced validation useEffect triggered",{isEditing:N,isSaving:p,initialEditState:G,debouncedTempFormState:K,lastValidatedStateRef:X.current}))}}),[K,N,p,G,z,x]);s((function(){if("SYNC_SNAPSHOT"===S){var e={wta:l.wta.map((function(e){return{text:e.text}})),wnta:l.wnta.map((function(e){return{text:e.text}}))};X.current=JSON.stringify(e),T(null)}}),[S,l,T]);var Z=function(t){var r,a,o;return t>70?(r="#e9f5ea",a="#34a853",o="#34a853"):t>50?(r="#feefc3",a="#f9ab00",o="#f9ab00"):(r="#fbe9e7",a="#d93025",o="#d93025"),e(Yj,M({sx:{backgroundColor:r,color:a,borderRadius:"14px",padding:"4px 12px",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,fontSize:"12px",fontFamily:"'Inter', sans-serif",gap:"2px"}},{children:[n(hee,{color:o})," ",t.toFixed(1),"%"]}))},ee=function(t,r){return e(Yj,u?M({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",p:2,textAlign:"center"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5,color:"#4338ca",mb:1}},{children:[n(SW,{size:20,color:"inherit"}),e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{})," Generating AI Suggestions..."]}))]})),n(iF,M({sx:{fontSize:"0.9rem",color:"#6b7280",fontFamily:"'Inter', sans-serif",mb:4}},{children:"Our AI is analyzing your requirements and creating personalized suggestions"})),e(iF,M({sx:{fontSize:"0.85rem",color:"#9ca3af",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:"4px","@keyframes bounce":{"0%, 60%, 100%":{transform:"translateY(0)"},"30%":{transform:"translateY(-8px)"}},"& span":{display:"inline-block",animation:"bounce 1.4s infinite"},"& span:nth-of-type(1)":{animationDelay:"0s"},"& span:nth-of-type(2)":{animationDelay:"0.2s"},"& span:nth-of-type(3)":{animationDelay:"0.4s"}}},{children:[n("span",{children:"●"}),n("span",{children:"●"}),n("span",{children:"●"}),"Please wait..."]}))]}):y?M({sx:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",flex:1,backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",p:2,textAlign:"center"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5,color:"#4338ca",mb:1}},{children:[n(SW,{size:20,color:"inherit"}),e(iF,M({sx:{fontSize:"1rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{})," Checking for existing rules..."]}))]})),n(iF,M({sx:{fontSize:"0.9rem",color:"#6b7280",fontFamily:"'Inter', sans-serif",mb:4}},{children:"Comparing rules with other agents in the database."})),e(iF,M({sx:{fontSize:"0.85rem",color:"#9ca3af",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:"4px","@keyframes bounce":{"0%, 60%, 100%":{transform:"translateY(0)"},"30%":{transform:"translateY(-8px)"}},"& span":{display:"inline-block",animation:"bounce 1.4s infinite"},"& span:nth-of-type(1)":{animationDelay:"0s"},"& span:nth-of-type(2)":{animationDelay:"0.2s"},"& span:nth-of-type(3)":{animationDelay:"0.4s"}}},{children:[n("span",{children:"●"}),n("span",{children:"●"}),n("span",{children:"●"}),"Please wait..."]}))]}):M({sx:{backgroundColor:"#f9fafb",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"16px",display:"flex",flexDirection:"column",flex:1,opacity:p?.6:1,pointerEvents:p?"none":"auto"}},{children:[n(Yj,M({sx:{display:"flex",flexDirection:"column",gap:2,flex:1}},{children:t.length>0?t.map((function(t,o){return e(a.Fragment,{children:[e(Yj,M({sx:{backgroundColor:"#ffffff",borderRadius:"8px",border:"1px solid #e5e7eb",padding:"8px 12px",display:"flex",alignItems:"center",gap:2}},{children:[e(iF,M({sx:{fontSize:"15px",fontWeight:500,color:"#6b7280"}},{children:[o+1,"."]})),N?n(j2,{value:t.text,onChange:function(e){return function(e,t,n){F((function(r){var a,o=V([],r[e],!0);return o[t]=M(M({},o[t]),{text:n}),M(M({},r),((a={})[e]=o,a))}))}(r,o,e.target.value)},variant:"standard",multiline:!0,placeholder:"Enter a rule...",disabled:p,InputProps:{disableUnderline:!0},sx:{flex:1,fontSize:"15px"}}):n(iF,M({sx:{fontSize:"15px",color:"#1f2937",flex:1,lineHeight:1.5,wordBreak:"break-word"}},{children:t.text})),void 0!==t.score&&n(LJ,M({title:"AI Confidence Score",arrow:!0},{children:Z(t.score)})),N&&n(UP,M({size:"small",onClick:function(){return function(e,t){F((function(n){var r;return M(M({},n),((r={})[e]=n[e].filter((function(e,n){return n!==t})),r))}))}(r,o)},disabled:p,sx:{color:"#9ca3af","&:hover":{color:"#ef4444"}}},{children:n(d7,{size:16})}))]})),t.reason&&!N&&e(nP,M({expanded:B["".concat(r,"-").concat(o)]||!1,onChange:function(){return function(e,t){var n="".concat(e,"-").concat(t);j((function(e){var t;return M(M({},e),((t={})[n]=!e[n],t))}))}(r,o)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.85rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:16})," ","wta"===r?"Reason behind When To Apply":"Reason behind When Not To Apply"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#ffffff"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:t.reason}))}))]}))]},o)})):n(Yj,M({sx:{flex:1,display:"flex",alignItems:"center",justifyContent:"center"}},{children:!N&&n(iF,M({sx:{color:"#9ca3af",textAlign:"center"}},{children:"No rules defined."}))}))})),N&&n(zU,M({startIcon:n(c7,{size:16}),onClick:function(){return function(e){F((function(t){var n;return M(M({},t),((n={})[e]=V(V([],t[e],!0),[{text:""}],!1),n))}))}(r)},disabled:p,sx:{color:"#6366f1",fontSize:"15px",fontWeight:500,textTransform:"none",mt:t.length>0?2:0,alignSelf:"flex-start"}},{children:"Add Rule"}))]}))};return e(qD,M({elevation:3,className:O,sx:{padding:"24px",width:"100%",maxWidth:"1050px",margin:"20px",boxSizing:"border-box",borderRadius:"12px",position:"relative"}},{children:[e(Yj,M({sx:{display:"flex",justifyContent:"space-between",alignItems:"center",mb:3}},{children:[n(Yj,{children:e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1.5}},{children:[n(iF,M({variant:"h5",component:"h2",gutterBottom:!0,sx:{display:"flex",fontWeight:"600",alignItems:"center",gap:1.5,fontFamily:"'Inter', sans-serif",mb:0}},{children:d.mainTitle})),n(LJ,M({title:d.mainTitleTooltip,arrow:!0,slotProps:{tooltip:{sx:{fontSize:"0.8rem",padding:"0.5rem",fontFamily:"'Inter', sans-serif"}}}},{children:n(n7,{size:13,color:"#494d55ff",style:{cursor:"pointer"}})})),e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5}},{children:[n(hee,{}),n(Yj,M({component:"span",sx:{fontWeight:600,fontSize:"1rem",background:"linear-gradient(90deg, #6a11cb 0%, #2575fc 100%)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",display:"inline-block"}},{children:"AI Suggested"}))]}))]}))}),e(Yj,M({sx:{display:"flex",gap:2}},{children:[e(tq,M({size:"small",sx:{minWidth:180}},{children:[n(kG,{children:"Model Provider"}),n(iQ,M({value:v,label:"Model Provider",onChange:function(e){var t=e.target.value;f(t),g(uee[t][0])}},{children:Object.keys(uee).map((function(e){return n(dK,M({value:e},{children:e}),e)}))}))]})),e(tq,M({size:"small",sx:{minWidth:180}},{children:[n(kG,{children:"Model Name"}),n(iQ,M({value:z,label:"Model Name",onChange:function(e){g(e.target.value)}},{children:null===(o=uee[v])||void 0===o?void 0:o.map((function(e){return n(dK,M({value:e},{children:e}),e)}))}))]}))]}))]})),e(Yj,M({sx:{display:"flex",gap:"24px",alignItems:"stretch"}},{children:[e(Yj,M({sx:{flex:1,backgroundColor:"#ffffff",display:"flex",flexDirection:"column"}},{children:[e(iF,M({variant:"subtitle1",sx:{fontWeight:600,marginBottom:"12px",color:"#1f2937",fontSize:"16px",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center"}},{children:["When to Apply ",n("span",M({style:{color:"red",marginRight:"8px"}},{children:"*"})),n(LJ,M({title:d.wtaTooltip,arrow:!0,slotProps:{tooltip:{sx:{fontSize:"0.8rem",padding:"0.5rem",fontFamily:"'Inter', sans-serif"}}}},{children:n(n7,{size:13,color:"#494d55ff",style:{cursor:"pointer"}})}))]})),ee(N?P.wta:l.wta,"wta"),!N&&J(E.wta,"wta")]})),e(Yj,M({sx:{flex:1,backgroundColor:"#ffffff",display:"flex",flexDirection:"column"}},{children:[e(iF,M({variant:"subtitle1",sx:{fontWeight:600,marginBottom:"12px",color:"#1f2937",fontSize:"16px",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center"}},{children:["When Not To Apply",n(LJ,M({title:d.wntaTooltip,arrow:!0,slotProps:{tooltip:{sx:{fontSize:"0.8rem",padding:"0.5rem",fontFamily:"'Inter', sans-serif"}}}},{children:n(n7,{size:13,color:"#494d55ff",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),ee(N?P.wnta:l.wnta,"wnta"),!N&&J(E.wnta,"wnta")]}))]})),n(Yj,M({sx:{display:"flex",justifyContent:"flex-end",mt:3}},{children:e(t,N?{children:[n(zU,M({onClick:function(){Q.current=!1,F(l),_(!1),Y(null),X.current=null},variant:"outlined",disabled:p,sx:{marginRight:"8px",borderColor:"#6b7280",color:"#6b7280",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#f9fafb",borderColor:"#4b5563"}}},{children:"Cancel"})),n(zU,M({onClick:function(){Q.current=!1;var e={wta:P.wta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}})),wnta:P.wnta.filter((function(e){return""!==e.text.trim()})).map((function(e){return{text:e.text}}))},t=JSON.stringify(e);t!==X.current&&(console.log("State changed on confirm, triggering immediate validation."),x(e,z),X.current=t),h(e),_(!1),Y(null)},disabled:p,variant:"contained",sx:{backgroundColor:"#4f46e5",color:"white",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#4338ca"}}},{children:"Confirm"}))]}:{children:[n(zU,M({onClick:function(){Q.current=!0,F(l);var e={wta:l.wta.map((function(e){return{text:e.text}})),wnta:l.wnta.map((function(e){return{text:e.text}}))};Y(e),_(!0)},variant:"outlined",disabled:u||p||y,startIcon:n(i7,{size:16}),sx:{marginRight:"8px",borderColor:"#6b7280",color:"#6b7280",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#f9fafb",borderColor:"#4b5563"}}},{children:"Edit"})),A&&n(zU,M({variant:"contained",onClick:function(){return m(l)},disabled:k,sx:{backgroundColor:"#4f46e5",color:"white",textTransform:"none",fontWeight:500,borderRadius:"8px",padding:"6px 16px",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#4338ca"}}},{children:p?"Validating...":L&&!w?"Save":"Validate"}))]})}))]}))},pee=function(t){var r=function(e){return Math.round(Math.min(e,100))}(t.score),a={bg:"#f2f0f2",text:"#343f52"};return n(LJ,M({title:"AI Confidence Score",placement:"top",arrow:!0},{children:e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,mr:1,py:.5,borderRadius:"16px",backgroundColor:a.bg,color:a.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{color:a.text}),e(iF,M({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[r,"%"]}))]}))}))},vee=function(t){var r,a,o=t.validationResponse,i=t.onFixConflicts,l=t.className,s=V(V([],(null===(r=o.cross_validation)||void 0===r?void 0:r.map((function(e){return M(M({},e),{type:"Cross-Validation"})})))||[],!0),(null===(a=o.duplication)||void 0===a?void 0:a.map((function(e){var t={reason:e.reason,confidence_score:e.confidence_score,type:"Duplication"},n=e.duplicate_conditions.join("\n");return"wta"===e.type?(t.condition_wta=n,t.type="Duplication (When to Apply)"):(t.condition_wnta=n,t.type="Duplication (When Not to Apply)"),t})))||[],!0),h=c(!1),d=h[0],u=h[1],m=c(s.map((function(e,t){return t}))),p=m[0],v=m[1],f=c({}),z=f[0],g=f[1];if(o.is_valid)return null;var y=function(e){return String.fromCharCode(65+e)};return e(qD,M({elevation:0,className:l,sx:{width:"100%",maxWidth:"1050px",margin:"20px auto",backgroundColor:"#FFFFFF",border:"1px solid #b3b3b3ff",padding:3,borderRadius:"12px",fontFamily:"'Inter', sans-serif"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontSize:"1.1rem",fontWeight:700,color:"#B91C1C"}},{children:"Validation Failed: Conflicts Found"})),n(LJ,M({slotProps:{tooltip:{sx:{fontSize:"0.9rem"}}},title:"The rules you've defined have logical conflicts. Please review and resolve them below.",arrow:!0},{children:n(n7,{size:16,color:"#B91C1C",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),o.correctness&&e(nP,M({expanded:d,onChange:function(){return u(!d)},disableGutters:!0,elevation:0,sx:{backgroundColor:"transparent",border:"1px solid #FCD34D",borderRadius:2,mb:2,"&::before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:20,color:"#92400E"}),sx:{backgroundColor:"#fef9f2",borderRadius:d?"8px 8px 0 0":2}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",gap:1}},{children:[n(tee,{style:{color:"#bb7601",fontSize:"1.2rem"}}),n(iF,M({sx:{fontSize:"0.95rem",fontWeight:600,color:"#bb7601"}},{children:"Why Validation Failed?"}))]})),n(pee,{score:o.correctness.confidence_score})]}))})),n(hP,M({sx:{p:1.5,backgroundColor:"#fcf8efff"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#bb7601"}},{children:o.correctness.reason}))}))]})),n(Yj,M({sx:{maxHeight:400,overflowY:"auto",pr:1.5}},{children:s.map((function(t,r){var a,o,c=p.includes(r),i=!!t.condition_wta,l=!!t.condition_wnta;return e(nP,M({expanded:c,onChange:function(){return function(e){v((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(r)},disableGutters:!0,sx:{mb:1.5,border:"1px solid #FCA5A5",borderRadius:"3px","&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:20,color:"#991B1B"}),sx:{backgroundColor:"#FEF2F2",borderBottom:c?"1px solid #FCA5A5":"none"}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[n(iF,M({sx:{color:"#991B1B",fontWeight:600,fontSize:"0.95rem"}},{children:"".concat(y(r),". ").concat(t.type," Conflict")})),n(pee,{score:t.confidence_score})]}))})),e(hP,M({sx:{px:2,pb:2,backgroundColor:"#FFF"}},{children:[e(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:i&&l?"row":"column"},gap:2,mb:2}},{children:[i&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:null===(a=t.condition_wta)||void 0===a?void 0:a.split("\n").map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]})),l&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When NOT to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:null===(o=t.condition_wnta)||void 0===o?void 0:o.split("\n").map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]}))]})),e(nP,M({expanded:z[r]||!1,onChange:function(){return function(e){g((function(t){var n;return M(M({},t),((n={})[e]=!t[e],n))}))}(r)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.9rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:16})," Reason behind validation failure?"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#f9fafb"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:t.reason}))}))]}))]}))]}),r)}))})),n(Yj,M({sx:{display:"flex",justifyContent:"flex-end",mt:2}},{children:n(zU,M({variant:"contained",onClick:i,startIcon:n(h7,{size:20}),sx:{backgroundColor:"transparent",textTransform:"none",fontWeight:600,border:"1px solid #838383ff",color:"#4a4a4aff",fontFamily:"'Inter', sans-serif","&:hover":{backgroundColor:"#f4f4f4ff"}}},{children:"Auto Fix Conflicts"}))}))]}))},fee=function(t){var r=function(e){return Math.round(Math.min(e,100))}(t.score),a={bg:"#f2f0f2",text:"#343f52"};return n(LJ,M({title:"AI Confidence Score",placement:"top",arrow:!0},{children:e(Yj,M({sx:{display:"inline-flex",alignItems:"center",gap:.5,px:1,mr:1,py:.5,borderRadius:"16px",backgroundColor:a.bg,color:a.text,fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[n(hee,{color:a.text}),e(iF,M({sx:{fontSize:"0.8rem",fontWeight:600,fontFamily:"'Inter', sans-serif"}},{children:[r,"%"]}))]}))}))},zee=function(t){var r=t.similarRules,a=t.showUpdateWarning,o=t.className,i=c(r.map((function(e,t){return t}))),l=i[0],s=i[1],h=c({}),d=h[0],u=h[1];if(!r||0===r.length)return null;var m=function(e){return String.fromCharCode(65+e)};return e(qD,M({elevation:0,className:o,sx:{width:"100%",maxWidth:"1050px",margin:"20px auto",backgroundColor:"#FFFFFF",border:"1px solid #b3b3b3ff",padding:3,borderRadius:"12px",fontFamily:"'Inter', sans-serif"}},{children:[e(Yj,M({sx:{display:"flex",alignItems:"center",mb:2}},{children:[n(iF,M({sx:{fontSize:"1.1rem",fontWeight:700,color:"#B91C1C"}},{children:"Similar Rules Detected"})),n(LJ,M({slotProps:{tooltip:{sx:{fontSize:"0.9rem"}}},title:"The rules you've defined are similar to existing rules in other agents. Please review them to avoid redundancy.",arrow:!0},{children:n(n7,{size:16,color:"#B91C1C",style:{marginLeft:"8px",cursor:"pointer"}})}))]})),n(Yj,M({sx:{maxHeight:400,overflowY:"auto",pr:1.5}},{children:r.map((function(t,r){var a=l.includes(r),o=t.wtaRules&&t.wtaRules.length>0,c=t.wntaRules&&t.wntaRules.length>0;return e(nP,M({expanded:a,onChange:function(){return function(e){s((function(t){return t.includes(e)?t.filter((function(t){return t!==e})):V(V([],t,!0),[e],!1)}))}(r)},disableGutters:!0,sx:{mb:1.5,border:"1px solid #FCA5A5",borderRadius:"3px","&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:20,color:"#991B1B"}),sx:{backgroundColor:"#FEF2F2",borderBottom:a?"1px solid #FCA5A5":"none"}},{children:e(Yj,M({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},{children:[n(iF,M({sx:{color:"#991B1B",fontWeight:600,fontSize:"0.95rem"}},{children:"".concat(m(r),". ").concat(t.agentName," has a similar rule")})),n(fee,{score:t.confidenceScore})]}))})),e(hP,M({sx:{px:2,pb:2,backgroundColor:"#FFF"}},{children:[e(Yj,M({sx:{display:"flex",flexDirection:{xs:"column",sm:o&&c?"row":"column"},gap:2,mb:2}},{children:[o&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:t.wtaRules.map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]})),c&&e(Yj,M({sx:{flex:1,border:"1px solid #E5E7EB",borderRadius:2,p:2,backgroundColor:"#F9FAFB"}},{children:[n(iF,M({sx:{fontWeight:600,mb:1,color:"#374151"}},{children:"When NOT to Apply"})),n(iF,M({sx:{whiteSpace:"pre-wrap",color:"#4B5563"}},{children:t.wntaRules.map((function(e,t){return"".concat(t+1,". ").concat(e)})).join("\n")}))]}))]})),e(nP,M({expanded:d[r]||!1,onChange:function(){return function(e){u((function(t){var n;return M(M({},t),((n={})[e]=!t[e],n))}))}(r)},disableGutters:!0,elevation:0,sx:{border:"1px solid #e5e7eb",borderRadius:"8px",overflow:"hidden",mt:1,"&:before":{display:"none"}}},{children:[n(_P,M({expandIcon:n(t7,{size:16,color:"#6b7280"}),sx:{backgroundColor:"#f2f2f3ff",minHeight:"auto","&.Mui-expanded":{borderBottom:"1px solid #e5e7eb",minHeight:"auto"},"& .MuiAccordionSummary-content":{margin:"10px 0px"}}},{children:e(iF,M({sx:{fontSize:"0.9rem",fontWeight:600,color:"#4b5563",fontFamily:"'Inter', sans-serif",display:"flex",alignItems:"center",gap:1}},{children:[n(r7,{size:16})," Reason for Similarity?"]}))})),n(hP,M({sx:{p:2,backgroundColor:"#f9fafb"}},{children:n(iF,M({sx:{fontSize:"0.9rem",color:"#374151",fontFamily:"'Inter', sans-serif",lineHeight:1.6}},{children:t.reason}))}))]}))]}))]}),r)}))})),a&&n(Yj,M({sx:{mt:3,p:1.5,borderRadius:"8px",backgroundColor:"#FFFBEB",border:"1px solid #FCD34D"}},{children:e(iF,M({sx:{color:"#B45309",fontSize:"0.9rem",fontWeight:500,fontFamily:"'Inter', sans-serif"}},{children:[n("strong",{children:"Warning:"})," Please update the current rules since there already exists a similar rule."]}))}))]}))},gee="WtaWnta-module_parentContainer__-2Txc";C('@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400..900&display=swap");body{font-family:Inter,sans-serif}.WtaWnta-module_parentContainer__-2Txc{align-items:center;display:flex;flex-direction:column;gap:24px;width:100%}');var yee={"agent-genie":{mainTitle:"Set Agent Rules",mainTitleTooltip:"Assistant would use these rules or conditions to call your agent.",wtaTitle:"When to Apply",wtaTooltip:"Specific rules or conditions where the agent must be called",wntaTitle:"When Not To Apply",wntaTooltip:"Specific rules or conditions where the agent should never be called."},"prompt-genie":{mainTitle:"Set Template Rules",mainTitleTooltip:"Set rules or conditions to get best response from the system prompt",wtaTitle:"When to Apply",wtaTooltip:"Specific rules or conditions where the template must be used",wntaTitle:"When Not To Apply",wntaTooltip:"Specific rules or conditions where the template must not be used"},"coding-standards":{mainTitle:"Set Coding Standards",mainTitleTooltip:"The assistant will enforce these coding standards.",wtaTitle:"Must Have",wtaTooltip:"Essential coding standards that must be followed.",wntaTitle:"Must Not Have",wntaTooltip:"Coding practices that should be avoided."}},Mee=function(t){var r,a=t.classNames,o=void 0===a?{}:a,i=yee[t.mode],h=function(){return"agent-genie"===t.mode&&(t.wta||t.wnta)?{wta:(t.wta||[]).map((function(e){return{text:e}})),wnta:(t.wnta||[]).map((function(e){return{text:e}}))}:{wta:[],wnta:[]}},d=c(h),u=d[0],m=d[1],p=c(h),v=p[0],f=p[1],z=c({wta:[],wnta:[]}),g=z[0],y=z[1],E=c(0),V=E[0];E[1];var C=c(!0),L=C[0],w=C[1],k=c("Google VertexAI"),x=k[0],S=k[1],T=c("gemini-2.5-flash-lite"),O=T[0],A=T[1],R=c(null),N=R[0],_=R[1],D="agent-genie"===t.mode?t:{},P=D.agent_context,F=void 0===P?"":P,I=D.agent_description,B=void 0===I?"":I,j=D.agent_id,U=void 0===j?null:j,W=D.assistant_name,$=void 0===W?"":W,q=D.organization_name,G=void 0===q?"":q,Y=D.base_url,K=void 0===Y?"":Y,X=D.wta,Q=void 0===X?[]:X,J=D.wnta,Z=void 0===J?[]:J,ee="agent-genie"===t.mode&&0===Q.length&&0===Z.length,te="prompt-genie"===t.mode?t:{},ne=te.template_context,re=void 0===ne?"":ne,ae=te.template_description,oe=void 0===ae?"":ae,ce=te.baseUrl,ie=void 0===ce?"":ce,le=function(e,t,n,r,a,o){void 0===a&&(a=!0);var i=c([]),l=i[0],h=i[1],d=c(!1),u=d[0],m=d[1],p=c(null),v=p[0],f=p[1],z=dee(e,500),g=dee(t,500);return s((function(){g&&a?b(void 0,void 0,void 0,(function(){var e,t,n,a,c,i,l;return H(this,(function(s){switch(s.label){case 0:console.log("[".concat((new Date).toLocaleTimeString(),"] Attempting to fetch suggestions...")),m(!0),f(null),s.label=1;case 1:return s.trys.push([1,4,5,6]),e={agent_context:z,agent_description:g,mode:"AgentGenie",llm:r,n:1},console.log("API Payload:",e),[4,fetch("".concat(o,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 2:if(!(t=s.sent()).ok)throw new Error("API Error: ".concat(t.statusText));return[4,t.json()];case 3:return n=s.sent(),a=[],null===(i=n.response.conditions_whentoapply)||void 0===i||i.forEach((function(e){a.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(l=n.response.conditions_whennottoapply)||void 0===l||l.forEach((function(e){a.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),h(a),[3,6];case 4:return c=s.sent(),console.error("Failed to fetch suggestions:",c),f(c),[3,6];case 5:return m(!1),[7];case 6:return[2]}}))})):h([])}),[z,g,n,a]),{suggestions:l,isLoading:u,error:v}}(F,B,V,O,ee,K),se=le.suggestions,he=le.isLoading,de=le.error,ue=function(e,t,n,r,a,o){void 0===a&&(a=!0);var i=c([]),l=i[0],h=i[1],d=c(!1),u=d[0],m=d[1],p=c(null),v=p[0],f=p[1],z=dee(e,500),g=dee(t,500);return s((function(){z&&g&&a?b(void 0,void 0,void 0,(function(){var e,t,n,a,c,i,l;return H(this,(function(s){switch(s.label){case 0:m(!0),f(null),s.label=1;case 1:return s.trys.push([1,4,5,6]),e={template_context:z,template_description:g,mode:"PromptGenie",llm:r,n:1},[4,fetch("".concat(o,"/instant_learning/mode-wta-suggestion"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})];case 2:if(!(t=s.sent()).ok)throw new Error("API Error: ".concat(t.statusText));return[4,t.json()];case 3:return n=s.sent(),a=[],null===(i=n.response.conditions_whentoapply)||void 0===i||i.forEach((function(e){a.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(l=n.response.conditions_whennottoapply)||void 0===l||l.forEach((function(e){a.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),h(a),[3,6];case 4:return c=s.sent(),console.error("Failed to fetch prompt suggestions:",c),f(c),[3,6];case 5:return m(!1),[7];case 6:return[2]}}))})):h([])}),[z,g,n,a]),{suggestions:l,isLoading:u,error:v}}(re,oe,V,O,"prompt-genie"===t.mode,ie),me=ue.suggestions,pe=ue.isLoading,ve=function(e,t,n){var r=c(!1),a=r[0],o=r[1],i=c(null),s=i[0],h=i[1],d=c(null),u=d[0],m=d[1],p=l((function(r,a){return b(void 0,void 0,void 0,(function(){var c,i,l,s;return H(this,(function(d){switch(d.label){case 0:if(o(!0),h(null),m(null),0===(c={agent_context:e,agent_description:t,mode:"AgentGenie",llm:a,wta:r.wta.map((function(e){return e.text})),wnta:r.wnta.map((function(e){return e.text}))}).wta.length)return console.error("WTA conditions cannot be empty."),o(!1),[2,null];d.label=1;case 1:return d.trys.push([1,4,5,6]),[4,fetch("".concat(n,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(i=d.sent()).ok)throw new Error("API Error: ".concat(i.statusText));return[4,i.json()];case 3:return(l=d.sent()).response.is_valid?(console.log("Validation Successful!"),h(null)):(console.warn("Validation failed, conflicts found."),h(l.response)),[2,l.response];case 4:return s=d.sent(),console.error("Failed to validate rules:",s),m(s),[2,null];case 5:return o(!1),[7];case 6:return[2]}}))}))}),[e,t,n]);return{validateAgentRules:p,clearValidation:function(){h(null)},isSaving:a,validationResponse:s,error:u}}(F,B,K),fe=ve.validateAgentRules,ze=ve.clearValidation,ge=ve.isSaving,ye=ve.validationResponse,Me=ve.error,Ee=function(e,t,n,r){void 0===n&&(n=!0);var a=c(!1),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1],d=c(null),u=d[0],m=d[1];return{validateRules:function(a,o){return b(void 0,void 0,void 0,(function(){var c,l,s,d;return H(this,(function(u){switch(u.label){case 0:if(!n)return[2,null];if(i(!0),h(null),m(null),0===(c={template_context:e,template_description:t,wta:a.wta.map((function(e){return e.text})),wnta:a.wnta.map((function(e){return e.text})),mode:"PromptGenie",llm_model:o}).wta.length)return console.error("WTA conditions cannot be empty."),m(new Error("When to Apply conditions cannot be empty.")),i(!1),[2,null];u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,fetch("".concat(r,"/instant_learning/mode-wta-validation"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(l=u.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(s=u.sent()).response.is_valid?(console.log("Prompt Validation Successful!"),h(null)):(console.warn("Prompt Validation failed, conflicts found."),h(s.response)),[2,s.response];case 4:return d=u.sent(),console.error("Failed to validate prompt rules:",d),m(d),[2,null];case 5:return i(!1),[7];case 6:return[2]}}))}))},clearValidation:function(){h(null)},isSaving:o,validationResponse:s,error:u}}(re,oe,"prompt-genie"===t.mode,ie),be=Ee.validateRules,He=Ee.clearValidation,Ve=Ee.isSaving,Ce=Ee.validationResponse,Le=function(e){var t=c(!1),n=t[0],r=t[1],a=c(null),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1];return{checkExistingRules:function(t,n,a,o){return b(void 0,void 0,void 0,(function(){var c,l,s,d;return H(this,(function(u){switch(u.label){case 0:r(!0),h(null),i(null),c={mode:"AgentGenie",assistantname:a,organizationname:o,wta:t.wta.map((function(e){return e.text})),wnta:t.wnta.map((function(e){return e.text})),agent_id:n},console.log("Checking for existing DB conflicts with payload:",c),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,fetch("".concat(e,"/instant_learning/mode-wta-existing"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)})];case 2:if(!(l=u.sent()).ok)throw new Error("API Error: ".concat(l.statusText));return[4,l.json()];case 3:return(s=u.sent()).response?(console.log("DB check successful. Setting state with:",s.response),i(s.response)):(console.error("DB check: API response object was missing."),i(null)),[3,6];case 4:return d=u.sent(),console.error("Failed to check for existing rules:",d),h(d),[3,6];case 5:return r(!1),[7];case 6:return[2]}}))}))},isLoading:n,existingConflicts:o,error:s,clearExistingAgentConflicts:function(){i(null)}}}(K),we=Le.checkExistingRules,ke=Le.isLoading,xe=Le.existingConflicts,Se=Le.error,Te=Le.clearExistingAgentConflicts,Oe=function(e){var t=c(!1),n=t[0],r=t[1],a=c([]),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1];return{fixAgentRules:function(t,n,a,o,c){return b(void 0,void 0,void 0,(function(){var l,s,d,u,m,p,v;return H(this,(function(f){switch(f.label){case 0:r(!0),i([]),h(null),l=M(M({},t),{wta:n.wta.map((function(e){return e.text})),wnta:n.wnta.map((function(e){return e.text})),mode:"AgentGenie",agent_description:o,agent_context:a,llm:c,n:1}),f.label=1;case 1:return f.trys.push([1,4,5,6]),[4,fetch("".concat(e,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})];case 2:if(!(s=f.sent()).ok)throw new Error("API Error: ".concat(s.statusText));return[4,s.json()];case 3:return d=f.sent(),u=[],null===(p=d.response.conditions_whentoapply)||void 0===p||p.forEach((function(e){u.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(v=d.response.conditions_whennottoapply)||void 0===v||v.forEach((function(e){u.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),i(u),[3,6];case 4:return m=f.sent(),console.error("Failed to fix rules:",m),h(m),[3,6];case 5:return r(!1),[7];case 6:return[2]}}))}))},isFixing:n,fixedSuggestions:o,error:s}}(K),Ae=Oe.fixAgentRules,Re=Oe.isFixing,Ne=Oe.fixedSuggestions,_e=Oe.error,De=function(e){var t=c(!1),n=t[0],r=t[1],a=c([]),o=a[0],i=a[1],l=c(null),s=l[0],h=l[1];return{fixPromptRules:function(t,n,a,o,c){return b(void 0,void 0,void 0,(function(){var l,s,d,u,m,p,v;return H(this,(function(f){switch(f.label){case 0:r(!0),i([]),h(null),l=M(M({},t),{wta:n.wta.map((function(e){return e.text})),wnta:n.wnta.map((function(e){return e.text})),mode:"PromptGenie",template_context:a,template_description:o,llm:c}),f.label=1;case 1:return f.trys.push([1,4,5,6]),[4,fetch("".concat(e,"/instant_learning/mode-wta-validation-fix"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)})];case 2:if(!(s=f.sent()).ok)throw new Error("API Error: ".concat(s.statusText));return[4,s.json()];case 3:return d=f.sent(),u=[],null===(p=d.response.conditions_whentoapply)||void 0===p||p.forEach((function(e){u.push({type:"wta",text:e.whentoapply,score:e.confidence_score,reason:e.reason})})),null===(v=d.response.conditions_whennottoapply)||void 0===v||v.forEach((function(e){u.push({type:"wnta",text:e.whennottoapply,score:e.confidence_score,reason:e.reason})})),i(u),[3,6];case 4:return m=f.sent(),console.error("Failed to fix prompt rules:",m),h(m),[3,6];case 5:return r(!1),[7];case 6:return[2]}}))}))},isFixing:n,fixedSuggestions:o,error:s}}(ie),Pe=De.fixPromptRules,Fe=De.isFixing,Ie=De.fixedSuggestions,Be=Re||Fe,je="agent-genie"===t.mode?Ne:Ie,Ue=he||pe,We=ge||Ve,$e=ye||Ce,qe="agent-genie"===t.mode?se:me,Ge=c(null===(r=t.isSave)||void 0===r||r),Ye=Ge[0],Ke=Ge[1],Xe=!v||JSON.stringify(u)!==JSON.stringify(v),Qe=!(!$e||$e.is_valid),Je=We||Ue||ke||Qe&&!Xe;s((function(){if(je.length>0){var e=je.filter((function(e){return"wta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}})),t=je.filter((function(e){return"wnta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}}));y({wta:e,wnta:t})}}),[je]),s((function(){if(qe.length>0){var e=qe.filter((function(e){return"wta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}})),t=qe.filter((function(e){return"wnta"===e.type})).map((function(e){return{text:e.text,score:e.score,reason:e.reason}})),n={wta:e,wnta:t};m({wta:e,wnta:t}),f(n)}}),[qe]);var Ze=function(){return b(void 0,void 0,void 0,(function(){return H(this,(function(e){switch(e.label){case 0:return $e?(ze(),He(),"agent-genie"!==t.mode?[3,2]:[4,Ae($e,u,F,B,O)]):[2];case 1:return e.sent(),[3,4];case 2:return"prompt-genie"!==t.mode?[3,4]:[4,Pe($e,u,re,oe,O)];case 3:e.sent(),e.label=4;case 4:return[2]}}))}))};if(de||Me||Se||_e){var et=de||Me||Se||_e;return e(iF,M({color:"error"},{children:["An error occurred: ",null==et?void 0:et.message]}))}var tt=((null==xe?void 0:xe.similar_conditions)||[]).map((function(e){return{agentName:e.ui_name,confidenceScore:e.confidence_score,reason:e.reason,wtaRules:[e.when_to_use],wntaRules:e.when_not_to_use?[e.when_not_to_use]:[]}}));return e(Yj,M({className:"".concat(gee," ").concat(o.root||"")},{children:[$e&&!$e.is_valid&&n(vee,{validationResponse:$e,onFixConflicts:Ze,className:o.validationCard}),xe&&xe.similar_conditions.length>0&&L&&n(zee,{similarRules:tt,showUpdateWarning:!(null==xe?void 0:xe.is_valid_db),className:o.similarCard}),n(mee,{formState:u,setFormState:m,config:i,isLoadingSuggestions:Ue,onSave:function(e){return b(void 0,void 0,void 0,(function(){var n,r,a,o;return H(this,(function(c){switch(c.label){case 0:return(null==xe?void 0:xe.is_valid_db)&&!Xe?"agent-genie"===t.mode?(n=u.wta.map((function(e){return e.text})).join(" OR "),r=u.wnta.map((function(e){return e.text})).join(" OR "),console.log("Save to DB clicked for Agent Genie. Final strings prepared."),console.log("When to Apply:",n),console.log("When Not to Apply:",r),null===(o=t.onSaveComplete)||void 0===o||o.call(t,{wta:n,wnta:r}),Ke(!1),[2]):[2]:(f(e),w(!1),m(e),"agent-genie"!==t.mode?[3,4]:[4,fe(e,O)]);case 1:return(a=c.sent())&&a.is_valid?(w(!0),[4,we(e,U,$,G)]):[3,3];case 2:c.sent(),c.label=3;case 3:return[3,7];case 4:return"prompt-genie"!==t.mode?[3,6]:[4,be(e,O)];case 5:return c.sent(),[3,7];case 6:console.log("Save triggered in '".concat(t.mode,"' mode. Skipping API calls.")),c.label=7;case 7:return[2]}}))}))},isSaving:We,isCheckingExisting:ke,modelProvider:x,setModelProvider:S,modelName:O,setModelName:A,suggestedFixes:g,onRejectFix:function(e,n){"agent-genie"===t.mode?(ze(),Te&&Te()):"prompt-genie"===t.mode&&He(),y((function(t){var r;return M(M({},t),((r={})[e]=t[e].filter((function(e,t){return t!==n})),r))}))},onAcceptFix:function(e,n){var r;"agent-genie"===t.mode?(ze(),Te&&Te()):"prompt-genie"===t.mode&&He();var a=M(M({},u),((r={})[e]=[{text:n.text}],r));m((function(t){var r;return M(M({},t),((r={})[e]=[{text:n.text}],r))})),f(a),_("SYNC_SNAPSHOT"),y((function(t){var n;return M(M({},t),((n={})[e]=[],n))}))},isFixing:Be,isValidDb:(null==xe?void 0:xe.is_valid_db)||!1,isSaveButtonDisabled:Je,isFormDirty:Xe,onValidate:function(e,n){return b(void 0,void 0,void 0,(function(){var r,a;return H(this,(function(o){switch(o.label){case 0:return Ke(!0),w(!1),f(e),r={wta:e.wta.map((function(e){return{text:e.text}})),wnta:e.wnta.map((function(e){return{text:e.text}}))},f(r),"agent-genie"!==t.mode?[3,4]:[4,fe(e,n)];case 1:return(a=o.sent())&&a.is_valid?(w(!0),[4,we(e,U,$,G)]):[3,3];case 2:o.sent(),o.label=3;case 3:return[3,6];case 4:return"prompt-genie"!==t.mode?[3,6]:[4,be(e,n)];case 5:o.sent(),o.label=6;case 6:return[2]}}))}))},validationResponse:$e,onFixConflicts:Ze,formCommand:N,setFormCommand:_,className:o.form,showValidateButton:Ye})]}))},Eee="PdfEditorCitation-module_citationRoot__5OtUI",bee="PdfEditorCitation-module_citationTitle__X9kQm",Hee="PdfEditorCitation-module_citationBody__C99jX",Vee="PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V";C(".PdfEditorCitation-module_citationRoot__5OtUI{display:flex;flex-direction:column}.PdfEditorCitation-module_citationTitle__X9kQm{align-items:center;background-color:#eff6ff;border:1px solid #000;border-radius:10px;cursor:pointer;display:inline-flex;gap:10px;padding:5px 8px;width:fit-content}.PdfEditorCitation-module_citationBody__C99jX{background-color:#fff;flex-grow:1}.PdfEditorCitation-module_citationBodyWhenCollapsed__8vG0V{display:none}.PdfEditorCitation-module_citationBodyWhenFullScreen__VKtop{bottom:0;height:100%!important;left:0;max-height:100%;position:absolute;right:0;top:0;width:100%!important}");var Cee,Lee={};var wee,kee=function(){if(Cee)return Lee;Cee=1;var e=p_(),t=S7();Object.defineProperty(Lee,"__esModule",{value:!0}),Lee.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"}),"ExpandLess");return Lee.default=r,Lee}(),xee=Se(kee),See={};var Tee=function(){if(wee)return See;wee=1;var e=p_(),t=S7();Object.defineProperty(See,"__esModule",{value:!0}),See.default=void 0;var n=t(a),r=(0,e(N7()).default)(n.createElement("path",{d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"}),"ExpandMore");return See.default=r,See}(),Oee=Se(Tee),Aee=function(){return Aee=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var a in t=arguments[n])Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a]);return e},Aee.apply(this,arguments)};function Ree(e,t,n,r){return new(n||(n=Promise))((function(a,o){function c(e){try{l(r.next(e))}catch(e){o(e)}}function i(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){e.done?a(e.value):function(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(c,i)}l((r=r.apply(e,t||[])).next())}))}function Nee(e,t){var n,r,a,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return c.next=i(0),c.throw=i(1),c.return=i(2),"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function i(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;c&&(c=0,i[0]&&(o=0)),o;)try{if(n=1,r&&(a=2&i[0]?r.return:i[0]?r.throw||((a=r.return)&&a.call(r),0):r.next)&&!(a=a.call(r,i[1])).done)return a;switch(r=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,r=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]<a[3])){o.label=i[1];break}if(6===i[0]&&o.label<a[1]){o.label=a[1],a=i;break}if(a&&o.label<a[2]){o.label=a[2],o.ops.push(i);break}a[2]&&o.ops.pop(),o.trys.pop();continue}i=t.call(e,o)}catch(e){i=[6,e],r=0}finally{n=a=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}function _ee(e,t,n){if(n||2===arguments.length)for(var r,a=0,o=t.length;a<o;a++)!r&&a in t||(r||(r=Array.prototype.slice.call(t,0,a)),r[a]=t[a]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var Dee=void 0!==ot?ot:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function Pee(){throw new Error("setTimeout has not been defined")}function Fee(){throw new Error("clearTimeout has not been defined")}var Iee=Pee,Bee=Fee;function jee(e){if(Iee===setTimeout)return setTimeout(e,0);if((Iee===Pee||!Iee)&&setTimeout)return Iee=setTimeout,setTimeout(e,0);try{return Iee(e,0)}catch(t){try{return Iee.call(null,e,0)}catch(t){return Iee.call(this,e,0)}}}"function"==typeof Dee.setTimeout&&(Iee=setTimeout),"function"==typeof Dee.clearTimeout&&(Bee=clearTimeout);var Uee,Wee=[],$ee=!1,qee=-1;function Gee(){$ee&&Uee&&($ee=!1,Uee.length?Wee=Uee.concat(Wee):qee=-1,Wee.length&&Yee())}function Yee(){if(!$ee){var e=jee(Gee);$ee=!0;for(var t=Wee.length;t;){for(Uee=Wee,Wee=[];++qee<t;)Uee&&Uee[qee].run();qee=-1,t=Wee.length}Uee=null,$ee=!1,function(e){if(Bee===clearTimeout)return clearTimeout(e);if((Bee===Fee||!Bee)&&clearTimeout)return Bee=clearTimeout,clearTimeout(e);try{return Bee(e)}catch(t){try{return Bee.call(null,e)}catch(t){return Bee.call(this,e)}}}(e)}}function Kee(e,t){this.fun=e,this.array=t}function Xee(){}Kee.prototype.run=function(){this.fun.apply(null,this.array)};var Qee=Xee,Jee=Xee,Zee=Xee,ete=Xee,tte=Xee,nte=Xee,rte=Xee,ate=Dee.performance||{},ote=ate.now||ate.mozNow||ate.msNow||ate.oNow||ate.webkitNow||function(){return(new Date).getTime()},cte=new Date,ite={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];Wee.push(new Kee(e,t)),1!==Wee.length||$ee||jee(Yee)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Qee,addListener:Jee,once:Zee,off:ete,removeListener:tte,removeAllListeners:nte,emit:rte,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*ote.call(ate),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-cte)/1e3}};function lte(e,t){return function(){return e.apply(t,arguments)}}const{toString:ste}=Object.prototype,{getPrototypeOf:hte}=Object,dte=(fte=Object.create(null),e=>{const t=ste.call(e);return fte[t]||(fte[t]=t.slice(8,-1).toLowerCase())}),ute=e=>(e=e.toLowerCase(),t=>dte(t)===e),mte=e=>t=>typeof t===e,{isArray:pte}=Array,vte=mte("undefined");var fte;const zte=ute("ArrayBuffer"),gte=mte("string"),yte=mte("function"),Mte=mte("number"),Ete=e=>null!==e&&"object"==typeof e,bte=e=>{if("object"!==dte(e))return!1;const t=hte(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},Hte=ute("Date"),Vte=ute("File"),Cte=ute("Blob"),Lte=ute("FileList"),wte=ute("URLSearchParams"),[kte,xte,Ste,Tte]=["ReadableStream","Request","Response","Headers"].map(ute);function Ote(e,t,{allOwnKeys:n=!1}={}){if(null==e)return;let r,a;if("object"!=typeof e&&(e=[e]),pte(e))for(r=0,a=e.length;r<a;r++)t.call(null,e[r],r,e);else{const a=n?Object.getOwnPropertyNames(e):Object.keys(e),o=a.length;let c;for(r=0;r<o;r++)c=a[r],t.call(null,e[c],c,e)}}function Ate(e,t){t=t.toLowerCase();const n=Object.keys(e);let r,a=n.length;for(;a-- >0;)if(r=n[a],t===r.toLowerCase())return r;return null}const Rte="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Dee,Nte=e=>!vte(e)&&e!==Rte,_te=(Dte="undefined"!=typeof Uint8Array&&hte(Uint8Array),e=>Dte&&e instanceof Dte);var Dte;const Pte=ute("HTMLFormElement"),Fte=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ite=ute("RegExp"),Bte=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};Ote(n,((n,a)=>{let o;!1!==(o=t(n,a,e))&&(r[a]=o||n)})),Object.defineProperties(e,r)},jte="abcdefghijklmnopqrstuvwxyz",Ute="0123456789",Wte={DIGIT:Ute,ALPHA:jte,ALPHA_DIGIT:jte+jte.toUpperCase()+Ute},$te=ute("AsyncFunction"),qte=(Gte="function"==typeof setImmediate,Yte=yte(Rte.postMessage),Gte?setImmediate:Yte?(Kte=`axios@${Math.random()}`,Xte=[],Rte.addEventListener("message",(({source:e,data:t})=>{e===Rte&&t===Kte&&Xte.length&&Xte.shift()()}),!1),e=>{Xte.push(e),Rte.postMessage(Kte,"*")}):e=>setTimeout(e));var Gte,Yte,Kte,Xte;const Qte="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Rte):ite.nextTick||qte;var Jte={isArray:pte,isArrayBuffer:zte,isBuffer:function(e){return null!==e&&!vte(e)&&null!==e.constructor&&!vte(e.constructor)&&yte(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||yte(e.append)&&("formdata"===(t=dte(e))||"object"===t&&yte(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&zte(e.buffer),t},isString:gte,isNumber:Mte,isBoolean:e=>!0===e||!1===e,isObject:Ete,isPlainObject:bte,isReadableStream:kte,isRequest:xte,isResponse:Ste,isHeaders:Tte,isUndefined:vte,isDate:Hte,isFile:Vte,isBlob:Cte,isRegExp:Ite,isFunction:yte,isStream:e=>Ete(e)&&yte(e.pipe),isURLSearchParams:wte,isTypedArray:_te,isFileList:Lte,forEach:Ote,merge:function e(){const{caseless:t}=Nte(this)&&this||{},n={},r=(r,a)=>{const o=t&&Ate(n,a)||a;bte(n[o])&&bte(r)?n[o]=e(n[o],r):bte(r)?n[o]=e({},r):pte(r)?n[o]=r.slice():n[o]=r};for(let e=0,t=arguments.length;e<t;e++)arguments[e]&&Ote(arguments[e],r);return n},extend:(e,t,n,{allOwnKeys:r}={})=>(Ote(t,((t,r)=>{n&&yte(t)?e[r]=lte(t,n):e[r]=t}),{allOwnKeys:r}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:(e,t,n,r)=>{let a,o,c;const i={};if(t=t||{},null==e)return t;do{for(a=Object.getOwnPropertyNames(e),o=a.length;o-- >0;)c=a[o],r&&!r(c,e,t)||i[c]||(t[c]=e[c],i[c]=!0);e=!1!==n&&hte(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:dte,kindOfTest:ute,endsWith:(e,t,n)=>{e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return-1!==r&&r===n},toArray:e=>{if(!e)return null;if(pte(e))return e;let t=e.length;if(!Mte(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},forEachEntry:(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let r;for(;(r=n.next())&&!r.done;){const n=r.value;t.call(e,n[0],n[1])}},matchAll:(e,t)=>{let n;const r=[];for(;null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:Pte,hasOwnProperty:Fte,hasOwnProp:Fte,reduceDescriptors:Bte,freezeMethods:e=>{Bte(e,((t,n)=>{if(yte(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;const r=e[n];yte(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:(e,t)=>{const n={},r=e=>{e.forEach((e=>{n[e]=!0}))};return pte(e)?r(e):r(String(e).split(t)),n},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Ate,global:Rte,isContextDefined:Nte,ALPHABET:Wte,generateString:(e=16,t=Wte.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&yte(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:e=>{const t=new Array(10),n=(e,r)=>{if(Ete(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[r]=e;const a=pte(e)?[]:{};return Ote(e,((e,t)=>{const o=n(e,r+1);!vte(o)&&(a[t]=o)})),t[r]=void 0,a}}return e};return n(e,0)},isAsyncFn:$te,isThenable:e=>e&&(Ete(e)||yte(e))&&yte(e.then)&&yte(e.catch),setImmediate:qte,asap:Qte},Zte=[],ene=[],tne="undefined"!=typeof Uint8Array?Uint8Array:Array,nne=!1;function rne(){nne=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Zte[t]=e[t],ene[e.charCodeAt(t)]=t;ene["-".charCodeAt(0)]=62,ene["_".charCodeAt(0)]=63}function ane(e,t,n){for(var r,a,o=[],c=t;c<n;c+=3)r=(e[c]<<16)+(e[c+1]<<8)+e[c+2],o.push(Zte[(a=r)>>18&63]+Zte[a>>12&63]+Zte[a>>6&63]+Zte[63&a]);return o.join("")}function one(e){var t;nne||rne();for(var n=e.length,r=n%3,a="",o=[],c=16383,i=0,l=n-r;i<l;i+=c)o.push(ane(e,i,i+c>l?l:i+c));return 1===r?(t=e[n-1],a+=Zte[t>>2],a+=Zte[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=Zte[t>>10],a+=Zte[t>>4&63],a+=Zte[t<<2&63],a+="="),o.push(a),o.join("")}function cne(e,t,n,r,a){var o,c,i=8*a-r-1,l=(1<<i)-1,s=l>>1,h=-7,d=n?a-1:0,u=n?-1:1,m=e[t+d];for(d+=u,o=m&(1<<-h)-1,m>>=-h,h+=i;h>0;o=256*o+e[t+d],d+=u,h-=8);for(c=o&(1<<-h)-1,o>>=-h,h+=r;h>0;c=256*c+e[t+d],d+=u,h-=8);if(0===o)o=1-s;else{if(o===l)return c?NaN:1/0*(m?-1:1);c+=Math.pow(2,r),o-=s}return(m?-1:1)*c*Math.pow(2,o-r)}function ine(e,t,n,r,a,o){var c,i,l,s=8*o-a-1,h=(1<<s)-1,d=h>>1,u=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,m=r?0:o-1,p=r?1:-1,v=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(i=isNaN(t)?1:0,c=h):(c=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-c))<1&&(c--,l*=2),(t+=c+d>=1?u/l:u*Math.pow(2,1-d))*l>=2&&(c++,l/=2),c+d>=h?(i=0,c=h):c+d>=1?(i=(t*l-1)*Math.pow(2,a),c+=d):(i=t*Math.pow(2,d-1)*Math.pow(2,a),c=0));a>=8;e[n+m]=255&i,m+=p,i/=256,a-=8);for(c=c<<a|i,s+=a;s>0;e[n+m]=255&c,m+=p,c/=256,s-=8);e[n+m-p]|=128*v}var lne={}.toString,sne=Array.isArray||function(e){return"[object Array]"==lne.call(e)};function hne(){return une.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function dne(e,t){if(hne()<t)throw new RangeError("Invalid typed array length");return une.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=une.prototype:(null===e&&(e=new une(t)),e.length=t),e}function une(e,t,n){if(!(une.TYPED_ARRAY_SUPPORT||this instanceof une))return new une(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return vne(this,e)}return mne(this,e,t,n)}function mne(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),une.TYPED_ARRAY_SUPPORT?(e=t).__proto__=une.prototype:e=fne(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!une.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|yne(t,n),a=(e=dne(e,r)).write(t,n);return a!==r&&(e=e.slice(0,a)),e}(e,t,n):function(e,t){if(gne(t)){var n=0|zne(t.length);return 0===(e=dne(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?dne(e,0):fne(e,t);if("Buffer"===t.type&&sne(t.data))return fne(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function pne(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function vne(e,t){if(pne(t),e=dne(e,t<0?0:0|zne(t)),!une.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function fne(e,t){var n=t.length<0?0:0|zne(t.length);e=dne(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function zne(e){if(e>=hne())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+hne().toString(16)+" bytes");return 0|e}function gne(e){return!(null==e||!e._isBuffer)}function yne(e,t){if(gne(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return qne(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Gne(e).length;default:if(r)return qne(e).length;t=(""+t).toLowerCase(),r=!0}}function Mne(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return Nne(this,t,n);case"utf8":case"utf-8":return Tne(this,t,n);case"ascii":return Ane(this,t,n);case"latin1":case"binary":return Rne(this,t,n);case"base64":return Sne(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _ne(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function Ene(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function bne(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=une.from(t,r)),gne(t))return 0===t.length?-1:Hne(e,t,n,r,a);if("number"==typeof t)return t&=255,une.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):Hne(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function Hne(e,t,n,r,a){var o,c=1,i=e.length,l=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;c=2,i/=2,l/=2,n/=2}function s(e,t){return 1===c?e[t]:e.readUInt16BE(t*c)}if(a){var h=-1;for(o=n;o<i;o++)if(s(e,o)===s(t,-1===h?0:o-h)){if(-1===h&&(h=o),o-h+1===l)return h*c}else-1!==h&&(o-=o-h),h=-1}else for(n+l>i&&(n=i-l),o=n;o>=0;o--){for(var d=!0,u=0;u<l;u++)if(s(e,o+u)!==s(t,u)){d=!1;break}if(d)return o}return-1}function Vne(e,t,n,r){n=Number(n)||0;var a=e.length-n;r?(r=Number(r))>a&&(r=a):r=a;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var c=0;c<r;++c){var i=parseInt(t.substr(2*c,2),16);if(isNaN(i))return c;e[n+c]=i}return c}function Cne(e,t,n,r){return Yne(qne(t,e.length-n),e,n,r)}function Lne(e,t,n,r){return Yne(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function wne(e,t,n,r){return Lne(e,t,n,r)}function kne(e,t,n,r){return Yne(Gne(t),e,n,r)}function xne(e,t,n,r){return Yne(function(e,t){for(var n,r,a,o=[],c=0;c<e.length&&!((t-=2)<0);++c)r=(n=e.charCodeAt(c))>>8,a=n%256,o.push(a),o.push(r);return o}(t,e.length-n),e,n,r)}function Sne(e,t,n){return 0===t&&n===e.length?one(e):one(e.slice(t,n))}function Tne(e,t,n){n=Math.min(e.length,n);for(var r=[],a=t;a<n;){var o,c,i,l,s=e[a],h=null,d=s>239?4:s>223?3:s>191?2:1;if(a+d<=n)switch(d){case 1:s<128&&(h=s);break;case 2:128==(192&(o=e[a+1]))&&(l=(31&s)<<6|63&o)>127&&(h=l);break;case 3:o=e[a+1],c=e[a+2],128==(192&o)&&128==(192&c)&&(l=(15&s)<<12|(63&o)<<6|63&c)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:o=e[a+1],c=e[a+2],i=e[a+3],128==(192&o)&&128==(192&c)&&128==(192&i)&&(l=(15&s)<<18|(63&o)<<12|(63&c)<<6|63&i)>65535&&l<1114112&&(h=l)}null===h?(h=65533,d=1):h>65535&&(h-=65536,r.push(h>>>10&1023|55296),h=56320|1023&h),r.push(h),a+=d}return function(e){var t=e.length;if(t<=One)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=One));return n}(r)}une.TYPED_ARRAY_SUPPORT=void 0===Dee.TYPED_ARRAY_SUPPORT||Dee.TYPED_ARRAY_SUPPORT,hne(),une.poolSize=8192,une._augment=function(e){return e.__proto__=une.prototype,e},une.from=function(e,t,n){return mne(null,e,t,n)},une.TYPED_ARRAY_SUPPORT&&(une.prototype.__proto__=Uint8Array.prototype,une.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&une[Symbol.species]),une.alloc=function(e,t,n){return function(e,t,n,r){return pne(t),t<=0?dne(e,t):void 0!==n?"string"==typeof r?dne(e,t).fill(n,r):dne(e,t).fill(n):dne(e,t)}(null,e,t,n)},une.allocUnsafe=function(e){return vne(null,e)},une.allocUnsafeSlow=function(e){return vne(null,e)},une.isBuffer=function(e){return null!=e&&(!!e._isBuffer||Kne(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&Kne(e.slice(0,0))}(e))},une.compare=function(e,t){if(!gne(e)||!gne(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,o=Math.min(n,r);a<o;++a)if(e[a]!==t[a]){n=e[a],r=t[a];break}return n<r?-1:r<n?1:0},une.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},une.concat=function(e,t){if(!sne(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return une.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=une.allocUnsafe(t),a=0;for(n=0;n<e.length;++n){var o=e[n];if(!gne(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,a),a+=o.length}return r},une.byteLength=yne,une.prototype._isBuffer=!0,une.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)Ene(this,t,t+1);return this},une.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)Ene(this,t,t+3),Ene(this,t+1,t+2);return this},une.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)Ene(this,t,t+7),Ene(this,t+1,t+6),Ene(this,t+2,t+5),Ene(this,t+3,t+4);return this},une.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?Tne(this,0,e):Mne.apply(this,arguments)},une.prototype.equals=function(e){if(!gne(e))throw new TypeError("Argument must be a Buffer");return this===e||0===une.compare(this,e)},une.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},une.prototype.compare=function(e,t,n,r,a){if(!gne(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(a>>>=0)-(r>>>=0),c=(n>>>=0)-(t>>>=0),i=Math.min(o,c),l=this.slice(r,a),s=e.slice(t,n),h=0;h<i;++h)if(l[h]!==s[h]){o=l[h],c=s[h];break}return o<c?-1:c<o?1:0},une.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},une.prototype.indexOf=function(e,t,n){return bne(this,e,t,n,!0)},une.prototype.lastIndexOf=function(e,t,n){return bne(this,e,t,n,!1)},une.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var a=this.length-t;if((void 0===n||n>a)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return Vne(this,e,t,n);case"utf8":case"utf-8":return Cne(this,e,t,n);case"ascii":return Lne(this,e,t,n);case"latin1":case"binary":return wne(this,e,t,n);case"base64":return kne(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return xne(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},une.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var One=4096;function Ane(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(127&e[a]);return r}function Rne(e,t,n){var r="";n=Math.min(e.length,n);for(var a=t;a<n;++a)r+=String.fromCharCode(e[a]);return r}function Nne(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var a="",o=t;o<n;++o)a+=$ne(e[o]);return a}function _ne(e,t,n){for(var r=e.slice(t,n),a="",o=0;o<r.length;o+=2)a+=String.fromCharCode(r[o]+256*r[o+1]);return a}function Dne(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function Pne(e,t,n,r,a,o){if(!gne(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function Fne(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,o=Math.min(e.length-n,2);a<o;++a)e[n+a]=(t&255<<8*(r?a:1-a))>>>8*(r?a:1-a)}function Ine(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,o=Math.min(e.length-n,4);a<o;++a)e[n+a]=t>>>8*(r?a:3-a)&255}function Bne(e,t,n,r,a,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function jne(e,t,n,r,a){return a||Bne(e,0,n,4),ine(e,t,n,r,23,4),n+4}function Une(e,t,n,r,a){return a||Bne(e,0,n,8),ine(e,t,n,r,52,8),n+8}une.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),une.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=une.prototype;else{var a=t-e;n=new une(a,void 0);for(var o=0;o<a;++o)n[o]=this[o+e]}return n},une.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r},une.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=this[e+--t],a=1;t>0&&(a*=256);)r+=this[e+--t]*a;return r},une.prototype.readUInt8=function(e,t){return t||Dne(e,1,this.length),this[e]},une.prototype.readUInt16LE=function(e,t){return t||Dne(e,2,this.length),this[e]|this[e+1]<<8},une.prototype.readUInt16BE=function(e,t){return t||Dne(e,2,this.length),this[e]<<8|this[e+1]},une.prototype.readUInt32LE=function(e,t){return t||Dne(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},une.prototype.readUInt32BE=function(e,t){return t||Dne(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},une.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=this[e],a=1,o=0;++o<t&&(a*=256);)r+=this[e+o]*a;return r>=(a*=128)&&(r-=Math.pow(2,8*t)),r},une.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||Dne(e,t,this.length);for(var r=t,a=1,o=this[e+--r];r>0&&(a*=256);)o+=this[e+--r]*a;return o>=(a*=128)&&(o-=Math.pow(2,8*t)),o},une.prototype.readInt8=function(e,t){return t||Dne(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},une.prototype.readInt16LE=function(e,t){t||Dne(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},une.prototype.readInt16BE=function(e,t){t||Dne(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},une.prototype.readInt32LE=function(e,t){return t||Dne(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},une.prototype.readInt32BE=function(e,t){return t||Dne(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},une.prototype.readFloatLE=function(e,t){return t||Dne(e,4,this.length),cne(this,e,!0,23,4)},une.prototype.readFloatBE=function(e,t){return t||Dne(e,4,this.length),cne(this,e,!1,23,4)},une.prototype.readDoubleLE=function(e,t){return t||Dne(e,8,this.length),cne(this,e,!0,52,8)},une.prototype.readDoubleBE=function(e,t){return t||Dne(e,8,this.length),cne(this,e,!1,52,8)},une.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Pne(this,e,t,n,Math.pow(2,8*n)-1,0);var a=1,o=0;for(this[t]=255&e;++o<n&&(a*=256);)this[t+o]=e/a&255;return t+n},une.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||Pne(this,e,t,n,Math.pow(2,8*n)-1,0);var a=n-1,o=1;for(this[t+a]=255&e;--a>=0&&(o*=256);)this[t+a]=e/o&255;return t+n},une.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,1,255,0),une.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},une.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,65535,0),une.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Fne(this,e,t,!0),t+2},une.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,65535,0),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Fne(this,e,t,!1),t+2},une.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,4294967295,0),une.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Ine(this,e,t,!0),t+4},une.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,4294967295,0),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ine(this,e,t,!1),t+4},une.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Pne(this,e,t,n,a-1,-a)}var o=0,c=1,i=0;for(this[t]=255&e;++o<n&&(c*=256);)e<0&&0===i&&0!==this[t+o-1]&&(i=1),this[t+o]=(e/c|0)-i&255;return t+n},une.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Pne(this,e,t,n,a-1,-a)}var o=n-1,c=1,i=0;for(this[t+o]=255&e;--o>=0&&(c*=256);)e<0&&0===i&&0!==this[t+o+1]&&(i=1),this[t+o]=(e/c|0)-i&255;return t+n},une.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,1,127,-128),une.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},une.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,32767,-32768),une.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):Fne(this,e,t,!0),t+2},une.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,2,32767,-32768),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):Fne(this,e,t,!1),t+2},une.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,2147483647,-2147483648),une.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Ine(this,e,t,!0),t+4},une.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Pne(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),une.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Ine(this,e,t,!1),t+4},une.prototype.writeFloatLE=function(e,t,n){return jne(this,e,t,!0,n)},une.prototype.writeFloatBE=function(e,t,n){return jne(this,e,t,!1,n)},une.prototype.writeDoubleLE=function(e,t,n){return Une(this,e,t,!0,n)},une.prototype.writeDoubleBE=function(e,t,n){return Une(this,e,t,!1,n)},une.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var a,o=r-n;if(this===e&&n<t&&t<r)for(a=o-1;a>=0;--a)e[a+t]=this[a+n];else if(o<1e3||!une.TYPED_ARRAY_SUPPORT)for(a=0;a<o;++a)e[a+t]=this[a+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},une.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var a=e.charCodeAt(0);a<256&&(e=a)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!une.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var c=gne(e)?e:qne(new une(e,r).toString()),i=c.length;for(o=0;o<n-t;++o)this[o+t]=c[o%i]}return this};var Wne=/[^+\/0-9A-Za-z-_]/g;function $ne(e){return e<16?"0"+e.toString(16):e.toString(16)}function qne(e,t){var n;t=t||1/0;for(var r=e.length,a=null,o=[],c=0;c<r;++c){if((n=e.charCodeAt(c))>55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(c+1===r){(t-=3)>-1&&o.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&o.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Gne(e){return function(e){var t,n,r,a,o,c;nne||rne();var i=e.length;if(i%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[i-2]?2:"="===e[i-1]?1:0,c=new tne(3*i/4-o),r=o>0?i-4:i;var l=0;for(t=0,n=0;t<r;t+=4,n+=3)a=ene[e.charCodeAt(t)]<<18|ene[e.charCodeAt(t+1)]<<12|ene[e.charCodeAt(t+2)]<<6|ene[e.charCodeAt(t+3)],c[l++]=a>>16&255,c[l++]=a>>8&255,c[l++]=255&a;return 2===o?(a=ene[e.charCodeAt(t)]<<2|ene[e.charCodeAt(t+1)]>>4,c[l++]=255&a):1===o&&(a=ene[e.charCodeAt(t)]<<10|ene[e.charCodeAt(t+1)]<<4|ene[e.charCodeAt(t+2)]>>2,c[l++]=a>>8&255,c[l++]=255&a),c}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Wne,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Yne(e,t,n,r){for(var a=0;a<r&&!(a+n>=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function Kne(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function Xne(e,t,n,r,a){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),a&&(this.response=a,this.status=a.status?a.status:null)}Jte.inherits(Xne,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:Jte.toJSONObject(this.config),code:this.code,status:this.status}}});const Qne=Xne.prototype,Jne={};function Zne(e){return Jte.isPlainObject(e)||Jte.isArray(e)}function ere(e){return Jte.endsWith(e,"[]")?e.slice(0,-2):e}function tre(e,t,n){return e?e.concat(t).map((function(e,t){return e=ere(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((e=>{Jne[e]={value:e}})),Object.defineProperties(Xne,Jne),Object.defineProperty(Qne,"isAxiosError",{value:!0}),Xne.from=(e,t,n,r,a,o)=>{const c=Object.create(Qne);return Jte.toFlatObject(e,c,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),Xne.call(c,e.message,t,n,r,a),c.cause=e,c.name=e.name,o&&Object.assign(c,o),c};const nre=Jte.toFlatObject(Jte,{},null,(function(e){return/^is[A-Z]/.test(e)}));function rre(e,t,n){if(!Jte.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const r=(n=Jte.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!Jte.isUndefined(t[e])}))).metaTokens,a=n.visitor||s,o=n.dots,c=n.indexes,i=(n.Blob||"undefined"!=typeof Blob&&Blob)&&Jte.isSpecCompliantForm(t);if(!Jte.isFunction(a))throw new TypeError("visitor must be a function");function l(e){if(null===e)return"";if(Jte.isDate(e))return e.toISOString();if(!i&&Jte.isBlob(e))throw new Xne("Blob is not supported. Use a Buffer instead.");return Jte.isArrayBuffer(e)||Jte.isTypedArray(e)?i&&"function"==typeof Blob?new Blob([e]):une.from(e):e}function s(e,n,a){let i=e;if(e&&!a&&"object"==typeof e)if(Jte.endsWith(n,"{}"))n=r?n:n.slice(0,-2),e=JSON.stringify(e);else if(Jte.isArray(e)&&function(e){return Jte.isArray(e)&&!e.some(Zne)}(e)||(Jte.isFileList(e)||Jte.endsWith(n,"[]"))&&(i=Jte.toArray(e)))return n=ere(n),i.forEach((function(e,r){!Jte.isUndefined(e)&&null!==e&&t.append(!0===c?tre([n],r,o):null===c?n:n+"[]",l(e))})),!1;return!!Zne(e)||(t.append(tre(a,n,o),l(e)),!1)}const h=[],d=Object.assign(nre,{defaultVisitor:s,convertValue:l,isVisitable:Zne});if(!Jte.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!Jte.isUndefined(n)){if(-1!==h.indexOf(n))throw Error("Circular reference detected in "+r.join("."));h.push(n),Jte.forEach(n,(function(n,o){!0===(!(Jte.isUndefined(n)||null===n)&&a.call(t,n,Jte.isString(o)?o.trim():o,r,d))&&e(n,r?r.concat(o):[o])})),h.pop()}}(e),t}function are(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function ore(e,t){this._pairs=[],e&&rre(e,this,t)}const cre=ore.prototype;function ire(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function lre(e,t,n){if(!t)return e;const r=n&&n.encode||ire;Jte.isFunction(n)&&(n={serialize:n});const a=n&&n.serialize;let o;if(o=a?a(t,n):Jte.isURLSearchParams(t)?t.toString():new ore(t,n).toString(r),o){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+o}return e}cre.append=function(e,t){this._pairs.push([e,t])},cre.toString=function(e){const t=e?function(t){return e.call(this,t,are)}:are;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class sre{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){Jte.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}var hre={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},dre={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:ore,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ure="undefined"!=typeof window&&"undefined"!=typeof document,mre="object"==typeof navigator&&navigator||void 0,pre=ure&&(!mre||["ReactNative","NativeScript","NS"].indexOf(mre.product)<0),vre="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,fre=ure&&window.location.href||"http://localhost";var zre={...Object.freeze({__proto__:null,hasBrowserEnv:ure,hasStandardBrowserWebWorkerEnv:vre,hasStandardBrowserEnv:pre,navigator:mre,origin:fre}),...dre};function gre(e){function t(e,n,r,a){let o=e[a++];if("__proto__"===o)return!0;const c=Number.isFinite(+o),i=a>=e.length;return o=!o&&Jte.isArray(r)?r.length:o,i?(Jte.hasOwnProp(r,o)?r[o]=[r[o],n]:r[o]=n,!c):(r[o]&&Jte.isObject(r[o])||(r[o]=[]),t(e,n,r[o],a)&&Jte.isArray(r[o])&&(r[o]=function(e){const t={},n=Object.keys(e);let r;const a=n.length;let o;for(r=0;r<a;r++)o=n[r],t[o]=e[o];return t}(r[o])),!c)}if(Jte.isFormData(e)&&Jte.isFunction(e.entries)){const n={};return Jte.forEachEntry(e,((e,r)=>{t(function(e){return Jte.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),r,n,0)})),n}return null}const yre={transitional:hre,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",r=n.indexOf("application/json")>-1,a=Jte.isObject(e);if(a&&Jte.isHTMLForm(e)&&(e=new FormData(e)),Jte.isFormData(e))return r?JSON.stringify(gre(e)):e;if(Jte.isArrayBuffer(e)||Jte.isBuffer(e)||Jte.isStream(e)||Jte.isFile(e)||Jte.isBlob(e)||Jte.isReadableStream(e))return e;if(Jte.isArrayBufferView(e))return e.buffer;if(Jte.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let o;if(a){if(n.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return rre(e,new zre.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return zre.isNode&&Jte.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((o=Jte.isFileList(e))||n.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return rre(o?{"files[]":e}:e,t&&new t,this.formSerializer)}}return a||r?(t.setContentType("application/json",!1),function(e){if(Jte.isString(e))try{return(0,JSON.parse)(e),Jte.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(0,JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||yre.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(Jte.isResponse(e)||Jte.isReadableStream(e))return e;if(e&&Jte.isString(e)&&(n&&!this.responseType||r)){const n=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(n){if("SyntaxError"===e.name)throw Xne.from(e,Xne.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:zre.classes.FormData,Blob:zre.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};Jte.forEach(["delete","get","head","post","put","patch"],(e=>{yre.headers[e]={}}));const Mre=Jte.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Ere=Symbol("internals");function bre(e){return e&&String(e).trim().toLowerCase()}function Hre(e){return!1===e||null==e?e:Jte.isArray(e)?e.map(Hre):String(e)}function Vre(e,t,n,r,a){return Jte.isFunction(r)?r.call(this,t,n):(a&&(t=n),Jte.isString(t)?Jte.isString(r)?-1!==t.indexOf(r):Jte.isRegExp(r)?r.test(t):void 0:void 0)}class Cre{constructor(e){e&&this.set(e)}set(e,t,n){const r=this;function a(e,t,n){const a=bre(t);if(!a)throw new Error("header name must be a non-empty string");const o=Jte.findKey(r,a);(!o||void 0===r[o]||!0===n||void 0===n&&!1!==r[o])&&(r[o||t]=Hre(e))}const o=(e,t)=>Jte.forEach(e,((e,n)=>a(e,n,t)));if(Jte.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(Jte.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))o((e=>{const t={};let n,r,a;return e&&e.split("\n").forEach((function(e){a=e.indexOf(":"),n=e.substring(0,a).trim().toLowerCase(),r=e.substring(a+1).trim(),!n||t[n]&&Mre[n]||("set-cookie"===n?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)})),t})(e),t);else if(Jte.isHeaders(e))for(const[t,r]of e.entries())a(r,t,n);else null!=e&&a(t,e,n);return this}get(e,t){if(e=bre(e)){const n=Jte.findKey(this,e);if(n){const e=this[n];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}(e);if(Jte.isFunction(t))return t.call(this,e,n);if(Jte.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=bre(e)){const n=Jte.findKey(this,e);return!(!n||void 0===this[n]||t&&!Vre(0,this[n],n,t))}return!1}delete(e,t){const n=this;let r=!1;function a(e){if(e=bre(e)){const a=Jte.findKey(n,e);!a||t&&!Vre(0,n[a],a,t)||(delete n[a],r=!0)}}return Jte.isArray(e)?e.forEach(a):a(e),r}clear(e){const t=Object.keys(this);let n=t.length,r=!1;for(;n--;){const a=t[n];e&&!Vre(0,this[a],a,e,!0)||(delete this[a],r=!0)}return r}normalize(e){const t=this,n={};return Jte.forEach(this,((r,a)=>{const o=Jte.findKey(n,a);if(o)return t[o]=Hre(r),void delete t[a];const c=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,n)=>t.toUpperCase()+n))}(a):String(a).trim();c!==a&&delete t[a],t[c]=Hre(r),n[c]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return Jte.forEach(this,((n,r)=>{null!=n&&!1!==n&&(t[r]=e&&Jte.isArray(n)?n.join(", "):n)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach((e=>n.set(e))),n}static accessor(e){const t=(this[Ere]=this[Ere]={accessors:{}}).accessors,n=this.prototype;function r(e){const r=bre(e);t[r]||(function(e,t){const n=Jte.toCamelCase(" "+t);["get","set","has"].forEach((r=>{Object.defineProperty(e,r+n,{value:function(e,n,a){return this[r].call(this,t,e,n,a)},configurable:!0})}))}(n,e),t[r]=!0)}return Jte.isArray(e)?e.forEach(r):r(e),this}}function Lre(e,t){const n=this||yre,r=t||n,a=Cre.from(r.headers);let o=r.data;return Jte.forEach(e,(function(e){o=e.call(n,o,a.normalize(),t?t.status:void 0)})),a.normalize(),o}function wre(e){return!(!e||!e.__CANCEL__)}function kre(e,t,n){Xne.call(this,null==e?"canceled":e,Xne.ERR_CANCELED,t,n),this.name="CanceledError"}function xre(e,t,n){const r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new Xne("Request failed with status code "+n.status,[Xne.ERR_BAD_REQUEST,Xne.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}Cre.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),Jte.reduceDescriptors(Cre.prototype,(({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[n]=e}}})),Jte.freezeMethods(Cre),Jte.inherits(kre,Xne,{__CANCEL__:!0});const Sre=(e,t,n=3)=>{let r=0;const a=function(e,t){e=e||10;const n=new Array(e),r=new Array(e);let a,o=0,c=0;return t=void 0!==t?t:1e3,function(i){const l=Date.now(),s=r[c];a||(a=l),n[o]=i,r[o]=l;let h=c,d=0;for(;h!==o;)d+=n[h++],h%=e;if(o=(o+1)%e,o===c&&(c=(c+1)%e),l-a<t)return;const u=s&&l-s;return u?Math.round(1e3*d/u):void 0}}(50,250);return function(e,t){let n,r,a=0,o=1e3/t;const c=(t,o=Date.now())=>{a=o,n=null,r&&(clearTimeout(r),r=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),i=t-a;i>=o?c(e,t):(n=e,r||(r=setTimeout((()=>{r=null,c(n)}),o-i)))},()=>n&&c(n)]}((n=>{const o=n.loaded,c=n.lengthComputable?n.total:void 0,i=o-r,l=a(i);r=o,e({loaded:o,total:c,progress:c?o/c:void 0,bytes:i,rate:l||void 0,estimated:l&&c&&o<=c?(c-o)/l:void 0,event:n,lengthComputable:null!=c,[t?"download":"upload"]:!0})}),n)},Tre=(e,t)=>{const n=null!=e;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},Ore=e=>(...t)=>Jte.asap((()=>e(...t)));var Are=zre.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,zre.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(zre.origin),zre.navigator&&/(msie|trident)/i.test(zre.navigator.userAgent)):()=>!0,Rre=zre.hasStandardBrowserEnv?{write(e,t,n,r,a,o){const c=[e+"="+encodeURIComponent(t)];Jte.isNumber(n)&&c.push("expires="+new Date(n).toGMTString()),Jte.isString(r)&&c.push("path="+r),Jte.isString(a)&&c.push("domain="+a),!0===o&&c.push("secure"),document.cookie=c.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Nre(e,t){return e&&!function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}(t)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const _re=e=>e instanceof Cre?{...e}:e;function Dre(e,t){t=t||{};const n={};function r(e,t,n,r){return Jte.isPlainObject(e)&&Jte.isPlainObject(t)?Jte.merge.call({caseless:r},e,t):Jte.isPlainObject(t)?Jte.merge({},t):Jte.isArray(t)?t.slice():t}function a(e,t,n,a){return Jte.isUndefined(t)?Jte.isUndefined(e)?void 0:r(void 0,e,0,a):r(e,t,0,a)}function o(e,t){if(!Jte.isUndefined(t))return r(void 0,t)}function c(e,t){return Jte.isUndefined(t)?Jte.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function i(n,a,o){return o in t?r(n,a):o in e?r(void 0,n):void 0}const l={url:o,method:o,data:o,baseURL:c,transformRequest:c,transformResponse:c,paramsSerializer:c,timeout:c,timeoutMessage:c,withCredentials:c,withXSRFToken:c,adapter:c,responseType:c,xsrfCookieName:c,xsrfHeaderName:c,onUploadProgress:c,onDownloadProgress:c,decompress:c,maxContentLength:c,maxBodyLength:c,beforeRedirect:c,transport:c,httpAgent:c,httpsAgent:c,cancelToken:c,socketPath:c,responseEncoding:c,validateStatus:i,headers:(e,t,n)=>a(_re(e),_re(t),0,!0)};return Jte.forEach(Object.keys(Object.assign({},e,t)),(function(r){const o=l[r]||a,c=o(e[r],t[r],r);Jte.isUndefined(c)&&o!==i||(n[r]=c)})),n}var Pre=e=>{const t=Dre({},e);let n,{data:r,withXSRFToken:a,xsrfHeaderName:o,xsrfCookieName:c,headers:i,auth:l}=t;if(t.headers=i=Cre.from(i),t.url=lre(Nre(t.baseURL,t.url),e.params,e.paramsSerializer),l&&i.set("Authorization","Basic "+btoa((l.username||"")+":"+(l.password?unescape(encodeURIComponent(l.password)):""))),Jte.isFormData(r))if(zre.hasStandardBrowserEnv||zre.hasStandardBrowserWebWorkerEnv)i.setContentType(void 0);else if(!1!==(n=i.getContentType())){const[e,...t]=n?n.split(";").map((e=>e.trim())).filter(Boolean):[];i.setContentType([e||"multipart/form-data",...t].join("; "))}if(zre.hasStandardBrowserEnv&&(a&&Jte.isFunction(a)&&(a=a(t)),a||!1!==a&&Are(t.url))){const e=o&&c&&Rre.read(c);e&&i.set(o,e)}return t},Fre="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){const r=Pre(e);let a=r.data;const o=Cre.from(r.headers).normalize();let c,i,l,s,h,{responseType:d,onUploadProgress:u,onDownloadProgress:m}=r;function p(){s&&s(),h&&h(),r.cancelToken&&r.cancelToken.unsubscribe(c),r.signal&&r.signal.removeEventListener("abort",c)}let v=new XMLHttpRequest;function f(){if(!v)return;const r=Cre.from("getAllResponseHeaders"in v&&v.getAllResponseHeaders());xre((function(e){t(e),p()}),(function(e){n(e),p()}),{data:d&&"text"!==d&&"json"!==d?v.response:v.responseText,status:v.status,statusText:v.statusText,headers:r,config:e,request:v}),v=null}v.open(r.method.toUpperCase(),r.url,!0),v.timeout=r.timeout,"onloadend"in v?v.onloadend=f:v.onreadystatechange=function(){v&&4===v.readyState&&(0!==v.status||v.responseURL&&0===v.responseURL.indexOf("file:"))&&setTimeout(f)},v.onabort=function(){v&&(n(new Xne("Request aborted",Xne.ECONNABORTED,e,v)),v=null)},v.onerror=function(){n(new Xne("Network Error",Xne.ERR_NETWORK,e,v)),v=null},v.ontimeout=function(){let t=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const a=r.transitional||hre;r.timeoutErrorMessage&&(t=r.timeoutErrorMessage),n(new Xne(t,a.clarifyTimeoutError?Xne.ETIMEDOUT:Xne.ECONNABORTED,e,v)),v=null},void 0===a&&o.setContentType(null),"setRequestHeader"in v&&Jte.forEach(o.toJSON(),(function(e,t){v.setRequestHeader(t,e)})),Jte.isUndefined(r.withCredentials)||(v.withCredentials=!!r.withCredentials),d&&"json"!==d&&(v.responseType=r.responseType),m&&([l,h]=Sre(m,!0),v.addEventListener("progress",l)),u&&v.upload&&([i,s]=Sre(u),v.upload.addEventListener("progress",i),v.upload.addEventListener("loadend",s)),(r.cancelToken||r.signal)&&(c=t=>{v&&(n(!t||t.type?new kre(null,e,v):t),v.abort(),v=null)},r.cancelToken&&r.cancelToken.subscribe(c),r.signal&&(r.signal.aborted?c():r.signal.addEventListener("abort",c)));const z=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(r.url);z&&-1===zre.protocols.indexOf(z)?n(new Xne("Unsupported protocol "+z+":",Xne.ERR_BAD_REQUEST,e)):v.send(a||null)}))};const Ire=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let n,r=new AbortController;const a=function(e){if(!n){n=!0,c();const t=e instanceof Error?e:this.reason;r.abort(t instanceof Xne?t:new kre(t instanceof Error?t.message:t))}};let o=t&&setTimeout((()=>{o=null,a(new Xne(`timeout ${t} of ms exceeded`,Xne.ETIMEDOUT))}),t);const c=()=>{e&&(o&&clearTimeout(o),o=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(a):e.removeEventListener("abort",a)})),e=null)};e.forEach((e=>e.addEventListener("abort",a)));const{signal:i}=r;return i.unsubscribe=()=>Jte.asap(c),i}},Bre=function*(e,t){let n=e.byteLength;if(!t||n<t)return void(yield e);let r,a=0;for(;a<n;)r=a+t,yield e.slice(a,r),a=r},jre=(e,t,n,r)=>{const a=async function*(e,t){for await(const n of async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}}(e))yield*Bre(n,t)}(e,t);let o,c=0,i=e=>{o||(o=!0,r&&r(e))};return new ReadableStream({async pull(e){try{const{done:t,value:r}=await a.next();if(t)return i(),void e.close();let o=r.byteLength;if(n){let e=c+=o;n(e)}e.enqueue(new Uint8Array(r))}catch(e){throw i(e),e}},cancel:e=>(i(e),a.return())},{highWaterMark:2})},Ure="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,Wre=Ure&&"function"==typeof ReadableStream,$re=Ure&&("function"==typeof TextEncoder?(qre=new TextEncoder,e=>qre.encode(e)):async e=>new Uint8Array(await new Response(e).arrayBuffer()));var qre;const Gre=(e,...t)=>{try{return!!e(...t)}catch(e){return!1}},Yre=Wre&&Gre((()=>{let e=!1;const t=new Request(zre.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Kre=Wre&&Gre((()=>Jte.isReadableStream(new Response("").body))),Xre={stream:Kre&&(e=>e.body)};var Qre;Ure&&(Qre=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!Xre[e]&&(Xre[e]=Jte.isFunction(Qre[e])?t=>t[e]():(t,n)=>{throw new Xne(`Response type '${e}' is not supported`,Xne.ERR_NOT_SUPPORT,n)})})));var Jre=Ure&&(async e=>{let{url:t,method:n,data:r,signal:a,cancelToken:o,timeout:c,onDownloadProgress:i,onUploadProgress:l,responseType:s,headers:h,withCredentials:d="same-origin",fetchOptions:u}=Pre(e);s=s?(s+"").toLowerCase():"text";let m,p=Ire([a,o&&o.toAbortSignal()],c);const v=p&&p.unsubscribe&&(()=>{p.unsubscribe()});let f;try{if(l&&Yre&&"get"!==n&&"head"!==n&&0!==(f=await(async(e,t)=>{const n=Jte.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(Jte.isBlob(e))return e.size;if(Jte.isSpecCompliantForm(e)){const t=new Request(zre.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return Jte.isArrayBufferView(e)||Jte.isArrayBuffer(e)?e.byteLength:(Jte.isURLSearchParams(e)&&(e+=""),Jte.isString(e)?(await $re(e)).byteLength:void 0)})(t):n})(h,r))){let e,n=new Request(t,{method:"POST",body:r,duplex:"half"});if(Jte.isFormData(r)&&(e=n.headers.get("content-type"))&&h.setContentType(e),n.body){const[e,t]=Tre(f,Sre(Ore(l)));r=jre(n.body,65536,e,t)}}Jte.isString(d)||(d=d?"include":"omit");const a="credentials"in Request.prototype;m=new Request(t,{...u,signal:p,method:n.toUpperCase(),headers:h.normalize().toJSON(),body:r,duplex:"half",credentials:a?d:void 0});let o=await fetch(m);const c=Kre&&("stream"===s||"response"===s);if(Kre&&(i||c&&v)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=o[t]}));const t=Jte.toFiniteNumber(o.headers.get("content-length")),[n,r]=i&&Tre(t,Sre(Ore(i),!0))||[];o=new Response(jre(o.body,65536,n,(()=>{r&&r(),v&&v()})),e)}s=s||"text";let z=await Xre[Jte.findKey(Xre,s)||"text"](o,e);return!c&&v&&v(),await new Promise(((t,n)=>{xre(t,n,{data:z,headers:Cre.from(o.headers),status:o.status,statusText:o.statusText,config:e,request:m})}))}catch(t){if(v&&v(),t&&"TypeError"===t.name&&/fetch/i.test(t.message))throw Object.assign(new Xne("Network Error",Xne.ERR_NETWORK,e,m),{cause:t.cause||t});throw Xne.from(t,t&&t.code,e,m)}});const Zre={http:null,xhr:Fre,fetch:Jre};Jte.forEach(Zre,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));const eae=e=>`- ${e}`,tae=e=>Jte.isFunction(e)||null===e||!1===e;var nae=e=>{e=Jte.isArray(e)?e:[e];const{length:t}=e;let n,r;const a={};for(let o=0;o<t;o++){let t;if(n=e[o],r=n,!tae(n)&&(r=Zre[(t=String(n)).toLowerCase()],void 0===r))throw new Xne(`Unknown adapter '${t}'`);if(r)break;a[t||"#"+o]=r}if(!r){const e=Object.entries(a).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new Xne("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(eae).join("\n"):" "+eae(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return r};function rae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new kre(null,e)}function aae(e){return rae(e),e.headers=Cre.from(e.headers),e.data=Lre.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),nae(e.adapter||yre.adapter)(e).then((function(t){return rae(e),t.data=Lre.call(e,e.transformResponse,t),t.headers=Cre.from(t.headers),t}),(function(t){return wre(t)||(rae(e),t&&t.response&&(t.response.data=Lre.call(e,e.transformResponse,t.response),t.response.headers=Cre.from(t.response.headers))),Promise.reject(t)}))}const oae={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{oae[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));const cae={};oae.transitional=function(e,t,n){function r(e,t){return"[Axios v1.7.9] Transitional option '"+e+"'"+t+(n?". "+n:"")}return(n,a,o)=>{if(!1===e)throw new Xne(r(a," has been removed"+(t?" in "+t:"")),Xne.ERR_DEPRECATED);return t&&!cae[a]&&(cae[a]=!0,console.warn(r(a," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,a,o)}},oae.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};var iae={assertOptions:function(e,t,n){if("object"!=typeof e)throw new Xne("options must be an object",Xne.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let a=r.length;for(;a-- >0;){const o=r[a],c=t[o];if(c){const t=e[o],n=void 0===t||c(t,o,e);if(!0!==n)throw new Xne("option "+o+" must be "+n,Xne.ERR_BAD_OPTION_VALUE)}else if(!0!==n)throw new Xne("Unknown option "+o,Xne.ERR_BAD_OPTION)}},validators:oae};const lae=iae.validators;class sae{constructor(e){this.defaults=e,this.interceptors={request:new sre,response:new sre}}async request(e,t){try{return await this._request(e,t)}catch(e){if(e instanceof Error){let t={};Error.captureStackTrace?Error.captureStackTrace(t):t=new Error;const n=t.stack?t.stack.replace(/^.+\n/,""):"";try{e.stack?n&&!String(e.stack).endsWith(n.replace(/^.+\n.+\n/,""))&&(e.stack+="\n"+n):e.stack=n}catch(e){}}throw e}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=Dre(this.defaults,t);const{transitional:n,paramsSerializer:r,headers:a}=t;void 0!==n&&iae.assertOptions(n,{silentJSONParsing:lae.transitional(lae.boolean),forcedJSONParsing:lae.transitional(lae.boolean),clarifyTimeoutError:lae.transitional(lae.boolean)},!1),null!=r&&(Jte.isFunction(r)?t.paramsSerializer={serialize:r}:iae.assertOptions(r,{encode:lae.function,serialize:lae.function},!0)),iae.assertOptions(t,{baseUrl:lae.spelling("baseURL"),withXsrfToken:lae.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=a&&Jte.merge(a.common,a[t.method]);a&&Jte.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete a[e]})),t.headers=Cre.concat(o,a);const c=[];let i=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(i=i&&e.synchronous,c.unshift(e.fulfilled,e.rejected))}));const l=[];let s;this.interceptors.response.forEach((function(e){l.push(e.fulfilled,e.rejected)}));let h,d=0;if(!i){const e=[aae.bind(this),void 0];for(e.unshift.apply(e,c),e.push.apply(e,l),h=e.length,s=Promise.resolve(t);d<h;)s=s.then(e[d++],e[d++]);return s}h=c.length;let u=t;for(d=0;d<h;){const t=c[d++],n=c[d++];try{u=t(u)}catch(e){n.call(this,e);break}}try{s=aae.call(this,u)}catch(e){return Promise.reject(e)}for(d=0,h=l.length;d<h;)s=s.then(l[d++],l[d++]);return s}getUri(e){return lre(Nre((e=Dre(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}Jte.forEach(["delete","get","head","options"],(function(e){sae.prototype[e]=function(t,n){return this.request(Dre(n||{},{method:e,url:t,data:(n||{}).data}))}})),Jte.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,a){return this.request(Dre(a||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}sae.prototype[e]=t(),sae.prototype[e+"Form"]=t(!0)}));class hae{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const n=this;this.promise.then((e=>{if(!n._listeners)return;let t=n._listeners.length;for(;t-- >0;)n._listeners[t](e);n._listeners=null})),this.promise.then=e=>{let t;const r=new Promise((e=>{n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e,r,a){n.reason||(n.reason=new kre(e,r,a),t(n.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new hae((function(t){e=t})),cancel:e}}}const dae={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(dae).forEach((([e,t])=>{dae[t]=e}));const uae=function e(t){const n=new sae(t),r=lte(sae.prototype.request,n);return Jte.extend(r,sae.prototype,n,{allOwnKeys:!0}),Jte.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(Dre(t,n))},r}(yre);uae.Axios=sae,uae.CanceledError=kre,uae.CancelToken=hae,uae.isCancel=wre,uae.VERSION="1.7.9",uae.toFormData=rre,uae.AxiosError=Xne,uae.Cancel=uae.CanceledError,uae.all=function(e){return Promise.all(e)},uae.spread=function(e){return function(t){return e.apply(null,t)}},uae.isAxiosError=function(e){return Jte.isObject(e)&&!0===e.isAxiosError},uae.mergeConfig=Dre,uae.AxiosHeaders=Cre,uae.formToJSON=e=>gre(Jte.isHTMLForm(e)?new FormData(e):e),uae.getAdapter=nae,uae.HttpStatusCode=dae,uae.default=uae;var mae=function(){function e(){}return e.convertJsonToQueryParamsString=function(e){return Object.keys(e).map((function(t){return t+"="+e[t]})).join("&")},e}(),pae=function(){function e(e){var t=this;this._backendBaseUrl="",this.updatePdf=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfApisEndPointRoute()),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfData=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchOnlyPdfPagesData=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createCommentThread=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.deleteCommentThread=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/delete"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.getCommentThreadById=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/").concat(e.commentThreadId))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchCommentThreads=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/commentThreads?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createComment=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfApisEndPointRoute(),"/commentThreads/comments"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchUsersOfPdf=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfApisEndPointRoute(),"/getUsers?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createPageAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:if(Object.keys(e.annotation||{}).length>1)throw new Error("invalid request payload");return[4,null===(n=this.api)||void 0===n?void 0:n.post(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchAllAnnotationsOfThePage=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.get("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.updatePageAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put(this.getPdfPagesAnnotationApisEndPointRoute(),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.deletePageAnnotation=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.delete("".concat(this.getPdfPagesAnnotationApisEndPointRoute(),"?").concat(mae.convertJsonToQueryParamsString(e)))];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.fetchPdfScales=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute(),"/get"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.createPdfScale=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.post("".concat(this.getPdfScalesApisEndPointRoute()),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.deletePdfScale=function(e){return Ree(t,void 0,void 0,(function(){var t;return Nee(this,(function(n){switch(n.label){case 0:return[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfScalesApisEndPointRoute(),"/delete"),e)];case 1:return n.sent(),[2]}}))}))},this.updatePdfScale=function(e){return Ree(t,void 0,void 0,(function(){var t,n;return Nee(this,(function(r){switch(r.label){case 0:return[4,null===(n=this.api)||void 0===n?void 0:n.put("".concat(this.getPdfScalesApisEndPointRoute(),"/update"),e)];case 1:return[2,null==(t=r.sent())?void 0:t.data]}}))}))},this.convertImageToPdf=function(e){var n=e.imageDownloadUrl,r=e.imageWidth,a=e.imageHeight;return Ree(t,void 0,void 0,(function(){var e,t,o,c,i;return Nee(this,(function(l){switch(l.label){case 0:return e={pdfFileName:"image.pdf",imageDetails:{imageDownloadUrl:n,imageWidth:r,imageHeight:a}},[4,null===(o=this.api)||void 0===o?void 0:o.post("".concat(this.getPdfApisEndPointRoute()),e)];case 1:if(t=l.sent(),!(null===(c=null==t?void 0:t.data)||void 0===c?void 0:c._id))throw new Error("pdfId not found");return[4,null===(i=this.api)||void 0===i?void 0:i.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==t?void 0:t.data._id})];case 2:return l.sent(),[2,{_id:null==t?void 0:t.data._id}]}}))}))},this.backendBaseUrl=e.backendBaseUrl,this.api=uae.create({baseURL:this.backendBaseUrl,headers:{"Content-type":"application/json; charset=utf-8"},withCredentials:!0})}return Object.defineProperty(e.prototype,"backendBaseUrl",{get:function(){return this._backendBaseUrl},set:function(e){this._backendBaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"api",{get:function(){return this._api},set:function(e){this._api=e},enumerable:!1,configurable:!0}),e.prototype.getPdfApisEndPointRoute=function(){return"".concat(this.backendBaseUrl,"/pdfs")},e.prototype.getPdfPagesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/pages")},e.prototype.getPdfScalesApisEndPointRoute=function(){return"".concat(this.getPdfApisEndPointRoute(),"/scales")},e.prototype.getPdfPagesAnnotationApisEndPointRoute=function(){return"".concat(this.getPdfPagesApisEndPointRoute(),"/annotation")},e.calculateDistanceBetweenTwoCoordinatesInPdfPagePoints=function(e){var t=e.normalisedCoordinates2.x-e.normalisedCoordinates1.x,n=e.normalisedCoordinates2.y-e.normalisedCoordinates1.y;return Math.sqrt(t*t+n*n)/(e.pdfPageImageOriginalWidth/e.pdfPageOriginalWidthInPoints)},e.convertPdfPagePointsDistanceToInches=function(e){return e.pdfPagePointsDistance/72},e.convertInchesToCentimeters=function(e){return 2.54*e.inches},e.convertInchesToMeters=function(e){return e.inches/39.37},e.convertInchesToFeet=function(e){return e.inches/12},e.convertInchesDistanceToPdfPagePoints=function(e){return 72*e.inchesDistance},e.isUserMoreNearToHorizontalAxisOrVerticalAxis=function(e){var t=e.firstCoordinate,n=e.secondCoordinate,r=n.x-t.x,a=n.y-t.y;return Math.abs(r)>Math.abs(a)?"horizontal":"vertical"},e.prototype.insertPdfAndItsPagesInDb=function(e){var t,n,r;return Ree(this,void 0,void 0,(function(){var a,o,c;return Nee(this,(function(i){switch(i.label){case 0:return(a=new FormData).append("pdfDownloadUrl",e.pdfSourceUrl),e.pdfFileName&&a.append("pdfFileName",e.pdfFileName),[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),a,{headers:{"Content-Type":"multipart/form-data"}})];case 1:if(o=i.sent(),!(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return c=null===(r=this.api)||void 0===r?void 0:r.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==o?void 0:o.data._id}),e.shouldWaitForPdfPagesCreation?[4,c]:[3,3];case 2:i.sent(),i.label=3;case 3:return[2,{_id:null==o?void 0:o.data._id}]}}))}))},e.convertNormalisedCoordinatesToUnNormalisedCoordinates=function(t){for(var n=t.normalisedCoordinates,r=t.normalisedXDimension,a=t.normalisedYDimension,o=t.unNormalisedXDimension,c=t.unNormalisedYDimension,i=[],l=0,s=n;l<s.length;l++){var h=s[l],d=h.x,u=h.y,m=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:d,normalisedDimension:r,unNormalisedDimension:o}),p=e.convertNormalisedValueToUnNormalisedForShowingInUI({normalisedValue:u,normalisedDimension:a,unNormalisedDimension:c});i.push({x:m,y:p})}return i},e.doNotMakeCoordinatesGoOutOfBoundary=function(e){for(var t=e.coordinates,n=e.coordinateBoundaries,r=0,a=t;r<a.length;r++){var o=a[r];o.x<n.xMin?o.x=n.xMin:o.x>n.xMax&&(o.x=n.xMax),o.y<n.yMin?o.y=n.yMin:o.y>n.yMax&&(o.y=n.yMax)}return t},e.prototype.insertPdfAndItsPagesInDBViaHTML=function(e){var t,n,r;return Ree(this,void 0,void 0,(function(){var a,o,c,i,l,s,h;return Nee(this,(function(d){switch(d.label){case 0:if(!(a=document.getElementById(e.htmlElementId)))throw new Error("htmlELement corresponding to the id not found");return o=a.outerHTML,e.cssClassNamesWhichShouldBeRemovedBeforeHtmlToPdfConversion.forEach((function(e){o=o.replaceAll(e,"")})),c=Array.from(document.querySelectorAll("style")).map((function(e){return e.outerHTML})).join("\n"),i='\n <html>\n <head>\n <meta charset="UTF-8">\n '.concat(c,"\n </head>\n <body>\n ").concat(o,"\n </body>\n </html>\n "),l={pdfFileName:"react-html.pdf",htmlDocument:{document:i,width:a.clientWidth}},[4,null===(t=this.api)||void 0===t?void 0:t.post("".concat(this.getPdfApisEndPointRoute()),l)];case 1:if(s=d.sent(),!(null===(n=null==s?void 0:s.data)||void 0===n?void 0:n._id))throw new Error("pdfId not found");return h=null===(r=this.api)||void 0===r?void 0:r.post("".concat(this.getPdfApisEndPointRoute(),"/pdf-pages-as-images"),{pdfId:null==s?void 0:s.data._id}),e.shouldWaitForPdfPagesCreation?[4,h]:[3,3];case 2:d.sent(),d.label=3;case 3:return[2,{_id:null==s?void 0:s.data._id}]}}))}))},e.convertValueFromOneUnitToAnotherUnit=function(e){var t=e.valueToConvert,n=e.fromUnit,r=e.toUnit;if(n===r)return t;var a=0;if("cm"===n)if("m"===r)a=t/100;else if("inch"===r)a=t/2.54;else{if("ft"!==r)throw new Error("Invalid toUnit");a=t/30.48}else if("m"===n)if("cm"===r)a=100*t;else if("inch"===r)a=39.37*t;else{if("ft"!==r)throw new Error("Invalid toUnit");a=3.281*t}else if("inch"===n)if("cm"===r)a=2.54*t;else if("m"===r)a=t/39.37;else{if("ft"!==r)throw new Error("Invalid toUnit");a=t/12}else{if("ft"!==n)throw new Error("Invalid fromUnit");if("cm"===r)a=30.48*t;else if("m"===r)a=t/3.281;else{if("inch"!==r)throw new Error("Invalid toUnit");a=12*t}}return a},e.convertNormalisedValueToUnNormalisedForShowingInUI=function(e){var t=e.normalisedValue,n=e.normalisedDimension;return t*(e.unNormalisedDimension/n)},e.convertUnNormalisedValueToNormalised=function(e){var t=e.unNormalisedValue,n=e.normalisedDimension;return t/(e.unNormalisedDimension/n)},e.convertCoordinatesArrayToNumberArray=function(e){for(var t=e.coordinates,n=[],r=0;r<t.length;r++)n.push(t[r].x),n.push(t[r].y);return n},e}(),vae=function(){function e(){}return e.getImageWidthHeightFromURL=function(e){return Ree(this,void 0,void 0,(function(){var t;return Nee(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,new Promise((function(t,n){try{var r=new Image;r.onload=function(){return t({width:r.width,height:r.height})},r.src=e}catch(e){n(new Error(e.message))}}))];case 1:return[2,n.sent()];case 2:throw t=n.sent(),new Error(t.message);case 3:return[2]}}))}))},e.getImageHeight=function(e,t){return e/t},e.getImageWidth=function(e,t){return e*t},e.downloadImage=function(e){return new Promise((function(t,n){var r=new Image;r.onload=function(){return t(r)},r.onerror=function(){return n(new Error("Image loading having url ".concat(e," got failed")))},r.src=e}))},e}(),fae={d:(e,t)=>{for(var n in t)fae.o(t,n)&&!fae.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},zae=globalThis.pdfjsLib={};fae.d(zae,{AbortException:()=>$ae,AnnotationEditorLayer:()=>Hle,AnnotationEditorParamsType:()=>Vae,AnnotationEditorType:()=>Hae,AnnotationEditorUIManager:()=>Soe,AnnotationLayer:()=>ale,AnnotationMode:()=>bae,ColorPicker:()=>ple,DOMSVGFactory:()=>Lie,DrawLayer:()=>Vle,FeatureTest:()=>Kae,GlobalWorkerOptions:()=>Lce,ImageKind:()=>Lae,InvalidPDFException:()=>Bae,MissingPDFException:()=>jae,OPS:()=>kae,OutputScale:()=>Eoe,PDFDataRangeTransport:()=>hie,PDFDateString:()=>voe,PDFWorker:()=>pie,PasswordResponses:()=>xae,PermissionFlag:()=>Cae,PixelsPerInch:()=>roe,RenderingCancelledException:()=>coe,TextLayer:()=>eie,TouchManager:()=>Ooe,UnexpectedResponseException:()=>Uae,Util:()=>Qae,VerbosityLevel:()=>wae,XfaLayer:()=>wie,build:()=>Eie,createValidAbsoluteUrl:()=>_ae,fetchData:()=>aoe,getDocument:()=>iie,getFilenameFromUrl:()=>soe,getPdfFilenameFromUrl:()=>hoe,getXfaPageViewport:()=>foe,isDataScheme:()=>ioe,isPdfFile:()=>loe,noContextMenu:()=>moe,normalizeUnicode:()=>eoe,setLayerDimensions:()=>Moe,shadow:()=>Dae,stopEvent:()=>poe,version:()=>Mie});const gae=!("object"!=typeof xt||xt+""!="[object process]"||xt.versions.nw||xt.versions.electron&&xt.type&&"browser"!==xt.type),yae=[1,0,0,1,0,0],Mae=[.001,0,0,.001,0,0],Eae=1.35,bae={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},Hae={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},Vae={RESIZE:1,CREATE:2,FREETEXT_SIZE:11,FREETEXT_COLOR:12,FREETEXT_OPACITY:13,INK_COLOR:21,INK_THICKNESS:22,INK_OPACITY:23,HIGHLIGHT_COLOR:31,HIGHLIGHT_DEFAULT_COLOR:32,HIGHLIGHT_THICKNESS:33,HIGHLIGHT_FREE:34,HIGHLIGHT_SHOW_ALL:35,DRAW_STEP:41},Cae={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},Lae={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},wae={ERRORS:0,WARNINGS:1,INFOS:5},kae={dependency:1,setLineWidth:2,setLineCap:3,setLineJoin:4,setMiterLimit:5,setDash:6,setRenderingIntent:7,setFlatness:8,setGState:9,save:10,restore:11,transform:12,moveTo:13,lineTo:14,curveTo:15,curveTo2:16,curveTo3:17,closePath:18,rectangle:19,stroke:20,closeStroke:21,fill:22,eoFill:23,fillStroke:24,eoFillStroke:25,closeFillStroke:26,closeEOFillStroke:27,endPath:28,clip:29,eoClip:30,beginText:31,endText:32,setCharSpacing:33,setWordSpacing:34,setHScale:35,setLeading:36,setFont:37,setTextRenderingMode:38,setTextRise:39,moveText:40,setLeadingMoveText:41,setTextMatrix:42,nextLine:43,showText:44,showSpacedText:45,nextLineShowText:46,nextLineSetSpacingShowText:47,setCharWidth:48,setCharWidthAndBounds:49,setStrokeColorSpace:50,setFillColorSpace:51,setStrokeColor:52,setStrokeColorN:53,setFillColor:54,setFillColorN:55,setStrokeGray:56,setFillGray:57,setStrokeRGBColor:58,setFillRGBColor:59,setStrokeCMYKColor:60,setFillCMYKColor:61,shadingFill:62,beginInlineImage:63,beginImageData:64,endInlineImage:65,paintXObject:66,markPoint:67,markPointProps:68,beginMarkedContent:69,beginMarkedContentProps:70,endMarkedContent:71,beginCompat:72,endCompat:73,paintFormXObjectBegin:74,paintFormXObjectEnd:75,beginGroup:76,endGroup:77,beginAnnotation:80,endAnnotation:81,paintImageMaskXObject:83,paintImageMaskXObjectGroup:84,paintImageXObject:85,paintInlineImageXObject:86,paintInlineImageXObjectGroup:87,paintImageXObjectRepeat:88,paintImageMaskXObjectRepeat:89,paintSolidColorImageMask:90,constructPath:91,setStrokeTransparent:92,setFillTransparent:93},xae={NEED_PASSWORD:1,INCORRECT_PASSWORD:2};let Sae=wae.WARNINGS;function Tae(){return Sae}function Oae(e){Sae>=wae.INFOS&&console.log(`Info: ${e}`)}function Aae(e){Sae>=wae.WARNINGS&&console.log(`Warning: ${e}`)}function Rae(e){throw new Error(e)}function Nae(e,t){e||Rae(t)}function _ae(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){const t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=decodeURIComponent(escape(e))}catch{}}const r=t?new URL(e,t):new URL(e);if(function(e){switch(e?.protocol){case"http:":case"https:":case"ftp:":case"mailto:":case"tel:":return!0;default:return!1}}(r))return r}catch{}return null}function Dae(e,t,n,r=!1){return Object.defineProperty(e,t,{value:n,enumerable:!r,configurable:!0,writable:!1}),n}const Pae=function(){function e(e,t){this.message=e,this.name=t}return e.prototype=new Error,e.constructor=e,e}();class Fae extends Pae{constructor(e,t){super(e,"PasswordException"),this.code=t}}class Iae extends Pae{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class Bae extends Pae{constructor(e){super(e,"InvalidPDFException")}}class jae extends Pae{constructor(e){super(e,"MissingPDFException")}}class Uae extends Pae{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class Wae extends Pae{constructor(e){super(e,"FormatError")}}class $ae extends Pae{constructor(e){super(e,"AbortException")}}function qae(e){"object"==typeof e&&void 0!==e?.length||Rae("Invalid argument for bytesToString");const t=e.length,n=8192;if(t<n)return String.fromCharCode.apply(null,e);const r=[];for(let a=0;a<t;a+=n){const o=Math.min(a+n,t),c=e.subarray(a,o);r.push(String.fromCharCode.apply(null,c))}return r.join("")}function Gae(e){"string"!=typeof e&&Rae("Invalid argument for stringToBytes");const t=e.length,n=new Uint8Array(t);for(let r=0;r<t;++r)n[r]=255&e.charCodeAt(r);return n}function Yae(e){const t=Object.create(null);for(const[n,r]of e)t[n]=r;return t}class Kae{static get isLittleEndian(){return Dae(this,"isLittleEndian",function(){const e=new Uint8Array(4);return e[0]=1,1===new Uint32Array(e.buffer,0,1)[0]}())}static get isEvalSupported(){return Dae(this,"isEvalSupported",function(){try{return new Function(""),!0}catch{return!1}}())}static get isOffscreenCanvasSupported(){return Dae(this,"isOffscreenCanvasSupported","undefined"!=typeof OffscreenCanvas)}static get isImageDecoderSupported(){return Dae(this,"isImageDecoderSupported","undefined"!=typeof ImageDecoder)}static get platform(){return"undefined"!=typeof navigator&&"string"==typeof navigator?.platform?Dae(this,"platform",{isMac:navigator.platform.includes("Mac"),isWindows:navigator.platform.includes("Win"),isFirefox:"string"==typeof navigator?.userAgent&&navigator.userAgent.includes("Firefox")}):Dae(this,"platform",{isMac:!1,isWindows:!1,isFirefox:!1})}static get isCSSRoundSupported(){return Dae(this,"isCSSRoundSupported",globalThis.CSS?.supports?.("width: round(1.5px, 1px)"))}}const Xae=Array.from(Array(256).keys(),(e=>e.toString(16).padStart(2,"0")));class Qae{static makeHexColor(e,t,n){return`#${Xae[e]}${Xae[t]}${Xae[n]}`}static scaleMinMax(e,t){let n;e[0]?(e[0]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[0],t[2]*=e[0],e[3]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[3],t[3]*=e[3]):(n=t[0],t[0]=t[1],t[1]=n,n=t[2],t[2]=t[3],t[3]=n,e[1]<0&&(n=t[1],t[1]=t[3],t[3]=n),t[1]*=e[1],t[3]*=e[1],e[2]<0&&(n=t[0],t[0]=t[2],t[2]=n),t[0]*=e[2],t[2]*=e[2]),t[0]+=e[4],t[1]+=e[5],t[2]+=e[4],t[3]+=e[5]}static transform(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}static applyTransform(e,t){return[e[0]*t[0]+e[1]*t[2]+t[4],e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){const n=t[0]*t[3]-t[1]*t[2];return[(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){const n=this.applyTransform(e,t),r=this.applyTransform(e.slice(2,4),t),a=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],r[0],a[0],o[0]),Math.min(n[1],r[1],a[1],o[1]),Math.max(n[0],r[0],a[0],o[0]),Math.max(n[1],r[1],a[1],o[1])]}static inverseTransform(e){const t=e[0]*e[3]-e[1]*e[2];return[e[3]/t,-e[1]/t,-e[2]/t,e[0]/t,(e[2]*e[5]-e[4]*e[3])/t,(e[4]*e[1]-e[5]*e[0])/t]}static singularValueDecompose2dScale(e){const t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],r=e[0]*t[1]+e[1]*t[3],a=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],c=(n+o)/2,i=Math.sqrt((n+o)**2-4*(n*o-a*r))/2,l=c+i||1,s=c-i||1;return[Math.sqrt(l),Math.sqrt(s)]}static normalizeRect(e){const t=e.slice(0);return e[0]>e[2]&&(t[0]=e[2],t[2]=e[0]),e[1]>e[3]&&(t[1]=e[3],t[3]=e[1]),t}static intersect(e,t){const n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),r=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>r)return null;const a=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return a>o?null:[n,a,r,o]}static#e(e,t,n,r,a,o,c,i,l,s){if(l<=0||l>=1)return;const h=1-l,d=l*l,u=d*l,m=h*(h*(h*e+3*l*t)+3*d*n)+u*r,p=h*(h*(h*a+3*l*o)+3*d*c)+u*i;s[0]=Math.min(s[0],m),s[1]=Math.min(s[1],p),s[2]=Math.max(s[2],m),s[3]=Math.max(s[3],p)}static#t(e,t,n,r,a,o,c,i,l,s,h,d){if(Math.abs(l)<1e-12)return void(Math.abs(s)>=1e-12&&this.#e(e,t,n,r,a,o,c,i,-h/s,d));const u=s**2-4*h*l;if(u<0)return;const m=Math.sqrt(u),p=2*l;this.#e(e,t,n,r,a,o,c,i,(-s+m)/p,d),this.#e(e,t,n,r,a,o,c,i,(-s-m)/p,d)}static bezierBoundingBox(e,t,n,r,a,o,c,i,l){return l?(l[0]=Math.min(l[0],e,c),l[1]=Math.min(l[1],t,i),l[2]=Math.max(l[2],e,c),l[3]=Math.max(l[3],t,i)):l=[Math.min(e,c),Math.min(t,i),Math.max(e,c),Math.max(t,i)],this.#t(e,n,a,c,t,r,o,i,3*(3*(n-a)-e+c),6*(e-2*n+a),3*(n-e),l),this.#t(e,n,a,c,t,r,o,i,3*(3*(r-o)-t+i),6*(t-2*r+o),3*(r-t),l),l}}let Jae=null,Zae=null;function eoe(e){return Jae||(Jae=/([\u00a0\u00b5\u037e\u0eb3\u2000-\u200a\u202f\u2126\ufb00-\ufb04\ufb06\ufb20-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufba1\ufba4-\ufba9\ufbae-\ufbb1\ufbd3-\ufbdc\ufbde-\ufbe7\ufbea-\ufbf8\ufbfc-\ufbfd\ufc00-\ufc5d\ufc64-\ufcf1\ufcf5-\ufd3d\ufd88\ufdf4\ufdfa-\ufdfb\ufe71\ufe77\ufe79\ufe7b\ufe7d]+)|(\ufb05+)/gu,Zae=new Map([["ſt","ſt"]])),e.replaceAll(Jae,((e,t,n)=>t?t.normalize("NFKC"):Zae.get(n)))}const toe="pdfjs_internal_id_";"function"!=typeof Promise.try&&(Promise.try=function(e,...t){return new Promise((n=>{n(e(...t))}))});const noe="http://www.w3.org/2000/svg";class roe{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function aoe(e,t="text"){if(uoe(e,document.baseURI)){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);switch(t){case"arraybuffer":return n.arrayBuffer();case"blob":return n.blob();case"json":return n.json()}return n.text()}return new Promise(((n,r)=>{const a=new XMLHttpRequest;a.open("GET",e,!0),a.responseType=t,a.onreadystatechange=()=>{if(a.readyState===XMLHttpRequest.DONE)if(200!==a.status&&0!==a.status)r(new Error(a.statusText));else{switch(t){case"arraybuffer":case"blob":case"json":return void n(a.response)}n(a.responseText)}},a.send(null)}))}class ooe{constructor({viewBox:e,userUnit:t,scale:n,rotation:r,offsetX:a=0,offsetY:o=0,dontFlip:c=!1}){this.viewBox=e,this.userUnit=t,this.scale=n,this.rotation=r,this.offsetX=a,this.offsetY=o,n*=t;const i=(e[2]+e[0])/2,l=(e[3]+e[1])/2;let s,h,d,u,m,p,v,f;switch((r%=360)<0&&(r+=360),r){case 180:s=-1,h=0,d=0,u=1;break;case 90:s=0,h=1,d=1,u=0;break;case 270:s=0,h=-1,d=-1,u=0;break;case 0:s=1,h=0,d=0,u=-1;break;default:throw new Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}c&&(d=-d,u=-u),0===s?(m=Math.abs(l-e[1])*n+a,p=Math.abs(i-e[0])*n+o,v=(e[3]-e[1])*n,f=(e[2]-e[0])*n):(m=Math.abs(i-e[0])*n+a,p=Math.abs(l-e[1])*n+o,v=(e[2]-e[0])*n,f=(e[3]-e[1])*n),this.transform=[s*n,h*n,d*n,u*n,m-s*n*i-d*n*l,p-h*n*i-u*n*l],this.width=v,this.height=f}get rawDims(){const{userUnit:e,viewBox:t}=this,n=t.map((t=>t*e));return Dae(this,"rawDims",{pageWidth:n[2]-n[0],pageHeight:n[3]-n[1],pageX:n[0],pageY:n[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:r=this.offsetY,dontFlip:a=!1}={}){return new ooe({viewBox:this.viewBox.slice(),userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:a})}convertToViewportPoint(e,t){return Qae.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){const t=Qae.applyTransform([e[0],e[1]],this.transform),n=Qae.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return Qae.applyInverseTransform([e,t],this.transform)}}class coe extends Pae{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function ioe(e){const t=e.length;let n=0;for(;n<t&&""===e[n].trim();)n++;return"data:"===e.substring(n,n+5).toLowerCase()}function loe(e){return"string"==typeof e&&/\.pdf$/i.test(e)}function soe(e){return[e]=e.split(/[#?]/,1),e.substring(e.lastIndexOf("/")+1)}function hoe(e,t="document.pdf"){if("string"!=typeof e)return t;if(ioe(e))return Aae('getPdfFilenameFromUrl: ignore "data:"-URL for performance reasons.'),t;const n=/[^/?#=]+\.pdf\b(?!.*\.pdf\b)/i,r=/^(?:(?:[^:]+:)?\/\/[^/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/.exec(e);let a=n.exec(r[1])||n.exec(r[2])||n.exec(r[3]);if(a&&(a=a[0],a.includes("%")))try{a=n.exec(decodeURIComponent(a))[0]}catch{}return a||t}class doe{started=Object.create(null);times=[];time(e){e in this.started&&Aae(`Timer is already running for ${e}`),this.started[e]=Date.now()}timeEnd(e){e in this.started||Aae(`Timer has not been started for ${e}`),this.times.push({name:e,start:this.started[e],end:Date.now()}),delete this.started[e]}toString(){const e=[];let t=0;for(const{name:e}of this.times)t=Math.max(e.length,t);for(const{name:n,start:r,end:a}of this.times)e.push(`${n.padEnd(t)} ${a-r}ms\n`);return e.join("")}}function uoe(e,t){try{const{protocol:n}=t?new URL(e,t):new URL(e);return"http:"===n||"https:"===n}catch{return!1}}function moe(e){e.preventDefault()}function poe(e){e.preventDefault(),e.stopPropagation()}class voe{static#n;static toDateObject(e){if(!e||"string"!=typeof e)return null;this.#n||=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?");const t=this.#n.exec(e);if(!t)return null;const n=parseInt(t[1],10);let r=parseInt(t[2],10);r=r>=1&&r<=12?r-1:0;let a=parseInt(t[3],10);a=a>=1&&a<=31?a:1;let o=parseInt(t[4],10);o=o>=0&&o<=23?o:0;let c=parseInt(t[5],10);c=c>=0&&c<=59?c:0;let i=parseInt(t[6],10);i=i>=0&&i<=59?i:0;const l=t[7]||"Z";let s=parseInt(t[8],10);s=s>=0&&s<=23?s:0;let h=parseInt(t[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===l?(o+=s,c+=h):"+"===l&&(o-=s,c-=h),new Date(Date.UTC(n,r,a,o,c,i))}}function foe(e,{scale:t=1,rotation:n=0}){const{width:r,height:a}=e.attributes.style,o=[0,0,parseInt(r),parseInt(a)];return new ooe({viewBox:o,userUnit:1,scale:t,rotation:n})}function zoe(e){if(e.startsWith("#")){const t=parseInt(e.slice(1),16);return[(16711680&t)>>16,(65280&t)>>8,255&t]}return e.startsWith("rgb(")?e.slice(4,-1).split(",").map((e=>parseInt(e))):e.startsWith("rgba(")?e.slice(5,-1).split(",").map((e=>parseInt(e))).slice(0,3):(Aae(`Not a valid color format: "${e}"`),[0,0,0])}function goe(e){const{a:t,b:n,c:r,d:a,e:o,f:c}=e.getTransform();return[t,n,r,a,o,c]}function yoe(e){const{a:t,b:n,c:r,d:a,e:o,f:c}=e.getTransform().invertSelf();return[t,n,r,a,o,c]}function Moe(e,t,n=!1,r=!0){if(t instanceof ooe){const{pageWidth:r,pageHeight:a}=t.rawDims,{style:o}=e,c=Kae.isCSSRoundSupported,i=`var(--scale-factor) * ${r}px`,l=`var(--scale-factor) * ${a}px`,s=c?`round(down, ${i}, var(--scale-round-x, 1px))`:`calc(${i})`,h=c?`round(down, ${l}, var(--scale-round-y, 1px))`:`calc(${l})`;n&&t.rotation%180!=0?(o.width=h,o.height=s):(o.width=s,o.height=h)}r&&e.setAttribute("data-main-rotation",t.rotation)}class Eoe{constructor(){const e=window.devicePixelRatio||1;this.sx=e,this.sy=e}get scaled(){return 1!==this.sx||1!==this.sy}get symmetric(){return this.sx===this.sy}}class boe{#r=null;#a=null;#o;#c=null;#i=null;static#l=null;constructor(e){this.#o=e,boe.#l||=Object.freeze({freetext:"pdfjs-editor-remove-freetext-button",highlight:"pdfjs-editor-remove-highlight-button",ink:"pdfjs-editor-remove-ink-button",stamp:"pdfjs-editor-remove-stamp-button"})}render(){const e=this.#r=document.createElement("div");e.classList.add("editToolbar","hidden"),e.setAttribute("role","toolbar");const t=this.#o._uiManager._signal;e.addEventListener("contextmenu",moe,{signal:t}),e.addEventListener("pointerdown",boe.#s,{signal:t});const n=this.#c=document.createElement("div");n.className="buttons",e.append(n);const r=this.#o.toolbarPosition;if(r){const{style:t}=e,n="ltr"===this.#o._uiManager.direction?1-r[0]:r[0];t.insetInlineEnd=100*n+"%",t.top=`calc(${100*r[1]}% + var(--editor-toolbar-vert-offset))`}return this.#h(),e}get div(){return this.#r}static#s(e){e.stopPropagation()}#d(e){this.#o._focusEventsAllowed=!1,poe(e)}#u(e){this.#o._focusEventsAllowed=!0,poe(e)}#m(e){const t=this.#o._uiManager._signal;e.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#u.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",moe,{signal:t})}hide(){this.#r.classList.add("hidden"),this.#a?.hideDropdown()}show(){this.#r.classList.remove("hidden"),this.#i?.shown()}#h(){const{editorType:e,_uiManager:t}=this.#o,n=document.createElement("button");n.className="delete",n.tabIndex=0,n.setAttribute("data-l10n-id",boe.#l[e]),this.#m(n),n.addEventListener("click",(e=>{t.delete()}),{signal:t._signal}),this.#c.append(n)}get#p(){const e=document.createElement("div");return e.className="divider",e}async addAltText(e){const t=await e.render();this.#m(t),this.#c.prepend(t,this.#p),this.#i=e}addColorPicker(e){this.#a=e;const t=e.renderButton();this.#m(t),this.#c.prepend(t,this.#p)}remove(){this.#r.remove(),this.#a?.destroy(),this.#a=null}}class Hoe{#c=null;#r=null;#v;constructor(e){this.#v=e}#f(){const e=this.#r=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",moe,{signal:this.#v._signal});const t=this.#c=document.createElement("div");return t.className="buttons",e.append(t),this.#z(),e}#g(e,t){let n=0,r=0;for(const a of e){const e=a.y+a.height;if(e<n)continue;const o=a.x+(t?a.width:0);e>n?(r=o,n=e):t?o>r&&(r=o):o<r&&(r=o)}return[t?1-r:r,n]}show(e,t,n){const[r,a]=this.#g(t,n),{style:o}=this.#r||=this.#f();e.append(this.#r),o.insetInlineEnd=100*r+"%",o.top=`calc(${100*a}% + var(--editor-toolbar-vert-offset))`}hide(){this.#r.remove()}#z(){const e=document.createElement("button");e.className="highlightButton",e.tabIndex=0,e.setAttribute("data-l10n-id","pdfjs-highlight-floating-button1");const t=document.createElement("span");e.append(t),t.className="visuallyHidden",t.setAttribute("data-l10n-id","pdfjs-highlight-floating-button-label");const n=this.#v._signal;e.addEventListener("contextmenu",moe,{signal:n}),e.addEventListener("click",(()=>{this.#v.highlightSelection("floating_button")}),{signal:n}),this.#c.append(e)}}function Voe(e,t,n){for(const r of n)t.addEventListener(r,e[r].bind(e))}class Coe{#y=0;get id(){return"pdfjs_internal_editor_"+this.#y++}}class Loe{#M=function(){if("function"==typeof crypto.randomUUID)return crypto.randomUUID();const e=new Uint8Array(32);return crypto.getRandomValues(e),qae(e)}();#y=0;#E=null;static get _isSVGFittingCanvas(){const e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),t=new Image;return t.src='data:image/svg+xml;charset=UTF-8,<svg viewBox="0 0 1 1" width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="1" height="1" style="fill:red;"/></svg>',Dae(this,"_isSVGFittingCanvas",t.decode().then((()=>(e.drawImage(t,0,0,1,1,0,0,1,3),0===new Uint32Array(e.getImageData(0,0,1,1).data.buffer)[0]))))}async#b(e,t){this.#E||=new Map;let n=this.#E.get(e);if(null===n)return null;if(n?.bitmap)return n.refCounter+=1,n;try{let e;if(n||={bitmap:null,id:`image_${this.#M}_${this.#y++}`,refCounter:0,isSvg:!1},"string"==typeof t?(n.url=t,e=await aoe(t,"blob")):t instanceof File?e=n.file=t:t instanceof Blob&&(e=t),"image/svg+xml"===e.type){const t=Loe._isSVGFittingCanvas,r=new FileReader,a=new Image,o=new Promise(((e,o)=>{a.onload=()=>{n.bitmap=a,n.isSvg=!0,e()},r.onload=async()=>{const e=n.svgUrl=r.result;a.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e},a.onerror=r.onerror=o}));r.readAsDataURL(e),await o}else n.bitmap=await createImageBitmap(e);n.refCounter=1}catch(e){Aae(e),n=null}return this.#E.set(e,n),n&&this.#E.set(n.id,n),n}async getFromFile(e){const{lastModified:t,name:n,size:r,type:a}=e;return this.#b(`${t}_${n}_${r}_${a}`,e)}async getFromUrl(e){return this.#b(e,e)}async getFromBlob(e,t){const n=await t;return this.#b(e,n)}async getFromId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return null;if(t.bitmap)return t.refCounter+=1,t;if(t.file)return this.getFromFile(t.file);if(t.blobPromise){const{blobPromise:e}=t;return delete t.blobPromise,this.getFromBlob(t.id,e)}return this.getFromUrl(t.url)}getFromCanvas(e,t){this.#E||=new Map;let n=this.#E.get(e);if(n?.bitmap)return n.refCounter+=1,n;const r=new OffscreenCanvas(t.width,t.height);return r.getContext("2d").drawImage(t,0,0),n={bitmap:r.transferToImageBitmap(),id:`image_${this.#M}_${this.#y++}`,refCounter:1,isSvg:!1},this.#E.set(e,n),this.#E.set(n.id,n),n}getSvgUrl(e){const t=this.#E.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#E||=new Map;const t=this.#E.get(e);if(!t)return;if(t.refCounter-=1,0!==t.refCounter)return;const{bitmap:n}=t;if(!t.url&&!t.file){const e=new OffscreenCanvas(n.width,n.height);e.getContext("bitmaprenderer").transferFromImageBitmap(n),t.blobPromise=e.convertToBlob()}n.close?.(),t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#M}_`)}}class woe{#H=[];#V=!1;#C;#L=-1;constructor(e=128){this.#C=e}add({cmd:e,undo:t,post:n,mustExec:r,type:a=NaN,overwriteIfSameType:o=!1,keepUndo:c=!1}){if(r&&e(),this.#V)return;const i={cmd:e,undo:t,post:n,type:a};if(-1===this.#L)return this.#H.length>0&&(this.#H.length=0),this.#L=0,void this.#H.push(i);if(o&&this.#H[this.#L].type===a)return c&&(i.undo=this.#H[this.#L].undo),void(this.#H[this.#L]=i);const l=this.#L+1;l===this.#C?this.#H.splice(0,1):(this.#L=l,l<this.#H.length&&this.#H.splice(l)),this.#H.push(i)}undo(){if(-1===this.#L)return;this.#V=!0;const{undo:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1,this.#L-=1}redo(){if(this.#L<this.#H.length-1){this.#L+=1,this.#V=!0;const{cmd:e,post:t}=this.#H[this.#L];e(),t?.(),this.#V=!1}}hasSomethingToUndo(){return-1!==this.#L}hasSomethingToRedo(){return this.#L<this.#H.length-1}cleanType(e){if(-1!==this.#L){for(let t=this.#L;t>=0;t--)if(this.#H[t].type!==e)return this.#H.splice(t+1,this.#L-t),void(this.#L=t);this.#H.length=0,this.#L=-1}}destroy(){this.#H=null}}class koe{constructor(e){this.buffer=[],this.callbacks=new Map,this.allKeys=new Set;const{isMac:t}=Kae.platform;for(const[n,r,a={}]of e)for(const e of n){const n=e.startsWith("mac+");t&&n?(this.callbacks.set(e.slice(4),{callback:r,options:a}),this.allKeys.add(e.split("+").at(-1))):t||n||(this.callbacks.set(e,{callback:r,options:a}),this.allKeys.add(e.split("+").at(-1)))}}#w(e){e.altKey&&this.buffer.push("alt"),e.ctrlKey&&this.buffer.push("ctrl"),e.metaKey&&this.buffer.push("meta"),e.shiftKey&&this.buffer.push("shift"),this.buffer.push(e.key);const t=this.buffer.join("+");return this.buffer.length=0,t}exec(e,t){if(!this.allKeys.has(t.key))return;const n=this.callbacks.get(this.#w(t));if(!n)return;const{callback:r,options:{bubbles:a=!1,args:o=[],checker:c=null}}=n;c&&!c(e,t)||(r.bind(e,...o,t)(),a||poe(t))}}class xoe{static _colorsMapping=new Map([["CanvasText",[0,0,0]],["Canvas",[255,255,255]]]);get _colors(){const e=new Map([["CanvasText",null],["Canvas",null]]);return function(e){const t=document.createElement("span");t.style.visibility="hidden",document.body.append(t);for(const n of e.keys()){t.style.color=n;const r=window.getComputedStyle(t).color;e.set(n,zoe(r))}t.remove()}(e),Dae(this,"_colors",e)}convert(e){const t=zoe(e);if(!window.matchMedia("(forced-colors: active)").matches)return t;for(const[e,n]of this._colors)if(n.every(((e,n)=>e===t[n])))return xoe._colorsMapping.get(e);return t}getHexCode(e){const t=this._colors.get(e);return t?Qae.makeHexColor(...t):e}}class Soe{#k=new AbortController;#x=null;#S=new Map;#T=new Map;#O=null;#A=null;#R=null;#N=new woe;#_=null;#D=null;#P=0;#F=new Set;#I=null;#B=null;#j=new Set;_editorUndoBar=null;#U=!1;#W=!1;#$=!1;#q=null;#G=null;#Y=null;#K=null;#X=!1;#Q=null;#J=new Coe;#Z=!1;#ee=!1;#te=null;#ne=null;#re=null;#ae=null;#oe=Hae.NONE;#ce=new Set;#ie=null;#le=null;#se=null;#he={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#de=[0,0];#ue=null;#me=null;#pe=null;#ve=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){const e=Soe.prototype,t=e=>e.#me.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),n=(e,{target:t})=>{if(t instanceof HTMLInputElement){const{type:e}=t;return"text"!==e&&"number"!==e}return!0},r=this.TRANSLATE_SMALL,a=this.TRANSLATE_BIG;return Dae(this,"_keyboardManager",new koe([[["ctrl+a","mac+meta+a"],e.selectAll,{checker:n}],[["ctrl+z","mac+meta+z"],e.undo,{checker:n}],[["ctrl+y","ctrl+shift+z","mac+meta+shift+z","ctrl+shift+Z","mac+meta+shift+Z"],e.redo,{checker:n}],[["Backspace","alt+Backspace","ctrl+Backspace","shift+Backspace","mac+Backspace","mac+alt+Backspace","mac+ctrl+Backspace","Delete","ctrl+Delete","shift+Delete","mac+Delete"],e.delete,{checker:n}],[["Enter","mac+Enter"],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(t)&&!e.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#me.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-a,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[a,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-a],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,a],checker:t}]]))}constructor(e,t,n,r,a,o,c,i,l,s,h,d,u){const m=this._signal=this.#k.signal;this.#me=e,this.#pe=t,this.#O=n,this._eventBus=r,r._on("editingaction",this.onEditingAction.bind(this),{signal:m}),r._on("pagechanging",this.onPageChanging.bind(this),{signal:m}),r._on("scalechanging",this.onScaleChanging.bind(this),{signal:m}),r._on("rotationchanging",this.onRotationChanging.bind(this),{signal:m}),r._on("setpreference",this.onSetPreference.bind(this),{signal:m}),r._on("switchannotationeditorparams",(e=>this.updateParams(e.type,e.value)),{signal:m}),this.#fe(),this.#ze(),this.#ge(),this.#A=a.annotationStorage,this.#q=a.filterFactory,this.#le=o,this.#K=c||null,this.#U=i,this.#W=l,this.#$=s,this.#ae=h||null,this.viewParameters={realScale:roe.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1,this._editorUndoBar=d||null,this._supportsPinchToZoom=!1!==u}destroy(){this.#ve?.resolve(),this.#ve=null,this.#k?.abort(),this.#k=null,this._signal=null;for(const e of this.#T.values())e.destroy();this.#T.clear(),this.#S.clear(),this.#j.clear(),this.#x=null,this.#ce.clear(),this.#N.destroy(),this.#O?.destroy(),this.#Q?.hide(),this.#Q=null,this.#G&&(clearTimeout(this.#G),this.#G=null),this.#ue&&(clearTimeout(this.#ue),this.#ue=null),this._editorUndoBar?.destroy()}combinedSignal(e){return AbortSignal.any([this._signal,e.signal])}get mlManager(){return this.#ae}get useNewAltTextFlow(){return this.#W}get useNewAltTextWhenAddingImage(){return this.#$}get hcmFilter(){return Dae(this,"hcmFilter",this.#le?this.#q.addHCMFilter(this.#le.foreground,this.#le.background):"none")}get direction(){return Dae(this,"direction",getComputedStyle(this.#me).direction)}get highlightColors(){return Dae(this,"highlightColors",this.#K?new Map(this.#K.split(",").map((e=>e.split("=").map((e=>e.trim()))))):null)}get highlightColorNames(){return Dae(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,(e=>e.reverse()))):null)}setCurrentDrawingSession(e){e?(this.unselectAll(),this.disableUserSelect(!0)):this.disableUserSelect(!1),this.#D=e}setMainHighlightColorPicker(e){this.#re=e}editAltText(e,t=!1){this.#O?.editAltText(this,e,t)}switchToMode(e,t){this._eventBus.on("annotationeditormodechanged",t,{once:!0,signal:this._signal}),this._eventBus.dispatch("showannotationeditorui",{source:this,mode:e})}setPreference(e,t){this._eventBus.dispatch("setpreference",{source:this,name:e,value:t})}onSetPreference({name:e,value:t}){"enableNewAltTextWhenAddingImage"===e&&(this.#$=t)}onPageChanging({pageNumber:e}){this.#P=e-1}focusMainContainer(){this.#me.focus()}findParent(e,t){for(const n of this.#T.values()){const{x:r,y:a,width:o,height:c}=n.div.getBoundingClientRect();if(e>=r&&e<=r+o&&t>=a&&t<=a+c)return n}return null}disableUserSelect(e=!1){this.#pe.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#j.add(e)}removeShouldRescale(e){this.#j.delete(e)}onScaleChanging({scale:e}){this.commitOrRemove(),this.viewParameters.realScale=e*roe.PDF_TO_CSS_UNITS;for(const e of this.#j)e.onScaleChanging();this.#D?.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#ye({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}#Me(e){const{currentLayer:t}=this;if(t.hasTextLayer(e))return t;for(const t of this.#T.values())if(t.hasTextLayer(e))return t;return null}highlightSelection(e=""){const t=document.getSelection();if(!t||t.isCollapsed)return;const{anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o}=t,c=t.toString(),i=this.#ye(t).closest(".textLayer"),l=this.getSelectionBoxes(i);if(!l)return;t.empty();const s=this.#Me(i),h=this.#oe===Hae.NONE,d=()=>{s?.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:n,anchorOffset:r,focusNode:a,focusOffset:o,text:c}),h&&this.showAllEditors("highlight",!0,!0)};h?this.switchToMode(Hae.HIGHLIGHT,d):d()}#Ee(){const e=document.getSelection();if(!e||e.isCollapsed)return;const t=this.#ye(e).closest(".textLayer"),n=this.getSelectionBoxes(t);n&&(this.#Q||=new Hoe(this),this.#Q.show(t,n,"ltr"===this.direction))}addToAnnotationStorage(e){e.isEmpty()||!this.#A||this.#A.has(e.id)||this.#A.setValue(e.id,e)}#be(){const e=document.getSelection();if(!e||e.isCollapsed)return void(this.#ie&&(this.#Q?.hide(),this.#ie=null,this.#He({hasSelectedText:!1})));const{anchorNode:t}=e;if(t===this.#ie)return;const n=this.#ye(e).closest(".textLayer");if(n){if(this.#Q?.hide(),this.#ie=t,this.#He({hasSelectedText:!0}),(this.#oe===Hae.HIGHLIGHT||this.#oe===Hae.NONE)&&(this.#oe===Hae.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#X=this.isShiftKeyDown,!this.isShiftKeyDown)){const e=this.#oe===Hae.HIGHLIGHT?this.#Me(n):null;e?.toggleDrawing();const t=new AbortController,r=this.combinedSignal(t),a=n=>{"pointerup"===n.type&&0!==n.button||(t.abort(),e?.toggleDrawing(!0),"pointerup"===n.type&&this.#Ve("main_toolbar"))};window.addEventListener("pointerup",a,{signal:r}),window.addEventListener("blur",a,{signal:r})}}else this.#ie&&(this.#Q?.hide(),this.#ie=null,this.#He({hasSelectedText:!1}))}#Ve(e=""){this.#oe===Hae.HIGHLIGHT?this.highlightSelection(e):this.#U&&this.#Ee()}#fe(){document.addEventListener("selectionchange",this.#be.bind(this),{signal:this._signal})}#Ce(){if(this.#Y)return;this.#Y=new AbortController;const e=this.combinedSignal(this.#Y);window.addEventListener("focus",this.focus.bind(this),{signal:e}),window.addEventListener("blur",this.blur.bind(this),{signal:e})}#Le(){this.#Y?.abort(),this.#Y=null}blur(){if(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")),!this.hasSelection)return;const{activeElement:e}=document;for(const t of this.#ce)if(t.div.contains(e)){this.#ne=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#ne)return;const[e,t]=this.#ne;this.#ne=null,t.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this._signal}),t.focus()}#ge(){if(this.#te)return;this.#te=new AbortController;const e=this.combinedSignal(this.#te);window.addEventListener("keydown",this.keydown.bind(this),{signal:e}),window.addEventListener("keyup",this.keyup.bind(this),{signal:e})}#we(){this.#te?.abort(),this.#te=null}#ke(){if(this.#_)return;this.#_=new AbortController;const e=this.combinedSignal(this.#_);document.addEventListener("copy",this.copy.bind(this),{signal:e}),document.addEventListener("cut",this.cut.bind(this),{signal:e}),document.addEventListener("paste",this.paste.bind(this),{signal:e})}#xe(){this.#_?.abort(),this.#_=null}#ze(){const e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ge(),this.#ke()}removeEditListeners(){this.#we(),this.#xe()}dragOver(e){for(const{type:t}of e.dataTransfer.items)for(const n of this.#B)if(n.isHandlingMimeForPasting(t))return e.dataTransfer.dropEffect="copy",void e.preventDefault()}drop(e){for(const t of e.dataTransfer.items)for(const n of this.#B)if(n.isHandlingMimeForPasting(t.type))return n.paste(t,this.currentLayer),void e.preventDefault()}copy(e){if(e.preventDefault(),this.#x?.commitOrRemove(),!this.hasSelection)return;const t=[];for(const e of this.#ce){const n=e.serialize(!0);n&&t.push(n)}0!==t.length&&e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}async paste(e){e.preventDefault();const{clipboardData:t}=e;for(const e of t.items)for(const t of this.#B)if(t.isHandlingMimeForPasting(e.type))return void t.paste(e,this.currentLayer);let n=t.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(e){return void Aae(`paste: "${e.message}".`)}if(!Array.isArray(n))return;this.unselectAll();const r=this.currentLayer;try{const e=[];for(const t of n){const n=await r.deserialize(t);if(!n)return;e.push(n)}const t=()=>{for(const t of e)this.#Se(t);this.#Te(e)},a=()=>{for(const t of e)t.remove()};this.addCommands({cmd:t,undo:a,mustExec:!0})}catch(e){Aae(`paste: "${e.message}".`)}}keydown(e){this.isShiftKeyDown||"Shift"!==e.key||(this.isShiftKeyDown=!0),this.#oe===Hae.NONE||this.isEditorHandlingKeyboard||Soe._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#X&&(this.#X=!1,this.#Ve("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#He(e){Object.entries(e).some((([e,t])=>this.#he[e]!==t))&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#he,e)}),this.#oe===Hae.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#Oe([[Vae.HIGHLIGHT_FREE,!0]]))}#Oe(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#Ce(),this.#ke(),this.#He({isEditing:this.#oe!==Hae.NONE,isEmpty:this.#Ae(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#Le(),this.#xe(),this.#He({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#B){this.#B=e;for(const e of this.#B)this.#Oe(e.defaultPropertiesToUpdate)}}getId(){return this.#J.id}get currentLayer(){return this.#T.get(this.#P)}getLayer(e){return this.#T.get(e)}get currentPageIndex(){return this.#P}addLayer(e){this.#T.set(e.pageIndex,e),this.#Z?e.enable():e.disable()}removeLayer(e){this.#T.delete(e.pageIndex)}async updateMode(e,t=null,n=!1){if(this.#oe!==e&&(!this.#ve||(await this.#ve.promise,this.#ve))){if(this.#ve=Promise.withResolvers(),this.#oe=e,e===Hae.NONE)return this.setEditingState(!1),this.#Re(),this._editorUndoBar?.hide(),void this.#ve.resolve();this.setEditingState(!0),await this.#Ne(),this.unselectAll();for(const t of this.#T.values())t.updateMode(e);if(!t)return n&&this.addNewEditorFromKeyboard(),void this.#ve.resolve();for(const e of this.#S.values())e.annotationElementId===t?(this.setSelected(e),e.enterInEditMode()):e.unselect();this.#ve.resolve()}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){e!==this.#oe&&this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(this.#B){switch(e){case Vae.CREATE:return void this.currentLayer.addNewEditor();case Vae.HIGHLIGHT_DEFAULT_COLOR:this.#re?.updateColor(t);break;case Vae.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#se||=new Map).set(e,t),this.showAllEditors("highlight",t)}for(const n of this.#ce)n.updateParams(e,t);for(const n of this.#B)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(const n of this.#S.values())n.editorType===e&&n.show(t);(this.#se?.get(Vae.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#Oe([[Vae.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#ee!==e){this.#ee=e;for(const t of this.#T.values())e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}}async#Ne(){if(!this.#Z){this.#Z=!0;const e=[];for(const t of this.#T.values())e.push(t.enable());await Promise.all(e);for(const e of this.#S.values())e.enable()}}#Re(){if(this.unselectAll(),this.#Z){this.#Z=!1;for(const e of this.#T.values())e.disable();for(const e of this.#S.values())e.disable()}}getEditors(e){const t=[];for(const n of this.#S.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#S.get(e)}addEditor(e){this.#S.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#G&&clearTimeout(this.#G),this.#G=setTimeout((()=>{this.focusMainContainer(),this.#G=null}),0)),this.#S.delete(e.id),this.unselect(e),e.annotationElementId&&this.#F.has(e.annotationElementId)||this.#A?.remove(e.id)}addDeletedAnnotationElement(e){this.#F.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#F.has(e)}removeDeletedAnnotationElement(e){this.#F.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#Se(e){const t=this.#T.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){this.#x!==e&&(this.#x=e,e&&this.#Oe(e.propertiesToUpdate))}get#_e(){let e=null;for(e of this.#ce);return e}updateUI(e){this.#_e===e&&this.#Oe(e.propertiesToUpdate)}updateUIForDefaultProperties(e){this.#Oe(e.defaultPropertiesToUpdate)}toggleSelected(e){if(this.#ce.has(e))return this.#ce.delete(e),e.unselect(),void this.#He({hasSelectedEditor:this.hasSelection});this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}setSelected(e){this.#D?.commitOrRemove();for(const t of this.#ce)t!==e&&t.unselect();this.#ce.clear(),this.#ce.add(e),e.select(),this.#Oe(e.propertiesToUpdate),this.#He({hasSelectedEditor:!0})}isSelected(e){return this.#ce.has(e)}get firstSelectedEditor(){return this.#ce.values().next().value}unselect(e){e.unselect(),this.#ce.delete(e),this.#He({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#ce.size}get isEnterHandled(){return 1===this.#ce.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#He({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#Ae()}),this._editorUndoBar?.hide()}redo(){this.#N.redo(),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#Ae()})}addCommands(e){this.#N.add(e),this.#He({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#Ae()})}cleanUndoStack(e){this.#N.cleanType(e)}#Ae(){if(0===this.#S.size)return!0;if(1===this.#S.size)for(const e of this.#S.values())return e.isEmpty();return!1}delete(){this.commitOrRemove();const e=this.currentLayer?.endDrawingSession(!0);if(!this.hasSelection&&!e)return;const t=e?[e]:[...this.#ce],n=()=>{for(const e of t)this.#Se(e)};this.addCommands({cmd:()=>{this._editorUndoBar?.show(n,1===t.length?t[0].editorType:t.length);for(const e of t)e.remove()},undo:n,mustExec:!0})}commitOrRemove(){this.#x?.commitOrRemove()}hasSomethingToControl(){return this.#x||this.hasSelection}#Te(e){for(const e of this.#ce)e.unselect();this.#ce.clear();for(const t of e)t.isEmpty()||(this.#ce.add(t),t.select());this.#He({hasSelectedEditor:this.hasSelection})}selectAll(){for(const e of this.#ce)e.commit();this.#Te(this.#S.values())}unselectAll(){if((!this.#x||(this.#x.commitOrRemove(),this.#oe===Hae.NONE))&&!this.#D?.commitOrRemove()&&this.hasSelection){for(const e of this.#ce)e.unselect();this.#ce.clear(),this.#He({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(n||this.commitOrRemove(),!this.hasSelection)return;this.#de[0]+=e,this.#de[1]+=t;const[r,a]=this.#de,o=[...this.#ce];this.#ue&&clearTimeout(this.#ue),this.#ue=setTimeout((()=>{this.#ue=null,this.#de[0]=this.#de[1]=0,this.addCommands({cmd:()=>{for(const e of o)this.#S.has(e.id)&&e.translateInPage(r,a)},undo:()=>{for(const e of o)this.#S.has(e.id)&&e.translateInPage(-r,-a)},mustExec:!1})}),1e3);for(const n of o)n.translateInPage(e,t)}setUpDragSession(){if(this.hasSelection){this.disableUserSelect(!0),this.#I=new Map;for(const e of this.#ce)this.#I.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}}endDragSession(){if(!this.#I)return!1;this.disableUserSelect(!1);const e=this.#I;this.#I=null;let t=!1;for(const[{x:n,y:r,pageIndex:a},o]of e)o.newX=n,o.newY=r,o.newPageIndex=a,t||=n!==o.savedX||r!==o.savedY||a!==o.savedPageIndex;if(!t)return!1;const n=(e,t,n,r)=>{if(this.#S.has(e.id)){const a=this.#T.get(r);a?e._setParentAndPosition(a,t,n):(e.pageIndex=r,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(const[t,{newX:r,newY:a,newPageIndex:o}]of e)n(t,r,a,o)},undo:()=>{for(const[t,{savedX:r,savedY:a,savedPageIndex:o}]of e)n(t,r,a,o)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(this.#I)for(const n of this.#I.keys())n.drag(e,t)}rebuild(e){if(null===e.parent){const t=this.getLayer(e.pageIndex);t?(t.changeParent(e),t.addOrRebuild(e)):(this.addEditor(e),this.addToAnnotationStorage(e),e.rebuild())}else e.parent.addOrRebuild(e)}get isEditorHandlingKeyboard(){return this.getActive()?.shouldGetKeyboardEvents()||1===this.#ce.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#x===e}getActive(){return this.#x}getMode(){return this.#oe}get imageManager(){return Dae(this,"imageManager",new Loe)}getSelectionBoxes(e){if(!e)return null;const t=document.getSelection();for(let n=0,r=t.rangeCount;n<r;n++)if(!e.contains(t.getRangeAt(n).commonAncestorContainer))return null;const{x:n,y:r,width:a,height:o}=e.getBoundingClientRect();let c;switch(e.getAttribute("data-main-rotation")){case"90":c=(e,t,c,i)=>({x:(t-r)/o,y:1-(e+c-n)/a,width:i/o,height:c/a});break;case"180":c=(e,t,c,i)=>({x:1-(e+c-n)/a,y:1-(t+i-r)/o,width:c/a,height:i/o});break;case"270":c=(e,t,c,i)=>({x:1-(t+i-r)/o,y:(e-n)/a,width:i/o,height:c/a});break;default:c=(e,t,c,i)=>({x:(e-n)/a,y:(t-r)/o,width:c/a,height:i/o})}const i=[];for(let e=0,n=t.rangeCount;e<n;e++){const n=t.getRangeAt(e);if(!n.collapsed)for(const{x:e,y:t,width:r,height:a}of n.getClientRects())0!==r&&0!==a&&i.push(c(e,t,r,a))}return 0===i.length?null:i}addChangedExistingAnnotation({annotationElementId:e,id:t}){(this.#R||=new Map).set(e,t)}removeChangedExistingAnnotation({annotationElementId:e}){this.#R?.delete(e)}renderAnnotationElement(e){const t=this.#R?.get(e.data.id);if(!t)return;const n=this.#A.getRawValue(t);n&&(this.#oe!==Hae.NONE||n.hasBeenModified)&&n.renderAnnotationElement(e)}}class Toe{#i=null;#De=!1;#Pe=null;#Fe=null;#Ie=null;#Be=null;#je=!1;#Ue=null;#o=null;#We=null;#$e=null;#qe=!1;static#Ge=null;static _l10n=null;constructor(e){this.#o=e,this.#qe=e._uiManager.useNewAltTextFlow,Toe.#Ge||=Object.freeze({added:"pdfjs-editor-new-alt-text-added-button","added-label":"pdfjs-editor-new-alt-text-added-button-label",missing:"pdfjs-editor-new-alt-text-missing-button","missing-label":"pdfjs-editor-new-alt-text-missing-button-label",review:"pdfjs-editor-new-alt-text-to-review-button","review-label":"pdfjs-editor-new-alt-text-to-review-button-label"})}static initialize(e){Toe._l10n??=e}async render(){const e=this.#Pe=document.createElement("button");e.className="altText",e.tabIndex="0";const t=this.#Fe=document.createElement("span");e.append(t),this.#qe?(e.classList.add("new"),e.setAttribute("data-l10n-id",Toe.#Ge.missing),t.setAttribute("data-l10n-id",Toe.#Ge["missing-label"])):(e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button"),t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-button-label"));const n=this.#o._uiManager._signal;e.addEventListener("contextmenu",moe,{signal:n}),e.addEventListener("pointerdown",(e=>e.stopPropagation()),{signal:n});const r=e=>{e.preventDefault(),this.#o._uiManager.editAltText(this.#o),this.#qe&&this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_clicked",data:{label:this.#Ye}})};return e.addEventListener("click",r,{capture:!0,signal:n}),e.addEventListener("keydown",(t=>{t.target===e&&"Enter"===t.key&&(this.#je=!0,r(t))}),{signal:n}),await this.#Ke(),e}get#Ye(){return(this.#i?"added":null===this.#i&&this.guessedText&&"review")||"missing"}finish(){this.#Pe&&(this.#Pe.focus({focusVisible:this.#je}),this.#je=!1)}isEmpty(){return this.#qe?null===this.#i:!this.#i&&!this.#De}hasData(){return this.#qe?null!==this.#i||!!this.#We:this.isEmpty()}get guessedText(){return this.#We}async setGuessedText(e){null===this.#i&&(this.#We=e,this.#$e=await Toe._l10n.get("pdfjs-editor-new-alt-text-generated-alt-text-with-disclaimer",{generatedAltText:e}),this.#Ke())}toggleAltTextBadge(e=!1){if(!this.#qe||this.#i)return this.#Ue?.remove(),void(this.#Ue=null);if(!this.#Ue){const e=this.#Ue=document.createElement("div");e.className="noAltTextBadge",this.#o.div.append(e)}this.#Ue.classList.toggle("hidden",!e)}serialize(e){let t=this.#i;return e||this.#We!==t||(t=this.#$e),{altText:t,decorative:this.#De,guessedText:this.#We,textWithDisclaimer:this.#$e}}get data(){return{altText:this.#i,decorative:this.#De}}set data({altText:e,decorative:t,guessedText:n,textWithDisclaimer:r,cancel:a=!1}){n&&(this.#We=n,this.#$e=r),this.#i===e&&this.#De===t||(a||(this.#i=e,this.#De=t),this.#Ke())}toggle(e=!1){this.#Pe&&(!e&&this.#Be&&(clearTimeout(this.#Be),this.#Be=null),this.#Pe.disabled=!e)}shown(){this.#o._reportTelemetry({action:"pdfjs.image.alt_text.image_status_label_displayed",data:{label:this.#Ye}})}destroy(){this.#Pe?.remove(),this.#Pe=null,this.#Fe=null,this.#Ie=null,this.#Ue?.remove(),this.#Ue=null}async#Ke(){const e=this.#Pe;if(!e)return;if(this.#qe){if(e.classList.toggle("done",!!this.#i),e.setAttribute("data-l10n-id",Toe.#Ge[this.#Ye]),this.#Fe?.setAttribute("data-l10n-id",Toe.#Ge[`${this.#Ye}-label`]),!this.#i)return void this.#Ie?.remove()}else{if(!this.#i&&!this.#De)return e.classList.remove("done"),void this.#Ie?.remove();e.classList.add("done"),e.setAttribute("data-l10n-id","pdfjs-editor-alt-text-edit-button")}let t=this.#Ie;if(!t){this.#Ie=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip"),t.id=`alt-text-tooltip-${this.#o.id}`;const n=100,r=this.#o._uiManager._signal;r.addEventListener("abort",(()=>{clearTimeout(this.#Be),this.#Be=null}),{once:!0}),e.addEventListener("mouseenter",(()=>{this.#Be=setTimeout((()=>{this.#Be=null,this.#Ie.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})}),n)}),{signal:r}),e.addEventListener("mouseleave",(()=>{this.#Be&&(clearTimeout(this.#Be),this.#Be=null),this.#Ie?.classList.remove("show")}),{signal:r})}this.#De?t.setAttribute("data-l10n-id","pdfjs-editor-alt-text-decorative-tooltip"):(t.removeAttribute("data-l10n-id"),t.textContent=this.#i),t.parentNode||e.append(t);const n=this.#o.getImageForAltText();n?.setAttribute("aria-describedby",t.id)}}class Ooe{#me;#Xe=!1;#Qe=null;#Je;#Ze;#et;#tt;#nt;#rt=null;#at;#ot=null;constructor({container:e,isPinchingDisabled:t=null,isPinchingStopped:n=null,onPinchStart:r=null,onPinching:a=null,onPinchEnd:o=null,signal:c}){this.#me=e,this.#Qe=n,this.#Je=t,this.#Ze=r,this.#et=a,this.#tt=o,this.#at=new AbortController,this.#nt=AbortSignal.any([c,this.#at.signal]),e.addEventListener("touchstart",this.#ct.bind(this),{passive:!1,signal:this.#nt})}get MIN_TOUCH_DISTANCE_TO_PINCH(){return Dae(this,"MIN_TOUCH_DISTANCE_TO_PINCH",35/(window.devicePixelRatio||1))}#ct(e){if(this.#Je?.()||e.touches.length<2)return;if(!this.#ot){this.#ot=new AbortController;const e=AbortSignal.any([this.#nt,this.#ot.signal]),t=this.#me,n={signal:e,passive:!1};t.addEventListener("touchmove",this.#it.bind(this),n),t.addEventListener("touchend",this.#lt.bind(this),n),t.addEventListener("touchcancel",this.#lt.bind(this),n),this.#Ze?.()}if(poe(e),2!==e.touches.length||this.#Qe?.())return void(this.#rt=null);let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]),this.#rt={touch0X:t.screenX,touch0Y:t.screenY,touch1X:n.screenX,touch1Y:n.screenY}}#it(e){if(!this.#rt||2!==e.touches.length)return;let[t,n]=e.touches;t.identifier>n.identifier&&([t,n]=[n,t]);const{screenX:r,screenY:a}=t,{screenX:o,screenY:c}=n,i=this.#rt,{touch0X:l,touch0Y:s,touch1X:h,touch1Y:d}=i,u=h-l,m=d-s,p=o-r,v=c-a,f=Math.hypot(p,v)||1,z=Math.hypot(u,m)||1;if(!this.#Xe&&Math.abs(z-f)<=Ooe.MIN_TOUCH_DISTANCE_TO_PINCH)return;if(i.touch0X=r,i.touch0Y=a,i.touch1X=o,i.touch1Y=c,e.preventDefault(),!this.#Xe)return void(this.#Xe=!0);const g=[(r+o)/2,(a+c)/2];this.#et?.(g,z,f)}#lt(e){this.#ot.abort(),this.#ot=null,this.#tt?.(),this.#rt&&(e.preventDefault(),this.#rt=null,this.#Xe=!1)}destroy(){this.#at?.abort(),this.#at=null}}class Aoe{#st=null;#ht=null;#i=null;#dt=!1;#ut=null;#mt="";#pt=!1;#vt=null;#ft=null;#zt=null;#gt=null;#yt="";#Mt=!1;#Et=null;#bt=!1;#Ht=!1;#Vt=!1;#Ct=null;#Lt=0;#wt=0;#kt=null;#xt=null;_editToolbar=null;_initialOptions=Object.create(null);_initialData=null;_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;static _l10n=null;static _l10nResizer=null;#St=!1;#Tt=Aoe._zIndex++;static _borderLineWidth=-1;static _colorManager=new xoe;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){const e=Aoe.prototype._resizeWithKeyboard,t=Soe.TRANSLATE_SMALL,n=Soe.TRANSLATE_BIG;return Dae(this,"_resizerKeyboardManager",new koe([[["ArrowLeft","mac+ArrowLeft"],e,{args:[-t,0]}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e,{args:[-n,0]}],[["ArrowRight","mac+ArrowRight"],e,{args:[t,0]}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e,{args:[n,0]}],[["ArrowUp","mac+ArrowUp"],e,{args:[0,-t]}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e,{args:[0,-n]}],[["ArrowDown","mac+ArrowDown"],e,{args:[0,t]}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e,{args:[0,n]}],[["Escape","mac+Escape"],Aoe.prototype._stopResizingWithKeyboard]]))}constructor(e){this.parent=e.parent,this.id=e.id,this.width=this.height=null,this.pageIndex=e.parent.pageIndex,this.name=e.name,this.div=null,this._uiManager=e.uiManager,this.annotationElementId=null,this._willKeepAspectRatio=!1,this._initialOptions.isCentered=e.isCentered,this._structTreeParentId=null;const{rotation:t,rawDims:{pageWidth:n,pageHeight:r,pageX:a,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,r],this.pageTranslation=[a,o];const[c,i]=this.parentDimensions;this.x=e.x/c,this.y=e.y/i,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get isDrawer(){return!1}static get _defaultLineColor(){return Dae(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){const t=new Roe({id:e.parent.getNextId(),parent:e.parent,uiManager:e._uiManager});t.annotationElementId=e.annotationElementId,t.deleted=!0,t._uiManager.addToAnnotationStorage(t)}static initialize(e,t){if(Aoe._l10n??=e,Aoe._l10nResizer||=Object.freeze({topLeft:"pdfjs-editor-resizer-top-left",topMiddle:"pdfjs-editor-resizer-top-middle",topRight:"pdfjs-editor-resizer-top-right",middleRight:"pdfjs-editor-resizer-middle-right",bottomRight:"pdfjs-editor-resizer-bottom-right",bottomMiddle:"pdfjs-editor-resizer-bottom-middle",bottomLeft:"pdfjs-editor-resizer-bottom-left",middleLeft:"pdfjs-editor-resizer-middle-left"}),-1!==Aoe._borderLineWidth)return;const n=getComputedStyle(document.documentElement);Aoe._borderLineWidth=parseFloat(n.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){Rae("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#St}set _isDraggable(e){this.#St=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){const[e,t]=this.pageDimensions;switch(this.parentRotation){case 90:this.x-=this.height*t/(2*e),this.y+=this.width*e/(2*t);break;case 180:this.x+=this.width/2,this.y+=this.height/2;break;case 270:this.x+=this.height*t/(2*e),this.y-=this.width*e/(2*t);break;default:this.x-=this.width/2,this.y-=this.height/2}this.fixAndSetPosition()}addCommands(e){this._uiManager.addCommands(e)}get currentLayer(){return this._uiManager.currentLayer}setInBackground(){this.div.style.zIndex=0}setInForeground(){this.div.style.zIndex=this.#Tt}setParent(e){null!==e?(this.pageIndex=e.pageIndex,this.pageDimensions=e.pageDimensions):this.#Ot(),this.parent=e}focusin(e){this._focusEventsAllowed&&(this.#Mt?this.#Mt=!1:this.parent.setSelected(this))}focusout(e){if(!this._focusEventsAllowed)return;if(!this.isAttachedToDOM)return;const t=e.relatedTarget;t?.closest(`#${this.id}`)||(e.preventDefault(),this.parent?.isMultipleSelection||this.commitOrRemove())}commitOrRemove(){this.isEmpty()?this.remove():this.commit()}commit(){this.addToAnnotationStorage()}addToAnnotationStorage(){this._uiManager.addToAnnotationStorage(this)}setAt(e,t,n,r){const[a,o]=this.parentDimensions;[n,r]=this.screenToPageTranslation(n,r),this.x=(e+n)/a,this.y=(t+r)/o,this.fixAndSetPosition()}#At([e,t],n,r){[n,r]=this.screenToPageTranslation(n,r),this.x+=n/e,this.y+=r/t,this._onTranslating(this.x,this.y),this.fixAndSetPosition()}translate(e,t){this.#At(this.parentDimensions,e,t)}translateInPage(e,t){this.#Et||=[this.x,this.y,this.width,this.height],this.#At(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#Et||=[this.x,this.y,this.width,this.height];const{div:n,parentDimensions:[r,a]}=this;if(this.x+=e/r,this.y+=t/a,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){const{x:e,y:t}=this.div.getBoundingClientRect();this.parent.findNewParent(this,e,t)&&(this.x-=Math.floor(this.x),this.y-=Math.floor(this.y))}let{x:o,y:c}=this;const[i,l]=this.getBaseTranslation();o+=i,c+=l;const{style:s}=n;s.left=`${(100*o).toFixed(2)}%`,s.top=`${(100*c).toFixed(2)}%`,this._onTranslating(o,c),n.scrollIntoView({block:"nearest"})}_onTranslating(e,t){}_onTranslated(e,t){}get _hasBeenMoved(){return!!this.#Et&&(this.#Et[0]!==this.x||this.#Et[1]!==this.y)}get _hasBeenResized(){return!!this.#Et&&(this.#Et[2]!==this.width||this.#Et[3]!==this.height)}getBaseTranslation(){const[e,t]=this.parentDimensions,{_borderLineWidth:n}=Aoe,r=n/e,a=n/t;switch(this.rotation){case 90:return[-r,a];case 180:return[r,a];case 270:return[r,-a];default:return[-r,-a]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){const{div:{style:t},pageDimensions:[n,r]}=this;let{x:a,y:o,width:c,height:i}=this;if(c*=n,i*=r,a*=n,o*=r,this._mustFixPosition)switch(e){case 0:a=Math.max(0,Math.min(n-c,a)),o=Math.max(0,Math.min(r-i,o));break;case 90:a=Math.max(0,Math.min(n-i,a)),o=Math.min(r,Math.max(c,o));break;case 180:a=Math.min(n,Math.max(c,a)),o=Math.min(r,Math.max(i,o));break;case 270:a=Math.min(n,Math.max(i,a)),o=Math.max(0,Math.min(r-c,o))}this.x=a/=n,this.y=o/=r;const[l,s]=this.getBaseTranslation();a+=l,o+=s,t.left=`${(100*a).toFixed(2)}%`,t.top=`${(100*o).toFixed(2)}%`,this.moveInDOM()}static#Rt(e,t,n){switch(n){case 90:return[t,-e];case 180:return[-e,-t];case 270:return[-t,e];default:return[e,t]}}screenToPageTranslation(e,t){return Aoe.#Rt(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return Aoe.#Rt(e,t,360-this.parentRotation)}#Nt(e){switch(e){case 90:{const[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{const[e,t]=this.pageDimensions;return[0,e/t,-t/e,0]}default:return[1,0,0,1]}}get parentScale(){return this._uiManager.viewParameters.realScale}get parentRotation(){return(this._uiManager.viewParameters.rotation+this.pageRotation)%360}get parentDimensions(){const{parentScale:e,pageDimensions:[t,n]}=this;return[t*e,n*e]}setDims(e,t){const[n,r]=this.parentDimensions,{style:a}=this.div;a.width=`${(100*e/n).toFixed(2)}%`,this.#pt||(a.height=`${(100*t/r).toFixed(2)}%`)}fixDims(){const{style:e}=this.div,{height:t,width:n}=e,r=n.endsWith("%"),a=!this.#pt&&t.endsWith("%");if(r&&a)return;const[o,c]=this.parentDimensions;r||(e.width=`${(100*parseFloat(n)/o).toFixed(2)}%`),this.#pt||a||(e.height=`${(100*parseFloat(t)/c).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#_t(){if(this.#vt)return;this.#vt=document.createElement("div"),this.#vt.classList.add("resizers");const e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(const n of e){const e=document.createElement("div");this.#vt.append(e),e.classList.add("resizer",n),e.setAttribute("data-resizer-name",n),e.addEventListener("pointerdown",this.#Dt.bind(this,n),{signal:t}),e.addEventListener("contextmenu",moe,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#vt)}#Dt(e,t){t.preventDefault();const{isMac:n}=Kae.platform;if(0!==t.button||t.ctrlKey&&n)return;this.#i?.toggle(!1);const r=this._isDraggable;this._isDraggable=!1,this.#ft=[t.screenX,t.screenY];const a=new AbortController,o=this._uiManager.combinedSignal(a);this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",this.#Pt.bind(this,e),{passive:!0,capture:!0,signal:o}),window.addEventListener("touchmove",poe,{passive:!1,signal:o}),window.addEventListener("contextmenu",moe,{signal:o}),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const c=this.parent.div.style.cursor,i=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;const l=()=>{a.abort(),this.parent.togglePointerEvents(!0),this.#i?.toggle(!0),this._isDraggable=r,this.parent.div.style.cursor=c,this.div.style.cursor=i,this.#Ft()};window.addEventListener("pointerup",l,{signal:o}),window.addEventListener("blur",l,{signal:o})}#It(e,t,n,r){this.width=n,this.height=r,this.x=e,this.y=t;const[a,o]=this.parentDimensions;this.setDims(a*n,o*r),this.fixAndSetPosition(),this._onResized()}_onResized(){}#Ft(){if(!this.#zt)return;const{savedX:e,savedY:t,savedWidth:n,savedHeight:r}=this.#zt;this.#zt=null;const a=this.x,o=this.y,c=this.width,i=this.height;a===e&&o===t&&c===n&&i===r||this.addCommands({cmd:this.#It.bind(this,a,o,c,i),undo:this.#It.bind(this,e,t,n,r),mustExec:!0})}static _round(e){return Math.round(1e4*e)/1e4}#Pt(e,t){const[n,r]=this.parentDimensions,a=this.x,o=this.y,c=this.width,i=this.height,l=Aoe.MIN_SIZE/n,s=Aoe.MIN_SIZE/r,h=this.#Nt(this.rotation),d=(e,t)=>[h[0]*e+h[2]*t,h[1]*e+h[3]*t],u=this.#Nt(360-this.rotation);let m,p,v=!1,f=!1;switch(e){case"topLeft":v=!0,m=(e,t)=>[0,0],p=(e,t)=>[e,t];break;case"topMiddle":m=(e,t)=>[e/2,0],p=(e,t)=>[e/2,t];break;case"topRight":v=!0,m=(e,t)=>[e,0],p=(e,t)=>[0,t];break;case"middleRight":f=!0,m=(e,t)=>[e,t/2],p=(e,t)=>[0,t/2];break;case"bottomRight":v=!0,m=(e,t)=>[e,t],p=(e,t)=>[0,0];break;case"bottomMiddle":m=(e,t)=>[e/2,t],p=(e,t)=>[e/2,0];break;case"bottomLeft":v=!0,m=(e,t)=>[0,t],p=(e,t)=>[e,0];break;case"middleLeft":f=!0,m=(e,t)=>[0,t/2],p=(e,t)=>[e,t/2]}const z=m(c,i),g=p(c,i);let y=d(...g);const M=Aoe._round(a+y[0]),E=Aoe._round(o+y[1]);let b,H,V=1,C=1;if(t.fromKeyboard)({deltaX:b,deltaY:H}=t);else{const{screenX:e,screenY:n}=t,[r,a]=this.#ft;[b,H]=this.screenToPageTranslation(e-r,n-a),this.#ft[0]=e,this.#ft[1]=n}var L,w;if([b,H]=(L=b/n,w=H/r,[u[0]*L+u[2]*w,u[1]*L+u[3]*w]),v){const e=Math.hypot(c,i);V=C=Math.max(Math.min(Math.hypot(g[0]-z[0]-b,g[1]-z[1]-H)/e,1/c,1/i),l/c,s/i)}else f?V=Math.max(l,Math.min(1,Math.abs(g[0]-z[0]-b)))/c:C=Math.max(s,Math.min(1,Math.abs(g[1]-z[1]-H)))/i;const k=Aoe._round(c*V),x=Aoe._round(i*C);y=d(...p(k,x));const S=M-y[0],T=E-y[1];this.#Et||=[this.x,this.y,this.width,this.height],this.width=k,this.height=x,this.x=S,this.y=T,this.setDims(n*k,r*x),this.fixAndSetPosition(),this._onResizing()}_onResizing(){}altTextFinish(){this.#i?.finish()}async addEditToolbar(){return this._editToolbar||this.#Ht||(this._editToolbar=new boe(this),this.div.append(this._editToolbar.render()),this.#i&&await this._editToolbar.addAltText(this.#i)),this._editToolbar}removeEditToolbar(){this._editToolbar&&(this._editToolbar.remove(),this._editToolbar=null,this.#i?.destroy())}addContainer(e){const t=this._editToolbar?.div;t?t.before(e):this.div.append(e)}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){this.#i||(Toe.initialize(Aoe._l10n),this.#i=new Toe(this),this.#st&&(this.#i.data=this.#st,this.#st=null),await this.addEditToolbar())}get altTextData(){return this.#i?.data}set altTextData(e){this.#i&&(this.#i.data=e)}get guessedAltText(){return this.#i?.guessedText}async setGuessedAltText(e){await(this.#i?.setGuessedText(e))}serializeAltText(e){return this.#i?.serialize(e)}hasAltText(){return!!this.#i&&!this.#i.isEmpty()}hasAltTextData(){return this.#i?.hasData()??!1}render(){this.div=document.createElement("div"),this.div.setAttribute("data-editor-rotation",(360-this.rotation)%360),this.div.className=this.name,this.div.setAttribute("id",this.id),this.div.tabIndex=this.#dt?-1:0,this._isVisible||this.div.classList.add("hidden"),this.setInForeground(),this.#Bt();const[e,t]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*t/e).toFixed(2)}%`,this.div.style.maxHeight=`${(100*e/t).toFixed(2)}%`);const[n,r]=this.getInitialTranslation();return this.translate(n,r),Voe(this,this.div,["pointerdown"]),this.isResizable&&this._uiManager._supportsPinchToZoom&&(this.#xt||=new Ooe({container:this.div,isPinchingDisabled:()=>!this.isSelected,onPinchStart:this.#jt.bind(this),onPinching:this.#Ut.bind(this),onPinchEnd:this.#Wt.bind(this),signal:this._uiManager._signal})),this._uiManager._editorUndoBar?.hide(),this.div}#jt(){this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height},this.#i?.toggle(!1),this.parent.togglePointerEvents(!1)}#Ut(e,t,n){let r=n/t*.7+1-.7;if(1===r)return;const a=this.#Nt(this.rotation),o=(e,t)=>[a[0]*e+a[2]*t,a[1]*e+a[3]*t],[c,i]=this.parentDimensions,l=this.x,s=this.y,h=this.width,d=this.height,u=Aoe.MIN_SIZE/c,m=Aoe.MIN_SIZE/i;r=Math.max(Math.min(r,1/h,1/d),u/h,m/d);const p=Aoe._round(h*r),v=Aoe._round(d*r);if(p===h&&v===d)return;this.#Et||=[l,s,h,d];const f=o(h/2,d/2),z=Aoe._round(l+f[0]),g=Aoe._round(s+f[1]),y=o(p/2,v/2);this.x=z-y[0],this.y=g-y[1],this.width=p,this.height=v,this.setDims(c*p,i*v),this.fixAndSetPosition(),this._onResizing()}#Wt(){this.#i?.toggle(!0),this.parent.togglePointerEvents(!0),this.#Ft()}pointerdown(e){const{isMac:t}=Kae.platform;0!==e.button||e.ctrlKey&&t?e.preventDefault():(this.#Mt=!0,this._isDraggable?this.#$t(e):this.#qt(e))}get isSelected(){return this._uiManager.isSelected(this)}#qt(e){const{isMac:t}=Kae.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#$t(e){const{isSelected:t}=this;this._uiManager.setUpDragSession();let n=!1;const r=new AbortController,a=this._uiManager.combinedSignal(r),o={capture:!0,passive:!1,signal:a},c=e=>{r.abort(),this.#ut=null,this.#Mt=!1,this._uiManager.endDragSession()||this.#qt(e),n&&this._onStopDragging()};t&&(this.#Lt=e.clientX,this.#wt=e.clientY,this.#ut=e.pointerId,this.#mt=e.pointerType,window.addEventListener("pointermove",(e=>{n||(n=!0,this._onStartDragging());const{clientX:t,clientY:r,pointerId:a}=e;if(a!==this.#ut)return void poe(e);const[o,c]=this.screenToPageTranslation(t-this.#Lt,r-this.#wt);this.#Lt=t,this.#wt=r,this._uiManager.dragSelectedEditors(o,c)}),o),window.addEventListener("touchmove",poe,o),window.addEventListener("pointerdown",(e=>{e.pointerType===this.#mt&&(this.#xt||e.isPrimary)&&c(e),poe(e)}),o));const i=e=>{this.#ut&&this.#ut!==e.pointerId?poe(e):c(e)};window.addEventListener("pointerup",i,{signal:a}),window.addEventListener("blur",i,{signal:a})}_onStartDragging(){}_onStopDragging(){}moveInDOM(){this.#Ct&&clearTimeout(this.#Ct),this.#Ct=setTimeout((()=>{this.#Ct=null,this.parent?.moveEditorInDOM(this)}),0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition(),this._onTranslated()}getRect(e,t,n=this.rotation){const r=this.parentScale,[a,o]=this.pageDimensions,[c,i]=this.pageTranslation,l=e/r,s=t/r,h=this.x*a,d=this.y*o,u=this.width*a,m=this.height*o;switch(n){case 0:return[h+l+c,o-d-s-m+i,h+l+u+c,o-d-s+i];case 90:return[h+s+c,o-d+l+i,h+s+m+c,o-d+l+u+i];case 180:return[h-l-u+c,o-d+s+i,h-l+c,o-d+s+m+i];case 270:return[h-s-m+c,o-d-l-u+i,h-s+c,o-d-l+i];default:throw new Error("Invalid rotation")}}getRectInCurrentCoords(e,t){const[n,r,a,o]=e,c=a-n,i=o-r;switch(this.rotation){case 0:return[n,t-o,c,i];case 90:return[n,t-r,i,c];case 180:return[a,t-r,c,i];case 270:return[a,t-o,i,c];default:throw new Error("Invalid rotation")}}onceAdded(e){}isEmpty(){return!1}enableEditMode(){this.#Ht=!0}disableEditMode(){this.#Ht=!1}isInEditMode(){return this.#Ht}shouldGetKeyboardEvents(){return this.#Vt}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}get isOnScreen(){const{top:e,left:t,bottom:n,right:r}=this.getClientDimensions(),{innerHeight:a,innerWidth:o}=window;return t<o&&r>0&&e<a&&n>0}#Bt(){if(this.#gt||!this.div)return;this.#gt=new AbortController;const e=this._uiManager.combinedSignal(this.#gt);this.div.addEventListener("focusin",this.focusin.bind(this),{signal:e}),this.div.addEventListener("focusout",this.focusout.bind(this),{signal:e})}rebuild(){this.#Bt()}rotate(e){}resize(){}serializeDeleted(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex,popupRef:this._initialData?.popupRef||""}}serialize(e=!1,t=null){Rae("An editor must be serializable")}static async deserialize(e,t,n){const r=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});r.rotation=e.rotation,r.#st=e.accessibilityData;const[a,o]=r.pageDimensions,[c,i,l,s]=r.getRectInCurrentCoords(e.rect,o);return r.x=c/a,r.y=i/o,r.width=l/a,r.height=s/o,r}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.#gt?.abort(),this.#gt=null,this.isEmpty()||this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#Ct&&(clearTimeout(this.#Ct),this.#Ct=null),this.#Ot(),this.removeEditToolbar(),this.#kt){for(const e of this.#kt.values())clearTimeout(e);this.#kt=null}this.parent=null,this.#xt?.destroy(),this.#xt=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#_t(),this.#vt.classList.remove("hidden"),Voe(this,this.div,["keydown"]))}get toolbarPosition(){return null}keydown(e){if(!this.isResizable||e.target!==this.div||"Enter"!==e.key)return;this._uiManager.setSelected(this),this.#zt={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};const t=this.#vt.children;if(!this.#ht){this.#ht=Array.from(t);const e=this.#Gt.bind(this),n=this.#Yt.bind(this),r=this._uiManager._signal;for(const t of this.#ht){const a=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton"),t.addEventListener("keydown",e,{signal:r}),t.addEventListener("blur",n,{signal:r}),t.addEventListener("focus",this.#Kt.bind(this,a),{signal:r}),t.setAttribute("data-l10n-id",Aoe._l10nResizer[a])}}const n=this.#ht[0];let r=0;for(const e of t){if(e===n)break;r++}const a=(360-this.rotation+this.parentRotation)%360/90*(this.#ht.length/4);if(a!==r){if(a<r)for(let e=0;e<r-a;e++)this.#vt.append(this.#vt.firstChild);else if(a>r)for(let e=0;e<a-r;e++)this.#vt.firstChild.before(this.#vt.lastChild);let e=0;for(const n of t){const t=this.#ht[e++].getAttribute("data-resizer-name");n.setAttribute("data-l10n-id",Aoe._l10nResizer[t])}}this.#Xt(0),this.#Vt=!0,this.#vt.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#Gt(e){Aoe._resizerKeyboardManager.exec(this,e)}#Yt(e){this.#Vt&&e.relatedTarget?.parentNode!==this.#vt&&this.#Ot()}#Kt(e){this.#yt=this.#Vt?e:""}#Xt(e){if(this.#ht)for(const t of this.#ht)t.tabIndex=e}_resizeWithKeyboard(e,t){this.#Vt&&this.#Pt(this.#yt,{deltaX:e,deltaY:t,fromKeyboard:!0})}#Ot(){this.#Vt=!1,this.#Xt(-1),this.#Ft()}_stopResizingWithKeyboard(){this.#Ot(),this.div.focus()}select(){this.makeResizable(),this.div?.classList.add("selectedEditor"),this._editToolbar?(this._editToolbar?.show(),this.#i?.toggleAltTextBadge(!1)):this.addEditToolbar().then((()=>{this.div?.classList.contains("selectedEditor")&&this._editToolbar?.show()}))}unselect(){this.#vt?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this._editToolbar?.hide(),this.#i?.toggleAltTextBadge(!0)}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#bt}set isEditing(e){this.#bt=e,this.parent&&(e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null))}setAspectRatio(e,t){this.#pt=!0;const n=e/t,{style:r}=this.div;r.aspectRatio=n,r.height="auto"}static get MIN_SIZE(){return 16}static canCreateNewEmptyEditor(){return!0}get telemetryInitialData(){return{action:"added"}}get telemetryFinalData(){return null}_reportTelemetry(e,t=!1){if(t){this.#kt||=new Map;const{action:t}=e;let n=this.#kt.get(t);return n&&clearTimeout(n),n=setTimeout((()=>{this._reportTelemetry(e),this.#kt.delete(t),0===this.#kt.size&&(this.#kt=null)}),Aoe._telemetryTimeout),void this.#kt.set(t,n)}e.type||=this.editorType,this._uiManager._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:e}})}show(e=this._isVisible){this.div.classList.toggle("hidden",!e),this._isVisible=e}enable(){this.div&&(this.div.tabIndex=0),this.#dt=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#dt=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){const e=t;t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.before(t)}}else t=document.createElement("div"),t.classList.add("annotationContent",this.editorType),e.container.prepend(t);return t}resetAnnotationElement(e){const{firstChild:t}=e.container;"DIV"===t?.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}class Roe extends Aoe{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return this.serializeDeleted()}}const Noe=3285377520,_oe=4294901760,Doe=65535;class Poe{constructor(e){this.h1=e?4294967295&e:Noe,this.h2=e?4294967295&e:Noe}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let r=0,a=e.length;r<a;r++){const a=e.charCodeAt(r);a<=255?t[n++]=a:(t[n++]=a>>>8,t[n++]=255&a)}}else{if(!ArrayBuffer.isView(e))throw new Error("Invalid data format, must be a string or TypedArray.");t=e.slice(),n=t.byteLength}const r=n>>2,a=n-4*r,o=new Uint32Array(t.buffer,0,r);let c=0,i=0,l=this.h1,s=this.h2;const h=3432918353,d=461845907,u=11601,m=13715;for(let e=0;e<r;e++)1&e?(c=o[e],c=c*h&_oe|c*u&Doe,c=c<<15|c>>>17,c=c*d&_oe|c*m&Doe,l^=c,l=l<<13|l>>>19,l=5*l+3864292196):(i=o[e],i=i*h&_oe|i*u&Doe,i=i<<15|i>>>17,i=i*d&_oe|i*m&Doe,s^=i,s=s<<13|s>>>19,s=5*s+3864292196);switch(c=0,a){case 3:c^=t[4*r+2]<<16;case 2:c^=t[4*r+1]<<8;case 1:c^=t[4*r],c=c*h&_oe|c*u&Doe,c=c<<15|c>>>17,c=c*d&_oe|c*m&Doe,1&r?l^=c:s^=c}this.h1=l,this.h2=s}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,e=3981806797*e&_oe|36045*e&Doe,t=4283543511*t&_oe|(2950163797*(t<<16|e>>>16)&_oe)>>>16,e^=t>>>1,e=444984403*e&_oe|60499*e&Doe,t=3301882366*t&_oe|(3120437893*(t<<16|e>>>16)&_oe)>>>16,e^=t>>>1,(e>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}const Foe=Object.freeze({map:null,hash:"",transfer:void 0});class Ioe{#Qt=!1;#Jt=null;#Zt=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){const n=this.#Zt.get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return this.#Zt.get(e)}remove(e){if(this.#Zt.delete(e),0===this.#Zt.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(const e of this.#Zt.values())if(e instanceof Aoe)return;this.onAnnotationEditor(null)}}setValue(e,t){const n=this.#Zt.get(e);let r=!1;if(void 0!==n)for(const[e,a]of Object.entries(t))n[e]!==a&&(r=!0,n[e]=a);else r=!0,this.#Zt.set(e,t);r&&this.#en(),t instanceof Aoe&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#Zt.has(e)}getAll(){return this.#Zt.size>0?Yae(this.#Zt):null}setAll(e){for(const[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#Zt.size}#en(){this.#Qt||(this.#Qt=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#Qt&&(this.#Qt=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new Boe(this)}get serializable(){if(0===this.#Zt.size)return Foe;const e=new Map,t=new Poe,n=[],r=Object.create(null);let a=!1;for(const[n,o]of this.#Zt){const c=o instanceof Aoe?o.serialize(!1,r):o;c&&(e.set(n,c),t.update(`${n}:${JSON.stringify(c)}`),a||=!!c.bitmap)}if(a)for(const t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:Foe}get editorStats(){let e=null;const t=new Map;for(const n of this.#Zt.values()){if(!(n instanceof Aoe))continue;const r=n.telemetryFinalData;if(!r)continue;const{type:a}=r;t.has(a)||t.set(a,Object.getPrototypeOf(n).constructor),e||=Object.create(null);const o=e[a]||=new Map;for(const[e,t]of Object.entries(r)){if("type"===e)continue;let n=o.get(e);n||(n=new Map,o.set(e,n));const r=n.get(t)??0;n.set(t,r+1)}}for(const[n,r]of t)e[n]=r.computeTelemetryFinalData(e[n]);return e}resetModifiedIds(){this.#Jt=null}get modifiedIds(){if(this.#Jt)return this.#Jt;const e=[];for(const t of this.#Zt.values())t instanceof Aoe&&t.annotationElementId&&t.serialize()&&e.push(t.annotationElementId);return this.#Jt={ids:new Set(e),hash:e.join(",")}}}class Boe extends Ioe{#tn;constructor(e){super();const{map:t,hash:n,transfer:r}=e.serializable,a=structuredClone(t,r?{transfer:r}:null);this.#tn={map:a,hash:n,transfer:r}}get print(){Rae("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#tn}get modifiedIds(){return Dae(this,"modifiedIds",{ids:new Set,hash:""})}}class joe{#nn=new Set;constructor({ownerDocument:e=globalThis.document,styleElement:t=null}){this._document=e,this.nativeFontFaces=new Set,this.styleElement=null,this.loadingRequests=[],this.loadTestFontId=0}addNativeFontFace(e){this.nativeFontFaces.add(e),this._document.fonts.add(e)}removeNativeFontFace(e){this.nativeFontFaces.delete(e),this._document.fonts.delete(e)}insertRule(e){this.styleElement||(this.styleElement=this._document.createElement("style"),this._document.documentElement.getElementsByTagName("head")[0].append(this.styleElement));const t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(const e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#nn.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(e&&!this.#nn.has(e.loadedName))if(Nae(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){const{loadedName:n,src:r,style:a}=e,o=new FontFace(n,r,a);this.addNativeFontFace(o);try{await o.load(),this.#nn.add(n),t?.(e)}catch{Aae(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}}else Rae("Not implemented: loadSystemFont without the Font Loading API.")}async bind(e){if(e.attached||e.missingFile&&!e.systemFontInfo)return;if(e.attached=!0,e.systemFontInfo)return void await this.loadSystemFont(e);if(this.isFontLoadingAPISupported){const t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw Aae(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}const t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise((t=>{const n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)}))}}get isFontLoadingAPISupported(){return Dae(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let e=!1;return(gae||"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent))&&(e=!0),Dae(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){const{loadingRequests:t}=this,n={done:!1,complete:function(){for(Nae(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;){const e=t.shift();setTimeout(e.callback,0)}},callback:e};return t.push(n),n}get _loadTestFont(){return Dae(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){function n(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function r(e,t,n,r){return e.substring(0,t)+r+e.substring(t+n)}let a,o;const c=this._document.createElement("canvas");c.width=1,c.height=1;const i=c.getContext("2d");let l=0;const s=`lt${Date.now()}${this.loadTestFontId++}`;let h=this._loadTestFont;h=r(h,976,s.length,s);const d=1482184792;let u=n(h,16);for(a=0,o=s.length-3;a<o;a+=4)u=u-d+n(s,a)|0;a<s.length&&(u=u-d+n(s+"XXX",a)|0),h=r(h,16,4,function(e){return String.fromCharCode(e>>24&255,e>>16&255,e>>8&255,255&e)}(u));const m=`@font-face {font-family:"${s}";src:url(data:font/opentype;base64,${btoa(h)});}`;this.insertRule(m);const p=this._document.createElement("div");p.style.visibility="hidden",p.style.width=p.style.height="10px",p.style.position="absolute",p.style.top=p.style.left="0px";for(const t of[e.loadedName,s]){const e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,p.append(e)}this._document.body.append(p),function e(t,n){if(++l>30)return Aae("Load test font never loaded."),void n();i.font="30px "+t,i.fillText(".",0,20),i.getImageData(0,0,1,1).data[3]>0?n():setTimeout(e.bind(null,t,n))}(s,(()=>{p.remove(),t.complete()}))}}class Uoe{constructor(e,{disableFontFace:t=!1,fontExtraProperties:n=!1,inspectFont:r=null}){this.compiledGlyphs=Object.create(null);for(const t in e)this[t]=e[t];this.disableFontFace=!0===t,this.fontExtraProperties=!0===n,this._inspectFont=r}createNativeFontFace(){if(!this.data||this.disableFontFace)return null;let e;if(this.cssFontInfo){const t={weight:this.cssFontInfo.fontWeight};this.cssFontInfo.italicAngle&&(t.style=`oblique ${this.cssFontInfo.italicAngle}deg`),e=new FontFace(this.cssFontInfo.fontFamily,this.data,t)}else e=new FontFace(this.loadedName,this.data,{});return this._inspectFont?.(this),e}createFontFaceRule(){if(!this.data||this.disableFontFace)return null;const e=`url(data:${this.mimetype};base64,${t=this.data,Uint8Array.prototype.toBase64?t.toBase64():btoa(qae(t))});`;var t;let n;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),n=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${e}}`}else n=`@font-face {font-family:"${this.loadedName}";src:${e}}`;return this._inspectFont?.(this,e),n}getPathGenerator(e,t){if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];const n=this.loadedName+"_path_"+t;let r;try{r=e.get(n)}catch(e){Aae(`getPathGenerator - ignoring character: "${e}".`)}const a=new Path2D(r||"");return this.fontExtraProperties||e.delete(n),this.compiledGlyphs[t]=a}}function Woe(){}function $oe(e){if(e instanceof $ae||e instanceof Bae||e instanceof jae||e instanceof Fae||e instanceof Uae||e instanceof Iae)return e;switch(e instanceof Error||"object"==typeof e&&null!==e||Rae('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new $ae(e.message);case"InvalidPDFException":return new Bae(e.message);case"MissingPDFException":return new jae(e.message);case"PasswordException":return new Fae(e.message,e.code);case"UnexpectedResponseException":return new Uae(e.message,e.status);case"UnknownErrorException":return new Iae(e.message,e.details)}return new Iae(e.message,e.toString())}class qoe{#rn=new AbortController;constructor(e,t,n){this.sourceName=e,this.targetName=t,this.comObj=n,this.callbackId=1,this.streamId=1,this.streamSinks=Object.create(null),this.streamControllers=Object.create(null),this.callbackCapabilities=Object.create(null),this.actionHandler=Object.create(null),n.addEventListener("message",this.#an.bind(this),{signal:this.#rn.signal})}#an({data:e}){if(e.targetName!==this.sourceName)return;if(e.stream)return void this.#on(e);if(e.callback){const t=e.callbackId,n=this.callbackCapabilities[t];if(!n)throw new Error(`Cannot resolve callback ${t}`);if(delete this.callbackCapabilities[t],1===e.callback)n.resolve(e.data);else{if(2!==e.callback)throw new Error("Unexpected callback case");n.reject($oe(e.reason))}return}const t=this.actionHandler[e.action];if(!t)throw new Error(`Unknown action from worker: ${e.action}`);if(e.callbackId){const n=this.sourceName,r=e.sourceName,a=this.comObj;Promise.try(t,e.data).then((function(t){a.postMessage({sourceName:n,targetName:r,callback:1,callbackId:e.callbackId,data:t})}),(function(t){a.postMessage({sourceName:n,targetName:r,callback:2,callbackId:e.callbackId,reason:$oe(t)})}))}else e.streamId?this.#cn(e):t(e.data)}on(e,t){const n=this.actionHandler;if(n[e])throw new Error(`There is already an actionName called "${e}"`);n[e]=t}send(e,t,n){this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,data:t},n)}sendWithPromise(e,t,n){const r=this.callbackId++,a=Promise.withResolvers();this.callbackCapabilities[r]=a;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:r,data:t},n)}catch(e){a.reject(e)}return a.promise}sendWithStream(e,t,n,r){const a=this.streamId++,o=this.sourceName,c=this.targetName,i=this.comObj;return new ReadableStream({start:n=>{const l=Promise.withResolvers();return this.streamControllers[a]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},i.postMessage({sourceName:o,targetName:c,action:e,streamId:a,data:t,desiredSize:n.desiredSize},r),l.promise},pull:e=>{const t=Promise.withResolvers();return this.streamControllers[a].pullCall=t,i.postMessage({sourceName:o,targetName:c,stream:6,streamId:a,desiredSize:e.desiredSize}),t.promise},cancel:e=>{Nae(e instanceof Error,"cancel must have a valid reason");const t=Promise.withResolvers();return this.streamControllers[a].cancelCall=t,this.streamControllers[a].isClosed=!0,i.postMessage({sourceName:o,targetName:c,stream:1,streamId:a,reason:$oe(e)}),t.promise}},n)}#cn(e){const t=e.streamId,n=this.sourceName,r=e.sourceName,a=this.comObj,o=this,c=this.actionHandler[e.action],i={enqueue(e,o=1,c){if(this.isCancelled)return;const i=this.desiredSize;this.desiredSize-=o,i>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),a.postMessage({sourceName:n,targetName:r,stream:4,streamId:t,chunk:e},c)},close(){this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:3,streamId:t}),delete o.streamSinks[t])},error(e){Nae(e instanceof Error,"error must have a valid reason"),this.isCancelled||(this.isCancelled=!0,a.postMessage({sourceName:n,targetName:r,stream:5,streamId:t,reason:$oe(e)}))},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};i.sinkCapability.resolve(),i.ready=i.sinkCapability.promise,this.streamSinks[t]=i,Promise.try(c,e.data,i).then((function(){a.postMessage({sourceName:n,targetName:r,stream:8,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:n,targetName:r,stream:8,streamId:t,reason:$oe(e)})}))}#on(e){const t=e.streamId,n=this.sourceName,r=e.sourceName,a=this.comObj,o=this.streamControllers[t],c=this.streamSinks[t];switch(e.stream){case 8:e.success?o.startCall.resolve():o.startCall.reject($oe(e.reason));break;case 7:e.success?o.pullCall.resolve():o.pullCall.reject($oe(e.reason));break;case 6:if(!c){a.postMessage({sourceName:n,targetName:r,stream:7,streamId:t,success:!0});break}c.desiredSize<=0&&e.desiredSize>0&&c.sinkCapability.resolve(),c.desiredSize=e.desiredSize,Promise.try(c.onPull||Woe).then((function(){a.postMessage({sourceName:n,targetName:r,stream:7,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:n,targetName:r,stream:7,streamId:t,reason:$oe(e)})}));break;case 4:if(Nae(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case 3:if(Nae(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#in(o,t);break;case 5:Nae(o,"error should have stream controller"),o.controller.error($oe(e.reason)),this.#in(o,t);break;case 2:e.success?o.cancelCall.resolve():o.cancelCall.reject($oe(e.reason)),this.#in(o,t);break;case 1:if(!c)break;const i=$oe(e.reason);Promise.try(c.onCancel||Woe,i).then((function(){a.postMessage({sourceName:n,targetName:r,stream:2,streamId:t,success:!0})}),(function(e){a.postMessage({sourceName:n,targetName:r,stream:2,streamId:t,reason:$oe(e)})})),c.sinkCapability.reject(i),c.isCancelled=!0,delete this.streamSinks[t];break;default:throw new Error("Unexpected stream case")}}async#in(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.#rn?.abort(),this.#rn=null}}class Goe{#ln=!1;constructor({enableHWA:e=!1}){this.#ln=e}create(e,t){if(e<=0||t<=0)throw new Error("Invalid canvas size");const n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#ln})}}reset(e,t,n){if(!e.canvas)throw new Error("Canvas is not specified");if(t<=0||n<=0)throw new Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw new Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){Rae("Abstract method `_createCanvas` called.")}}class Yoe{constructor({baseUrl:e=null,isCompressed:t=!0}){this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw new Error("Ensure that the `cMapUrl` and `cMapPacked` API parameters are provided.");if(!e)throw new Error("CMap name must be specified.");const t=this.baseUrl+e+(this.isCompressed?".bcmap":"");return this._fetch(t).then((e=>({cMapData:e,isCompressed:this.isCompressed}))).catch((e=>{throw new Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)}))}async _fetch(e){Rae("Abstract method `_fetch` called.")}}class Koe extends Yoe{async _fetch(e){const t=await aoe(e,this.isCompressed?"arraybuffer":"text");return t instanceof ArrayBuffer?new Uint8Array(t):Gae(t)}}class Xoe{addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,n,r,a){return"none"}destroy(e=!1){}}class Qoe{constructor({baseUrl:e=null}){this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw new Error("Ensure that the `standardFontDataUrl` API parameter is provided.");if(!e)throw new Error("Font filename must be specified.");const t=`${this.baseUrl}${e}`;return this._fetch(t).catch((e=>{throw new Error(`Unable to load font data at: ${t}`)}))}async _fetch(e){Rae("Abstract method `_fetch` called.")}}class Joe extends Qoe{async _fetch(e){const t=await aoe(e,"arraybuffer");return new Uint8Array(t)}}async function Zoe(e){const t=xt.getBuiltinModule("fs"),n=await t.promises.readFile(e);return new Uint8Array(n)}gae&&Aae("Please use the `legacy` build in Node.js environments.");const ece="Fill",tce="Stroke",nce="Shading";function rce(e,t){if(!t)return;const n=t[2]-t[0],r=t[3]-t[1],a=new Path2D;a.rect(t[0],t[1],n,r),e.clip(a)}class ace{getPattern(){Rae("Abstract method `getPattern` called.")}}class oce extends ace{constructor(e){super(),this._type=e[1],this._bbox=e[2],this._colorStops=e[3],this._p0=e[4],this._p1=e[5],this._r0=e[6],this._r1=e[7],this.matrix=null}_createGradient(e){let t;"axial"===this._type?t=e.createLinearGradient(this._p0[0],this._p0[1],this._p1[0],this._p1[1]):"radial"===this._type&&(t=e.createRadialGradient(this._p0[0],this._p0[1],this._r0,this._p1[0],this._p1[1],this._r1));for(const e of this._colorStops)t.addColorStop(e[0],e[1]);return t}getPattern(e,t,n,r){let a;if(r===tce||r===ece){const o=t.current.getClippedPathBoundingBox(r,goe(e))||[0,0,0,0],c=Math.ceil(o[2]-o[0])||1,i=Math.ceil(o[3]-o[1])||1,l=t.cachedCanvases.getCanvas("pattern",c,i),s=l.context;s.clearRect(0,0,s.canvas.width,s.canvas.height),s.beginPath(),s.rect(0,0,s.canvas.width,s.canvas.height),s.translate(-o[0],-o[1]),n=Qae.transform(n,[1,0,0,1,o[0],o[1]]),s.transform(...t.baseTransform),this.matrix&&s.transform(...this.matrix),rce(s,this._bbox),s.fillStyle=this._createGradient(s),s.fill(),a=e.createPattern(l.canvas,"no-repeat");const h=new DOMMatrix(n);a.setTransform(h)}else rce(e,this._bbox),a=this._createGradient(e);return a}}function cce(e,t,n,r,a,o,c,i){const l=t.coords,s=t.colors,h=e.data,d=4*e.width;let u;l[n+1]>l[r+1]&&(u=n,n=r,r=u,u=o,o=c,c=u),l[r+1]>l[a+1]&&(u=r,r=a,a=u,u=c,c=i,i=u),l[n+1]>l[r+1]&&(u=n,n=r,r=u,u=o,o=c,c=u);const m=(l[n]+t.offsetX)*t.scaleX,p=(l[n+1]+t.offsetY)*t.scaleY,v=(l[r]+t.offsetX)*t.scaleX,f=(l[r+1]+t.offsetY)*t.scaleY,z=(l[a]+t.offsetX)*t.scaleX,g=(l[a+1]+t.offsetY)*t.scaleY;if(p>=g)return;const y=s[o],M=s[o+1],E=s[o+2],b=s[c],H=s[c+1],V=s[c+2],C=s[i],L=s[i+1],w=s[i+2],k=Math.round(p),x=Math.round(g);let S,T,O,A,R,N,_,D;for(let e=k;e<=x;e++){if(e<f){const t=e<p?0:(p-e)/(p-f);S=m-(m-v)*t,T=y-(y-b)*t,O=M-(M-H)*t,A=E-(E-V)*t}else{let t;t=e>g?1:f===g?0:(f-e)/(f-g),S=v-(v-z)*t,T=b-(b-C)*t,O=H-(H-L)*t,A=V-(V-w)*t}let t;t=e<p?0:e>g?1:(p-e)/(p-g),R=m-(m-z)*t,N=y-(y-C)*t,_=M-(M-L)*t,D=E-(E-w)*t;const n=Math.round(Math.min(S,R)),r=Math.round(Math.max(S,R));let a=d*e+4*n;for(let e=n;e<=r;e++)t=(S-e)/(S-R),t<0?t=0:t>1&&(t=1),h[a++]=T-(T-N)*t|0,h[a++]=O-(O-_)*t|0,h[a++]=A-(A-D)*t|0,h[a++]=255}}function ice(e,t,n){const r=t.coords,a=t.colors;let o,c;switch(t.type){case"lattice":const i=t.verticesPerRow,l=Math.floor(r.length/i)-1,s=i-1;for(o=0;o<l;o++){let t=o*i;for(let o=0;o<s;o++,t++)cce(e,n,r[t],r[t+1],r[t+i],a[t],a[t+1],a[t+i]),cce(e,n,r[t+i+1],r[t+1],r[t+i],a[t+i+1],a[t+1],a[t+i])}break;case"triangles":for(o=0,c=r.length;o<c;o+=3)cce(e,n,r[o],r[o+1],r[o+2],a[o],a[o+1],a[o+2]);break;default:throw new Error("illegal figure")}}class lce extends ace{constructor(e){super(),this._coords=e[2],this._colors=e[3],this._figures=e[4],this._bounds=e[5],this._bbox=e[7],this._background=e[8],this.matrix=null}_createMeshCanvas(e,t,n){const r=Math.floor(this._bounds[0]),a=Math.floor(this._bounds[1]),o=Math.ceil(this._bounds[2])-r,c=Math.ceil(this._bounds[3])-a,i=Math.min(Math.ceil(Math.abs(o*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(c*e[1]*1.1)),3e3),s=o/i,h=c/l,d={coords:this._coords,colors:this._colors,offsetX:-r,offsetY:-a,scaleX:1/s,scaleY:1/h},u=i+4,m=l+4,p=n.getCanvas("mesh",u,m),v=p.context,f=v.createImageData(i,l);if(t){const e=f.data;for(let n=0,r=e.length;n<r;n+=4)e[n]=t[0],e[n+1]=t[1],e[n+2]=t[2],e[n+3]=255}for(const e of this._figures)ice(f,e,d);return v.putImageData(f,2,2),{canvas:p.canvas,offsetX:r-2*s,offsetY:a-2*h,scaleX:s,scaleY:h}}getPattern(e,t,n,r){let a;if(rce(e,this._bbox),r===nce)a=Qae.singularValueDecompose2dScale(goe(e));else if(a=Qae.singularValueDecompose2dScale(t.baseTransform),this.matrix){const e=Qae.singularValueDecompose2dScale(this.matrix);a=[a[0]*e[0],a[1]*e[1]]}const o=this._createMeshCanvas(a,r===nce?null:this._background,t.cachedCanvases);return r!==nce&&(e.setTransform(...t.baseTransform),this.matrix&&e.transform(...this.matrix)),e.translate(o.offsetX,o.offsetY),e.scale(o.scaleX,o.scaleY),e.createPattern(o.canvas,"no-repeat")}}class sce extends ace{getPattern(){return"hotpink"}}class hce{static MAX_PATTERN_SIZE=3e3;constructor(e,t,n,r,a){this.operatorList=e[2],this.matrix=e[3],this.bbox=e[4],this.xstep=e[5],this.ystep=e[6],this.paintType=e[7],this.tilingType=e[8],this.color=t,this.ctx=n,this.canvasGraphicsFactory=r,this.baseTransform=a}createPatternCanvas(e){const{bbox:t,operatorList:n,paintType:r,tilingType:a,color:o,canvasGraphicsFactory:c}=this;let{xstep:i,ystep:l}=this;i=Math.abs(i),l=Math.abs(l),Oae("TilingType: "+a);const s=t[0],h=t[1],d=t[2],u=t[3],m=d-s,p=u-h,v=Qae.singularValueDecompose2dScale(this.matrix),f=Qae.singularValueDecompose2dScale(this.baseTransform),z=v[0]*f[0],g=v[1]*f[1];let y=m,M=p,E=!1,b=!1;const H=Math.ceil(i*z),V=Math.ceil(l*g);H>=Math.ceil(m*z)?y=i:E=!0,V>=Math.ceil(p*g)?M=l:b=!0;const C=this.getSizeAndScale(y,this.ctx.canvas.width,z),L=this.getSizeAndScale(M,this.ctx.canvas.height,g),w=e.cachedCanvases.getCanvas("pattern",C.size,L.size),k=w.context,x=c.createCanvasGraphics(k);if(x.groupLevel=e.groupLevel,this.setFillAndStrokeStyleToContext(x,r,o),k.translate(-C.scale*s,-L.scale*h),x.transform(C.scale,0,0,L.scale,0,0),k.save(),this.clipBbox(x,s,h,d,u),x.baseTransform=goe(x.ctx),x.executeOperatorList(n),x.endDrawing(),k.restore(),E||b){const t=w.canvas;E&&(y=i),b&&(M=l);const n=this.getSizeAndScale(y,this.ctx.canvas.width,z),r=this.getSizeAndScale(M,this.ctx.canvas.height,g),a=n.size,o=r.size,c=e.cachedCanvases.getCanvas("pattern-workaround",a,o),d=c.context,u=E?Math.floor(m/i):0,v=b?Math.floor(p/l):0;for(let e=0;e<=u;e++)for(let n=0;n<=v;n++)d.drawImage(t,a*e,o*n,a,o,0,0,a,o);return{canvas:c.canvas,scaleX:n.scale,scaleY:r.scale,offsetX:s,offsetY:h}}return{canvas:w.canvas,scaleX:C.scale,scaleY:L.scale,offsetX:s,offsetY:h}}getSizeAndScale(e,t,n){const r=Math.max(hce.MAX_PATTERN_SIZE,t);let a=Math.ceil(e*n);return a>=r?a=r:n=a/e,{scale:n,size:a}}clipBbox(e,t,n,r,a){const o=r-t,c=a-n;e.ctx.rect(t,n,o,c),e.current.updateRectMinMax(goe(e.ctx),[t,n,r,a]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){const r=e.ctx,a=e.current;switch(t){case 1:const e=this.ctx;r.fillStyle=e.fillStyle,r.strokeStyle=e.strokeStyle,a.fillColor=e.fillStyle,a.strokeColor=e.strokeStyle;break;case 2:const o=Qae.makeHexColor(n[0],n[1],n[2]);r.fillStyle=o,r.strokeStyle=o,a.fillColor=o,a.strokeColor=o;break;default:throw new Wae(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,r){let a=n;r!==nce&&(a=Qae.transform(a,t.baseTransform),this.matrix&&(a=Qae.transform(a,this.matrix)));const o=this.createPatternCanvas(t);let c=new DOMMatrix(a);c=c.translate(o.offsetX,o.offsetY),c=c.scale(1/o.scaleX,1/o.scaleY);const i=e.createPattern(o.canvas,"repeat");return i.setTransform(c),i}}function dce({src:e,srcPos:t=0,dest:n,width:r,height:a,nonBlackColor:o=4294967295,inverseDecode:c=!1}){const i=Kae.isLittleEndian?4278190080:255,[l,s]=c?[o,i]:[i,o],h=r>>3,d=7&r,u=e.length;n=new Uint32Array(n.buffer);let m=0;for(let r=0;r<a;r++){for(const r=t+h;t<r;t++){const r=t<u?e[t]:255;n[m++]=128&r?s:l,n[m++]=64&r?s:l,n[m++]=32&r?s:l,n[m++]=16&r?s:l,n[m++]=8&r?s:l,n[m++]=4&r?s:l,n[m++]=2&r?s:l,n[m++]=1&r?s:l}if(0===d)continue;const r=t<u?e[t++]:255;for(let e=0;e<d;e++)n[m++]=r&1<<7-e?s:l}return{srcPos:t,destPos:m}}const uce=16;class mce{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let r;return void 0!==this.cache[e]?(r=this.cache[e],this.canvasFactory.reset(r,t,n)):(r=this.canvasFactory.create(t,n),this.cache[e]=r),r}delete(e){delete this.cache[e]}clear(){for(const e in this.cache){const t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function pce(e,t,n,r,a,o,c,i,l,s){const[h,d,u,m,p,v]=goe(e);if(0===d&&0===u){const f=c*h+p,z=Math.round(f),g=i*m+v,y=Math.round(g),M=(c+l)*h+p,E=Math.abs(Math.round(M)-z)||1,b=(i+s)*m+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(Math.sign(h),0,0,Math.sign(m),z,y),e.drawImage(t,n,r,a,o,0,0,E,H),e.setTransform(h,d,u,m,p,v),[E,H]}if(0===h&&0===m){const f=i*u+p,z=Math.round(f),g=c*d+v,y=Math.round(g),M=(i+s)*u+p,E=Math.abs(Math.round(M)-z)||1,b=(c+l)*d+v,H=Math.abs(Math.round(b)-y)||1;return e.setTransform(0,Math.sign(d),Math.sign(u),0,z,y),e.drawImage(t,n,r,a,o,0,0,H,E),e.setTransform(h,d,u,m,p,v),[H,E]}return e.drawImage(t,n,r,a,o,c,i,l,s),[Math.hypot(h,d)*l,Math.hypot(u,m)*s]}class vce{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=yae,this.textMatrixScale=1,this.fontMatrix=Mae,this.leading=0,this.x=0,this.y=0,this.lineX=0,this.lineY=0,this.charSpacing=0,this.wordSpacing=0,this.textHScale=1,this.textRenderingMode=0,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.patternStroke=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){const e=Object.create(this);return e.clipBox=this.clipBox.slice(),e}setCurrentPoint(e,t){this.x=e,this.y=t}updatePathMinMax(e,t,n){[t,n]=Qae.applyTransform([t,n],e),this.minX=Math.min(this.minX,t),this.minY=Math.min(this.minY,n),this.maxX=Math.max(this.maxX,t),this.maxY=Math.max(this.maxY,n)}updateRectMinMax(e,t){const n=Qae.applyTransform(t,e),r=Qae.applyTransform(t.slice(2),e),a=Qae.applyTransform([t[0],t[3]],e),o=Qae.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],r[0],a[0],o[0]),this.minY=Math.min(this.minY,n[1],r[1],a[1],o[1]),this.maxX=Math.max(this.maxX,n[0],r[0],a[0],o[0]),this.maxY=Math.max(this.maxY,n[1],r[1],a[1],o[1])}updateScalingPathMinMax(e,t){Qae.scaleMinMax(e,t),this.minX=Math.min(this.minX,t[0]),this.minY=Math.min(this.minY,t[1]),this.maxX=Math.max(this.maxX,t[2]),this.maxY=Math.max(this.maxY,t[3])}updateCurvePathMinMax(e,t,n,r,a,o,c,i,l,s){const h=Qae.bezierBoundingBox(t,n,r,a,o,c,i,l,s);s||this.updateRectMinMax(e,h)}getPathBoundingBox(e=ece,t=null){const n=[this.minX,this.minY,this.maxX,this.maxY];if(e===tce){t||Rae("Stroke bounding box must include transform.");const e=Qae.singularValueDecompose2dScale(t),r=e[0]*this.lineWidth/2,a=e[1]*this.lineWidth/2;n[0]-=r,n[1]-=a,n[2]+=r,n[3]+=a}return n}updateClipFromPath(){const e=Qae.intersect(this.clipBox,this.getPathBoundingBox());this.startNewPathAndClipBox(e||[0,0,0,0])}isEmptyClip(){return this.minX===1/0}startNewPathAndClipBox(e){this.clipBox=e,this.minX=1/0,this.minY=1/0,this.maxX=0,this.maxY=0}getClippedPathBoundingBox(e=ece,t=null){return Qae.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function fce(e,t){if(t instanceof ImageData)return void e.putImageData(t,0,0);const n=t.height,r=t.width,a=n%uce,o=(n-a)/uce,c=0===a?o:o+1,i=e.createImageData(r,uce);let l,s=0;const h=t.data,d=i.data;let u,m,p,v;if(t.kind===Lae.GRAYSCALE_1BPP){const t=h.byteLength,n=new Uint32Array(d.buffer,0,d.byteLength>>2),v=n.length,f=r+7>>3,z=4294967295,g=Kae.isLittleEndian?4278190080:255;for(u=0;u<c;u++){for(p=u<o?uce:a,l=0,m=0;m<p;m++){const e=t-s;let a=0;const o=e>f?r:8*e-7,c=-8&o;let i=0,d=0;for(;a<c;a+=8)d=h[s++],n[l++]=128&d?z:g,n[l++]=64&d?z:g,n[l++]=32&d?z:g,n[l++]=16&d?z:g,n[l++]=8&d?z:g,n[l++]=4&d?z:g,n[l++]=2&d?z:g,n[l++]=1&d?z:g;for(;a<o;a++)0===i&&(d=h[s++],i=128),n[l++]=d&i?z:g,i>>=1}for(;l<v;)n[l++]=0;e.putImageData(i,0,u*uce)}}else if(t.kind===Lae.RGBA_32BPP){for(m=0,v=r*uce*4,u=0;u<o;u++)d.set(h.subarray(s,s+v)),s+=v,e.putImageData(i,0,m),m+=uce;u<c&&(v=r*a*4,d.set(h.subarray(s,s+v)),e.putImageData(i,0,m))}else{if(t.kind!==Lae.RGB_24BPP)throw new Error(`bad image kind: ${t.kind}`);for(p=uce,v=r*p,u=0;u<c;u++){for(u>=o&&(p=a,v=r*p),l=0,m=v;m--;)d[l++]=h[s++],d[l++]=h[s++],d[l++]=h[s++],d[l++]=255;e.putImageData(i,0,u*uce)}}}function zce(e,t){if(t.bitmap)return void e.drawImage(t.bitmap,0,0);const n=t.height,r=t.width,a=n%uce,o=(n-a)/uce,c=0===a?o:o+1,i=e.createImageData(r,uce);let l=0;const s=t.data,h=i.data;for(let t=0;t<c;t++){const n=t<o?uce:a;({srcPos:l}=dce({src:s,srcPos:l,dest:h,width:r,height:n,nonBlackColor:0})),e.putImageData(i,0,t*uce)}}function gce(e,t){const n=["strokeStyle","fillStyle","fillRule","globalAlpha","lineWidth","lineCap","lineJoin","miterLimit","globalCompositeOperation","font","filter"];for(const r of n)void 0!==e[r]&&(t[r]=e[r]);void 0!==e.setLineDash&&(t.setLineDash(e.getLineDash()),t.lineDashOffset=e.lineDashOffset)}function yce(e){if(e.strokeStyle=e.fillStyle="#000000",e.fillRule="nonzero",e.globalAlpha=1,e.lineWidth=1,e.lineCap="butt",e.lineJoin="miter",e.miterLimit=10,e.globalCompositeOperation="source-over",e.font="10px sans-serif",void 0!==e.setLineDash&&(e.setLineDash([]),e.lineDashOffset=0),!gae){const{filter:t}=e;"none"!==t&&""!==t&&(e.filter="none")}}function Mce(e,t){if(t)return!0;const n=Qae.singularValueDecompose2dScale(e);n[0]=Math.fround(n[0]),n[1]=Math.fround(n[1]);const r=Math.fround((globalThis.devicePixelRatio||1)*roe.PDF_TO_CSS_UNITS);return n[0]<=r&&n[1]<=r}const Ece=["butt","round","square"],bce=["miter","round","bevel"],Hce={},Vce={};class Cce{constructor(e,t,n,r,a,{optionalContentConfig:o,markedContentStack:c=null},i,l){this.ctx=e,this.current=new vce(this.ctx.canvas.width,this.ctx.canvas.height),this.stateStack=[],this.pendingClip=null,this.pendingEOFill=!1,this.res=null,this.xobjs=null,this.commonObjs=t,this.objs=n,this.canvasFactory=r,this.filterFactory=a,this.groupStack=[],this.processingType3=null,this.baseTransform=null,this.baseTransformStack=[],this.groupLevel=0,this.smaskStack=[],this.smaskCounter=0,this.tempSMask=null,this.suspendedCtx=null,this.contentVisible=!0,this.markedContentStack=c||[],this.optionalContentConfig=o,this.cachedCanvases=new mce(this.canvasFactory),this.cachedPatterns=new Map,this.annotationCanvasMap=i,this.viewportScale=1,this.outputScaleX=1,this.outputScaleY=1,this.pageColors=l,this._cachedScaleForStroking=[-1,0],this._cachedGetSinglePixelWidth=null,this._cachedBitmapsMap=new Map}getObject(e,t=null){return"string"==typeof e?e.startsWith("g_")?this.commonObjs.get(e):this.objs.get(e):t}beginDrawing({transform:e,viewport:t,transparency:n=!1,background:r=null}){const a=this.ctx.canvas.width,o=this.ctx.canvas.height,c=this.ctx.fillStyle;if(this.ctx.fillStyle=r||"#ffffff",this.ctx.fillRect(0,0,a,o),this.ctx.fillStyle=c,n){const e=this.cachedCanvases.getCanvas("transparent",a,o);this.compositeCtx=this.ctx,this.transparentCanvas=e.canvas,this.ctx=e.context,this.ctx.save(),this.ctx.transform(...goe(this.compositeCtx))}this.ctx.save(),yce(this.ctx),e&&(this.ctx.transform(...e),this.outputScaleX=e[0],this.outputScaleY=e[0]),this.ctx.transform(...t.transform),this.viewportScale=t.scale,this.baseTransform=goe(this.ctx)}executeOperatorList(e,t,n,r){const a=e.argsArray,o=e.fnArray;let c=t||0;const i=a.length;if(i===c)return c;const l=i-c>10&&"function"==typeof n,s=l?Date.now()+15:0;let h=0;const d=this.commonObjs,u=this.objs;let m;for(;;){if(void 0!==r&&c===r.nextBreakPoint)return r.breakIt(c,n),c;if(m=o[c],m!==kae.dependency)this[m].apply(this,a[c]);else for(const e of a[c]){const t=e.startsWith("g_")?d:u;if(!t.has(e))return t.get(e,n),c}if(c++,c===i)return c;if(l&&++h>10){if(Date.now()>s)return n(),c;h=0}}}#sn(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();this.current.activeSMask=null,this.ctx.restore(),this.transparentCanvas&&(this.ctx=this.compositeCtx,this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.drawImage(this.transparentCanvas,0,0),this.ctx.restore(),this.transparentCanvas=null)}endDrawing(){this.#sn(),this.cachedCanvases.clear(),this.cachedPatterns.clear();for(const e of this._cachedBitmapsMap.values()){for(const t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#hn()}#hn(){if(this.pageColors){const e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){const t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){const n=e.width??e.displayWidth,r=e.height??e.displayHeight;let a,o,c=Math.max(Math.hypot(t[0],t[1]),1),i=Math.max(Math.hypot(t[2],t[3]),1),l=n,s=r,h="prescale1";for(;c>2&&l>1||i>2&&s>1;){let t=l,n=s;c>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),c/=l/t),i>2&&s>1&&(n=s>=16384?Math.floor(s/2)-1||1:Math.ceil(s)/2,i/=s/n),a=this.cachedCanvases.getCanvas(h,t,n),o=a.context,o.clearRect(0,0,t,n),o.drawImage(e,0,0,l,s,0,0,t,n),e=a.canvas,l=t,s=n,h="prescale1"===h?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:s}}_createMaskCanvas(e){const t=this.ctx,{width:n,height:r}=e,a=this.current.fillColor,o=this.current.patternFill,c=goe(t);let i,l,s,h;if((e.bitmap||e.data)&&e.count>1){const t=e.bitmap||e.data.buffer;l=JSON.stringify(o?c:[c.slice(0,4),a]),i=this._cachedBitmapsMap.get(t),i||(i=new Map,this._cachedBitmapsMap.set(t,i));const n=i.get(l);if(n&&!o)return{canvas:n,offsetX:Math.round(Math.min(c[0],c[2])+c[4]),offsetY:Math.round(Math.min(c[1],c[3])+c[5])};s=n}s||(h=this.cachedCanvases.getCanvas("maskCanvas",n,r),zce(h.context,e));let d=Qae.transform(c,[1/n,0,0,-1/r,0,0]);d=Qae.transform(d,[1,0,0,1,0,-r]);const[u,m,p,v]=Qae.getAxialAlignedBoundingBox([0,0,n,r],d),f=Math.round(p-u)||1,z=Math.round(v-m)||1,g=this.cachedCanvases.getCanvas("fillCanvas",f,z),y=g.context,M=u,E=m;y.translate(-M,-E),y.transform(...d),s||(s=this._scaleImage(h.canvas,yoe(y)),s=s.img,i&&o&&i.set(l,s)),y.imageSmoothingEnabled=Mce(goe(y),e.interpolate),pce(y,s,0,0,s.width,s.height,0,0,n,r),y.globalCompositeOperation="source-in";const b=Qae.transform(yoe(y),[1,0,0,1,-M,-E]);return y.fillStyle=o?a.getPattern(t,this,b,ece):a,y.fillRect(0,0,n,r),i&&!o&&(this.cachedCanvases.delete("fillCanvas"),i.set(l,g.canvas)),{canvas:g.canvas,offsetX:Math.round(M),offsetY:Math.round(E)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=Ece[e]}setLineJoin(e){this.ctx.lineJoin=bce[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){const n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(const[t,n]of e)switch(t){case"LW":this.setLineWidth(n);break;case"LC":this.setLineCap(n);break;case"LJ":this.setLineJoin(n);break;case"ML":this.setMiterLimit(n);break;case"D":this.setDash(n[0],n[1]);break;case"RI":this.setRenderingIntent(n);break;case"FL":this.setFlatness(n);break;case"Font":this.setFont(n[0],n[1]);break;case"CA":this.current.strokeAlpha=n;break;case"ca":this.current.fillAlpha=n,this.ctx.globalAlpha=n;break;case"BM":this.ctx.globalCompositeOperation=n;break;case"SMask":this.current.activeSMask=n?this.tempSMask:null,this.tempSMask=null,this.checkSMaskState();break;case"TR":this.ctx.filter=this.current.transferMaps=this.filterFactory.addFilter(n)}}get inSMaskMode(){return!!this.suspendedCtx}checkSMaskState(){const e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw new Error("beginSMaskMode called while already in smask mode");const e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,r=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=r.context;const a=this.ctx;a.setTransform(...goe(this.suspendedCtx)),gce(this.suspendedCtx,a),function(e,t){if(e._removeMirroring)throw new Error("Context is already forwarding operations.");e.__originalSave=e.save,e.__originalRestore=e.restore,e.__originalRotate=e.rotate,e.__originalScale=e.scale,e.__originalTranslate=e.translate,e.__originalTransform=e.transform,e.__originalSetTransform=e.setTransform,e.__originalResetTransform=e.resetTransform,e.__originalClip=e.clip,e.__originalMoveTo=e.moveTo,e.__originalLineTo=e.lineTo,e.__originalBezierCurveTo=e.bezierCurveTo,e.__originalRect=e.rect,e.__originalClosePath=e.closePath,e.__originalBeginPath=e.beginPath,e._removeMirroring=()=>{e.save=e.__originalSave,e.restore=e.__originalRestore,e.rotate=e.__originalRotate,e.scale=e.__originalScale,e.translate=e.__originalTranslate,e.transform=e.__originalTransform,e.setTransform=e.__originalSetTransform,e.resetTransform=e.__originalResetTransform,e.clip=e.__originalClip,e.moveTo=e.__originalMoveTo,e.lineTo=e.__originalLineTo,e.bezierCurveTo=e.__originalBezierCurveTo,e.rect=e.__originalRect,e.closePath=e.__originalClosePath,e.beginPath=e.__originalBeginPath,delete e._removeMirroring},e.save=function(){t.save(),this.__originalSave()},e.restore=function(){t.restore(),this.__originalRestore()},e.translate=function(e,n){t.translate(e,n),this.__originalTranslate(e,n)},e.scale=function(e,n){t.scale(e,n),this.__originalScale(e,n)},e.transform=function(e,n,r,a,o,c){t.transform(e,n,r,a,o,c),this.__originalTransform(e,n,r,a,o,c)},e.setTransform=function(e,n,r,a,o,c){t.setTransform(e,n,r,a,o,c),this.__originalSetTransform(e,n,r,a,o,c)},e.resetTransform=function(){t.resetTransform(),this.__originalResetTransform()},e.rotate=function(e){t.rotate(e),this.__originalRotate(e)},e.clip=function(e){t.clip(e),this.__originalClip(e)},e.moveTo=function(e,n){t.moveTo(e,n),this.__originalMoveTo(e,n)},e.lineTo=function(e,n){t.lineTo(e,n),this.__originalLineTo(e,n)},e.bezierCurveTo=function(e,n,r,a,o,c){t.bezierCurveTo(e,n,r,a,o,c),this.__originalBezierCurveTo(e,n,r,a,o,c)},e.rect=function(e,n,r,a){t.rect(e,n,r,a),this.__originalRect(e,n,r,a)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(a,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw new Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),gce(this.ctx,this.suspendedCtx),this.ctx=this.suspendedCtx,this.suspendedCtx=null}compose(e){if(!this.current.activeSMask)return;e?(e[0]=Math.floor(e[0]),e[1]=Math.floor(e[1]),e[2]=Math.ceil(e[2]),e[3]=Math.ceil(e[3])):e=[0,0,this.ctx.canvas.width,this.ctx.canvas.height];const t=this.current.activeSMask,n=this.suspendedCtx;this.composeSMask(n,t,this.ctx,e),this.ctx.save(),this.ctx.setTransform(1,0,0,1,0,0),this.ctx.clearRect(0,0,this.ctx.canvas.width,this.ctx.canvas.height),this.ctx.restore()}composeSMask(e,t,n,r){const a=r[0],o=r[1],c=r[2]-a,i=r[3]-o;0!==c&&0!==i&&(this.genericComposeSMask(t.context,n,c,i,t.subtype,t.backdrop,t.transferMap,a,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore())}genericComposeSMask(e,t,n,r,a,o,c,i,l,s,h){let d=e.canvas,u=i-s,m=l-h;if(o){const t=Qae.makeHexColor(...o);if(u<0||m<0||u+n>d.width||m+r>d.height){const e=this.cachedCanvases.getCanvas("maskExtension",n,r),a=e.context;a.drawImage(d,-u,-m),a.globalCompositeOperation="destination-atop",a.fillStyle=t,a.fillRect(0,0,n,r),a.globalCompositeOperation="source-over",d=e.canvas,u=m=0}else{e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);const a=new Path2D;a.rect(u,m,n,r),e.clip(a),e.globalCompositeOperation="destination-atop",e.fillStyle=t,e.fillRect(u,m,n,r),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),"Alpha"===a&&c?t.filter=this.filterFactory.addAlphaFilter(c):"Luminosity"===a&&(t.filter=this.filterFactory.addLuminosityFilter(c));const p=new Path2D;p.rect(i,l,n,r),t.clip(p),t.globalCompositeOperation="destination-in",t.drawImage(d,u,m,n,r,i,l,n,r),t.restore()}save(){this.inSMaskMode?(gce(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();const e=this.current;this.stateStack.push(e),this.current=e.clone()}restore(){0===this.stateStack.length&&this.inSMaskMode&&this.endSMaskMode(),0!==this.stateStack.length&&(this.current=this.stateStack.pop(),this.inSMaskMode?(this.suspendedCtx.restore(),gce(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,r,a,o){this.ctx.transform(e,t,n,r,a,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){const r=this.ctx,a=this.current;let o,c,i=a.x,l=a.y;const s=goe(r),h=0===s[0]&&0===s[3]||0===s[1]&&0===s[2],d=h?n.slice(0):null;for(let n=0,u=0,m=e.length;n<m;n++)switch(0|e[n]){case kae.rectangle:i=t[u++],l=t[u++];const e=t[u++],n=t[u++],m=i+e,p=l+n;r.moveTo(i,l),0===e||0===n?r.lineTo(m,p):(r.lineTo(m,l),r.lineTo(m,p),r.lineTo(i,p)),h||a.updateRectMinMax(s,[i,l,m,p]),r.closePath();break;case kae.moveTo:i=t[u++],l=t[u++],r.moveTo(i,l),h||a.updatePathMinMax(s,i,l);break;case kae.lineTo:i=t[u++],l=t[u++],r.lineTo(i,l),h||a.updatePathMinMax(s,i,l);break;case kae.curveTo:o=i,c=l,i=t[u+4],l=t[u+5],r.bezierCurveTo(t[u],t[u+1],t[u+2],t[u+3],i,l),a.updateCurvePathMinMax(s,o,c,t[u],t[u+1],t[u+2],t[u+3],i,l,d),u+=6;break;case kae.curveTo2:o=i,c=l,r.bezierCurveTo(i,l,t[u],t[u+1],t[u+2],t[u+3]),a.updateCurvePathMinMax(s,o,c,i,l,t[u],t[u+1],t[u+2],t[u+3],d),i=t[u+2],l=t[u+3],u+=4;break;case kae.curveTo3:o=i,c=l,i=t[u+2],l=t[u+3],r.bezierCurveTo(t[u],t[u+1],i,l,i,l),a.updateCurvePathMinMax(s,o,c,t[u],t[u+1],i,l,i,l,d),u+=4;break;case kae.closePath:r.closePath()}h&&a.updateScalingPathMinMax(s,d),a.setCurrentPoint(i,l)}closePath(){this.ctx.closePath()}stroke(e=!0){const t=this.ctx,n=this.current.strokeColor;t.globalAlpha=this.current.strokeAlpha,this.contentVisible&&("object"==typeof n&&n?.getPattern?(t.save(),t.strokeStyle=n.getPattern(t,this,yoe(t),tce),this.rescaleAndStroke(!1),t.restore()):this.rescaleAndStroke(!0)),e&&this.consumePath(this.current.getClippedPathBoundingBox()),t.globalAlpha=this.current.fillAlpha}closeStroke(){this.closePath(),this.stroke()}fill(e=!0){const t=this.ctx,n=this.current.fillColor;let r=!1;this.current.patternFill&&(t.save(),t.fillStyle=n.getPattern(t,this,yoe(t),ece),r=!0);const a=this.current.getClippedPathBoundingBox();this.contentVisible&&null!==a&&(this.pendingEOFill?(t.fill("evenodd"),this.pendingEOFill=!1):t.fill()),r&&t.restore(),e&&this.consumePath(a)}eoFill(){this.pendingEOFill=!0,this.fill()}fillStroke(){this.fill(!1),this.stroke(!1),this.consumePath()}eoFillStroke(){this.pendingEOFill=!0,this.fillStroke()}closeFillStroke(){this.closePath(),this.fillStroke()}closeEOFillStroke(){this.pendingEOFill=!0,this.closePath(),this.fillStroke()}endPath(){this.consumePath()}clip(){this.pendingClip=Hce}eoClip(){this.pendingClip=Vce}beginText(){this.current.textMatrix=yae,this.current.textMatrixScale=1,this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}endText(){const e=this.pendingTextPaths,t=this.ctx;if(void 0===e)return void t.beginPath();const n=new Path2D,r=t.getTransform().invertSelf();for(const{transform:t,x:a,y:o,fontSize:c,path:i}of e)n.addPath(i,new DOMMatrix(t).preMultiplySelf(r).translate(a,o).scale(c,-c));t.clip(n),t.beginPath(),delete this.pendingTextPaths}setCharSpacing(e){this.current.charSpacing=e}setWordSpacing(e){this.current.wordSpacing=e}setHScale(e){this.current.textHScale=e/100}setLeading(e){this.current.leading=-e}setFont(e,t){const n=this.commonObjs.get(e),r=this.current;if(!n)throw new Error(`Can't find font for ${e}`);if(r.fontMatrix=n.fontMatrix||Mae,0!==r.fontMatrix[0]&&0!==r.fontMatrix[3]||Aae("Invalid font matrix for font "+e),t<0?(t=-t,r.fontDirection=-1):r.fontDirection=1,this.current.font=n,this.current.fontSize=t,n.isType3Font)return;const a=n.loadedName||"sans-serif",o=n.systemFontInfo?.css||`"${a}", ${n.fallbackName}`;let c="normal";n.black?c="900":n.bold&&(c="bold");const i=n.italic?"italic":"normal";let l=t;t<16?l=16:t>100&&(l=100),this.current.fontSizeScale=t/l,this.ctx.font=`${i} ${c} ${l}px ${o}`}setTextRenderingMode(e){this.current.textRenderingMode=e}setTextRise(e){this.current.textRise=e}moveText(e,t){this.current.x=this.current.lineX+=e,this.current.y=this.current.lineY+=t}setLeadingMoveText(e,t){this.setLeading(-t),this.moveText(e,t)}setTextMatrix(e,t,n,r,a,o){this.current.textMatrix=[e,t,n,r,a,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}#dn(e,t,n){const r=new Path2D;return r.addPath(e,new DOMMatrix(n).invertSelf().multiplySelf(t)),r}paintChar(e,t,n,r,a){const o=this.ctx,c=this.current,i=c.font,l=c.textRenderingMode,s=c.fontSize/c.fontSizeScale,h=3&l,d=!!(4&l),u=c.patternFill&&!i.missingFile,m=c.patternStroke&&!i.missingFile;let p;if((i.disableFontFace||d||u||m)&&(p=i.getPathGenerator(this.commonObjs,e)),i.disableFontFace||u||m){if(o.save(),o.translate(t,n),o.scale(s,-s),0===h||2===h)if(r){const e=o.getTransform();o.setTransform(...r),o.fill(this.#dn(p,e,r))}else o.fill(p);if(1===h||2===h)if(a){const e=o.getTransform();o.setTransform(...a),o.stroke(this.#dn(p,e,a))}else o.lineWidth/=s,o.stroke(p);o.restore()}else 0!==h&&2!==h||o.fillText(e,t,n),1!==h&&2!==h||o.strokeText(e,t,n);d&&(this.pendingTextPaths||=[]).push({transform:goe(o),x:t,y:n,fontSize:s,path:p})}get isFontSubpixelAAEnabled(){const{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);const t=e.getImageData(0,0,10,10).data;let n=!1;for(let e=3;e<t.length;e+=4)if(t[e]>0&&t[e]<255){n=!0;break}return Dae(this,"isFontSubpixelAAEnabled",n)}showText(e){const t=this.current,n=t.font;if(n.isType3Font)return this.showType3Text(e);const r=t.fontSize;if(0===r)return;const a=this.ctx,o=t.fontSizeScale,c=t.charSpacing,i=t.wordSpacing,l=t.fontDirection,s=t.textHScale*l,h=e.length,d=n.vertical,u=d?1:-1,m=n.defaultVMetrics,p=r*t.fontMatrix[0],v=0===t.textRenderingMode&&!n.disableFontFace&&!t.patternFill;let f,z;if(a.save(),a.transform(...t.textMatrix),a.translate(t.x,t.y+t.textRise),l>0?a.scale(s,-1):a.scale(s,1),t.patternFill){a.save();const e=t.fillColor.getPattern(a,this,yoe(a),ece);f=goe(a),a.restore(),a.fillStyle=e}if(t.patternStroke){a.save();const e=t.strokeColor.getPattern(a,this,yoe(a),tce);z=goe(a),a.restore(),a.strokeStyle=e}let g=t.lineWidth;const y=t.textMatrixScale;if(0===y||0===g){const e=3&t.textRenderingMode;1!==e&&2!==e||(g=this.getSinglePixelWidth())}else g/=y;if(1!==o&&(a.scale(o,o),g/=o),a.lineWidth=g,n.isInvalidPDFjsFont){const n=[];let r=0;for(const t of e)n.push(t.unicode),r+=t.width;return a.fillText(n.join(""),0,0),t.x+=r*p*s,a.restore(),void this.compose()}let M,E=0;for(M=0;M<h;++M){const t=e[M];if("number"==typeof t){E+=u*t*r/1e3;continue}let s=!1;const h=(t.isSpace?i:0)+c,g=t.fontChar,y=t.accent;let b,H,V=t.width;if(d){const e=t.vmetric||m,n=-(t.vmetric?e[1]:.5*V)*p,r=e[2]*p;V=e?-e[0]:V,b=n/o,H=(E+r)/o}else b=E/o,H=0;if(n.remeasure&&V>0){const e=1e3*a.measureText(g).width/r*o;if(V<e&&this.isFontSubpixelAAEnabled){const t=V/e;s=!0,a.save(),a.scale(t,1),b/=t}else V!==e&&(b+=(V-e)/2e3*r/o)}if(this.contentVisible&&(t.isInFont||n.missingFile))if(v&&!y)a.fillText(g,b,H);else if(this.paintChar(g,b,H,f,z),y){const e=b+r*y.offset.x/o,t=H-r*y.offset.y/o;this.paintChar(y.fontChar,e,t,f,z)}E+=d?V*p-h*l:V*p+h*l,s&&a.restore()}d?t.y-=E:t.x+=E*s,a.restore(),this.compose()}showType3Text(e){const t=this.ctx,n=this.current,r=n.font,a=n.fontSize,o=n.fontDirection,c=r.vertical?1:-1,i=n.charSpacing,l=n.wordSpacing,s=n.textHScale*o,h=n.fontMatrix||Mae,d=e.length;let u,m,p,v;if(3!==n.textRenderingMode&&0!==a){for(this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null,t.save(),t.transform(...n.textMatrix),t.translate(n.x,n.y),t.scale(s,o),u=0;u<d;++u){if(m=e[u],"number"==typeof m){v=c*m*a/1e3,this.ctx.translate(v,0),n.x+=v*s;continue}const o=(m.isSpace?l:0)+i,d=r.charProcOperatorList[m.operatorListId];d?(this.contentVisible&&(this.processingType3=m,this.save(),t.scale(a,a),t.transform(...h),this.executeOperatorList(d),this.restore()),p=Qae.applyTransform([m.width,0],h)[0]*a+o,t.translate(p,0),n.x+=p*s):Aae(`Type3 character "${m.operatorListId}" is not available.`)}t.restore(),this.processingType3=null}}setCharWidth(e,t){}setCharWidthAndBounds(e,t,n,r,a,o){this.ctx.rect(n,r,a-n,o-r),this.ctx.clip(),this.endPath()}getColorN_Pattern(e){let t;if("TilingPattern"===e[0]){const n=e[1],r=this.baseTransform||goe(this.ctx),a={createCanvasGraphics:e=>new Cce(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})};t=new hce(e,n,this.ctx,a,r)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments),this.current.patternStroke=!0}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){this.ctx.strokeStyle=this.current.strokeColor=Qae.makeHexColor(e,t,n),this.current.patternStroke=!1}setStrokeTransparent(){this.ctx.strokeStyle=this.current.strokeColor="transparent",this.current.patternStroke=!1}setFillRGBColor(e,t,n){this.ctx.fillStyle=this.current.fillColor=Qae.makeHexColor(e,t,n),this.current.patternFill=!1}setFillTransparent(){this.ctx.fillStyle=this.current.fillColor="transparent",this.current.patternFill=!1}_getPattern(e,t=null){let n;return this.cachedPatterns.has(e)?n=this.cachedPatterns.get(e):(n=function(e){switch(e[0]){case"RadialAxial":return new oce(e);case"Mesh":return new lce(e);case"Dummy":return new sce}throw new Error(`Unknown IR type: ${e[0]}`)}(this.getObject(e)),this.cachedPatterns.set(e,n)),t&&(n.matrix=t),n}shadingFill(e){if(!this.contentVisible)return;const t=this.ctx;this.save();const n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,yoe(t),nce);const r=yoe(t);if(r){const{width:e,height:n}=t.canvas,[a,o,c,i]=Qae.getAxialAlignedBoundingBox([0,0,e,n],r);this.ctx.fillRect(a,o,c-a,i-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){Rae("Should not call beginInlineImage")}beginImageData(){Rae("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(this.contentVisible&&(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=goe(this.ctx),t)){const e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(goe(this.ctx),t),this.clip(),this.endPath()}}paintFormXObjectEnd(){this.contentVisible&&(this.restore(),this.baseTransform=this.baseTransformStack.pop())}beginGroup(e){if(!this.contentVisible)return;this.save(),this.inSMaskMode&&(this.endSMaskMode(),this.current.activeSMask=null);const t=this.ctx;e.isolated||Oae("TODO: Support non-isolated groups."),e.knockout&&Aae("Knockout groups not supported.");const n=goe(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw new Error("Bounding box is required.");let r=Qae.getAxialAlignedBoundingBox(e.bbox,goe(t));const a=[0,0,t.canvas.width,t.canvas.height];r=Qae.intersect(r,a)||[0,0,0,0];const o=Math.floor(r[0]),c=Math.floor(r[1]),i=Math.max(Math.ceil(r[2])-o,1),l=Math.max(Math.ceil(r[3])-c,1);this.current.startNewPathAndClipBox([0,0,i,l]);let s="groupAt"+this.groupLevel;e.smask&&(s+="_smask_"+this.smaskCounter++%2);const h=this.cachedCanvases.getCanvas(s,i,l),d=h.context;d.translate(-o,-c),d.transform(...n),e.smask?this.smaskStack.push({canvas:h.canvas,context:d,offsetX:o,offsetY:c,subtype:e.smask.subtype,backdrop:e.smask.backdrop,transferMap:e.smask.transferMap||null,startTransformInverse:null}):(t.setTransform(1,0,0,1,0,0),t.translate(o,c),t.save()),gce(t,d),this.ctx=d,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;const t=this.ctx,n=this.groupStack.pop();if(this.ctx=n,this.ctx.imageSmoothingEnabled=!1,e.smask)this.tempSMask=this.smaskStack.pop(),this.restore();else{this.ctx.restore();const e=goe(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);const n=Qae.getAxialAlignedBoundingBox([0,0,t.canvas.width,t.canvas.height],e);this.ctx.drawImage(t.canvas,0,0),this.ctx.restore(),this.compose(n)}}beginAnnotation(e,t,n,r,a){if(this.#sn(),yce(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){const r=t[2]-t[0],o=t[3]-t[1];if(a&&this.annotationCanvasMap){(n=n.slice())[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=r,t[3]=o;const[a,c]=Qae.singularValueDecompose2dScale(goe(this.ctx)),{viewportScale:i}=this,l=Math.ceil(r*this.outputScaleX*i),s=Math.ceil(o*this.outputScaleY*i);this.annotationCanvas=this.canvasFactory.create(l,s);const{canvas:h,context:d}=this.annotationCanvas;this.annotationCanvasMap.set(e,h),this.annotationCanvas.savedCtx=this.ctx,this.ctx=d,this.ctx.save(),this.ctx.setTransform(a,0,0,-c,0,o*c),yce(this.ctx)}else yce(this.ctx),this.endPath(),this.ctx.rect(t[0],t[1],r,o),this.ctx.clip(),this.ctx.beginPath()}this.current=new vce(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...r)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#hn(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;const t=e.count;(e=this.getObject(e.data,e)).count=t;const n=this.ctx,r=this.processingType3;if(r&&(void 0===r.compiled&&(r.compiled=function(e){const{width:t,height:n}=e;if(t>1e3||n>1e3)return null;const r=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=t+1;let o,c,i,l=new Uint8Array(a*(n+1));const s=t+7&-8;let h=new Uint8Array(s*n),d=0;for(const t of e.data){let e=128;for(;e>0;)h[d++]=t&e?0:255,e>>=1}let u=0;for(d=0,0!==h[d]&&(l[0]=1,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(l[c]=h[d]?2:1,++u),d++;for(0!==h[d]&&(l[c]=2,++u),o=1;o<n;o++){d=o*s,i=o*a,h[d-s]!==h[d]&&(l[i]=h[d]?1:8,++u);let e=(h[d]?4:0)+(h[d-s]?8:0);for(c=1;c<t;c++)e=(e>>2)+(h[d+1]?4:0)+(h[d-s+1]?8:0),r[e]&&(l[i+c]=r[e],++u),d++;if(h[d-s]!==h[d]&&(l[i+c]=h[d]?2:4,++u),u>1e3)return null}for(d=s*(n-1),i=o*a,0!==h[d]&&(l[i]=8,++u),c=1;c<t;c++)h[d]!==h[d+1]&&(l[i+c]=h[d]?4:8,++u),d++;if(0!==h[d]&&(l[i+c]=4,++u),u>1e3)return null;const m=new Int32Array([0,a,-1,0,-a,0,0,0,1]),p=new Path2D;for(o=0;u&&o<=n;o++){let e=o*a;const n=e+t;for(;e<n&&!l[e];)e++;if(e===n)continue;p.moveTo(e%a,o);const r=e;let c=l[e];do{const t=m[c];do{e+=t}while(!l[e]);const n=l[e];5!==n&&10!==n?(c=n,l[e]=0):(c=n&51*c>>4,l[e]&=c>>2|c<<2),p.lineTo(e%a,e/a|0),l[e]||--u}while(r!==e);--o}return h=null,l=null,function(e){e.save(),e.scale(1/t,-1/n),e.translate(0,-n),e.fill(p),e.beginPath(),e.restore()}}(e)),r.compiled))return void r.compiled(n);const a=this._createMaskCanvas(e),o=a.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,a.offsetX,a.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,r=0,a,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);const c=this.ctx;c.save();const i=goe(c);c.transform(t,n,r,a,0,0);const l=this._createMaskCanvas(e);c.setTransform(1,0,0,1,l.offsetX-i[4],l.offsetY-i[5]);for(let e=0,s=o.length;e<s;e+=2){const s=Qae.transform(i,[t,n,r,a,o[e],o[e+1]]),[h,d]=Qae.applyTransform([0,0],s);c.drawImage(l.canvas,h,d)}c.restore(),this.compose()}paintImageMaskXObjectGroup(e){if(!this.contentVisible)return;const t=this.ctx,n=this.current.fillColor,r=this.current.patternFill;for(const a of e){const{data:e,width:o,height:c,transform:i}=a,l=this.cachedCanvases.getCanvas("maskCanvas",o,c),s=l.context;s.save(),zce(s,this.getObject(e,a)),s.globalCompositeOperation="source-in",s.fillStyle=r?n.getPattern(s,this,yoe(t),ece):n,s.fillRect(0,0,o,c),s.restore(),t.save(),t.transform(...i),t.scale(1,-1),pce(t,l.canvas,0,0,o,c,0,-1,1,1),t.restore()}this.compose()}paintImageXObject(e){if(!this.contentVisible)return;const t=this.getObject(e);t?this.paintInlineImageXObject(t):Aae("Dependent image isn't ready yet")}paintImageXObjectRepeat(e,t,n,r){if(!this.contentVisible)return;const a=this.getObject(e);if(!a)return void Aae("Dependent image isn't ready yet");const o=a.width,c=a.height,i=[];for(let e=0,a=r.length;e<a;e+=2)i.push({transform:[t,0,0,n,r[e],r[e+1]],x:0,y:0,w:o,h:c});this.paintInlineImageXObjectGroup(a,i)}applyTransferMapsToCanvas(e){return"none"!==this.current.transferMaps&&(e.filter=this.current.transferMaps,e.drawImage(e.canvas,0,0),e.filter="none"),e.canvas}applyTransferMapsToBitmap(e){if("none"===this.current.transferMaps)return e.bitmap;const{bitmap:t,width:n,height:r}=e,a=this.cachedCanvases.getCanvas("inlineImage",n,r),o=a.context;return o.filter=this.current.transferMaps,o.drawImage(t,0,0),o.filter="none",a.canvas}paintInlineImageXObject(e){if(!this.contentVisible)return;const t=e.width,n=e.height,r=this.ctx;if(this.save(),!gae){const{filter:e}=r;"none"!==e&&""!==e&&(r.filter="none")}let a;if(r.scale(1/t,-1/n),e.bitmap)a=this.applyTransferMapsToBitmap(e);else if("function"==typeof HTMLElement&&e instanceof HTMLElement||!e.data)a=e;else{const r=this.cachedCanvases.getCanvas("inlineImage",t,n).context;fce(r,e),a=this.applyTransferMapsToCanvas(r)}const o=this._scaleImage(a,yoe(r));r.imageSmoothingEnabled=Mce(goe(r),e.interpolate),pce(r,o.img,0,0,o.paintWidth,o.paintHeight,0,-n,t,n),this.compose(),this.restore()}paintInlineImageXObjectGroup(e,t){if(!this.contentVisible)return;const n=this.ctx;let r;if(e.bitmap)r=e.bitmap;else{const t=e.width,n=e.height,a=this.cachedCanvases.getCanvas("inlineImage",t,n).context;fce(a,e),r=this.applyTransferMapsToCanvas(a)}for(const e of t)n.save(),n.transform(...e.transform),n.scale(1,-1),pce(n,r,e.x,e.y,e.w,e.h,0,-1,1,1),n.restore();this.compose()}paintSolidColorImageMask(){this.contentVisible&&(this.ctx.fillRect(0,0,1,1),this.compose())}markPoint(e){}markPointProps(e,t){}beginMarkedContent(e){this.markedContentStack.push({visible:!0})}beginMarkedContentProps(e,t){"OC"===e?this.markedContentStack.push({visible:this.optionalContentConfig.isVisible(t)}):this.markedContentStack.push({visible:!0}),this.contentVisible=this.isContentVisible()}endMarkedContent(){this.markedContentStack.pop(),this.contentVisible=this.isContentVisible()}beginCompat(){}endCompat(){}consumePath(e){const t=this.current.isEmptyClip();this.pendingClip&&this.current.updateClipFromPath(),this.pendingClip||this.compose(e);const n=this.ctx;this.pendingClip&&(t||(this.pendingClip===Vce?n.clip("evenodd"):n.clip()),this.pendingClip=null),this.current.startNewPathAndClipBox(this.current.clipBox),n.beginPath()}getSinglePixelWidth(){if(!this._cachedGetSinglePixelWidth){const e=goe(this.ctx);if(0===e[1]&&0===e[2])this._cachedGetSinglePixelWidth=1/Math.min(Math.abs(e[0]),Math.abs(e[3]));else{const t=Math.abs(e[0]*e[3]-e[2]*e[1]),n=Math.hypot(e[0],e[2]),r=Math.hypot(e[1],e[3]);this._cachedGetSinglePixelWidth=Math.max(n,r)/t}}return this._cachedGetSinglePixelWidth}getScaleForStroking(){if(-1===this._cachedScaleForStroking[0]){const{lineWidth:e}=this.current,{a:t,b:n,c:r,d:a}=this.ctx.getTransform();let o,c;if(0===n&&0===r){const n=Math.abs(t),r=Math.abs(a);if(n===r)if(0===e)o=c=1/n;else{const t=n*e;o=c=t<1?1/t:1}else if(0===e)o=1/n,c=1/r;else{const t=n*e,a=r*e;o=t<1?1/t:1,c=a<1?1/a:1}}else{const i=Math.abs(t*a-n*r),l=Math.hypot(t,n),s=Math.hypot(r,a);if(0===e)o=s/i,c=l/i;else{const t=e*i;o=s>t?s/t:1,c=l>t?l/t:1}}this._cachedScaleForStroking[0]=o,this._cachedScaleForStroking[1]=c}return this._cachedScaleForStroking}rescaleAndStroke(e){const{ctx:t}=this,{lineWidth:n}=this.current,[r,a]=this.getScaleForStroking();if(t.lineWidth=n||1,1===r&&1===a)return void t.stroke();const o=t.getLineDash();if(e&&t.save(),t.scale(r,a),o.length>0){const e=Math.max(r,a);t.setLineDash(o.map((t=>t/e))),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(const e in kae)void 0!==Cce.prototype[e]&&(Cce.prototype[kae[e]]=Cce.prototype[e]);class Lce{static#un=null;static#mn="";static get workerPort(){return this.#un}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw new Error("Invalid `workerPort` type.");this.#un=e}static get workerSrc(){return this.#mn}static set workerSrc(e){if("string"!=typeof e)throw new Error("Invalid `workerSrc` type.");this.#mn=e}}class wce{#pn;#vn;constructor({parsedData:e,rawData:t}){this.#pn=e,this.#vn=t}getRaw(){return this.#vn}get(e){return this.#pn.get(e)??null}getAll(){return Yae(this.#pn)}has(e){return this.#pn.has(e)}}const kce=Symbol("INTERNAL");class xce{#fn=!1;#zn=!1;#gn=!1;#yn=!0;constructor(e,{name:t,intent:n,usage:r,rbGroups:a}){this.#fn=!!(2&e),this.#zn=!!(4&e),this.name=t,this.intent=n,this.usage=r,this.rbGroups=a}get visible(){if(this.#gn)return this.#yn;if(!this.#yn)return!1;const{print:e,view:t}=this.usage;return this.#fn?"OFF"!==t?.viewState:!this.#zn||"OFF"!==e?.printState}_setVisible(e,t,n=!1){e!==kce&&Rae("Internal method `_setVisible` called."),this.#gn=n,this.#yn=t}}class Sce{#Mn=null;#En=new Map;#bn=null;#Hn=null;constructor(e,t=2){if(this.renderingIntent=t,this.name=null,this.creator=null,null!==e){this.name=e.name,this.creator=e.creator,this.#Hn=e.order;for(const n of e.groups)this.#En.set(n.id,new xce(t,n));if("OFF"===e.baseState)for(const e of this.#En.values())e._setVisible(kce,!1);for(const t of e.on)this.#En.get(t)._setVisible(kce,!0);for(const t of e.off)this.#En.get(t)._setVisible(kce,!1);this.#bn=this.getHash()}}#Vn(e){const t=e.length;if(t<2)return!0;const n=e[0];for(let r=1;r<t;r++){const t=e[r];let a;if(Array.isArray(t))a=this.#Vn(t);else{if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;a=this.#En.get(t).visible}switch(n){case"And":if(!a)return!1;break;case"Or":if(a)return!0;break;case"Not":return!a;default:return!0}}return"And"===n}isVisible(e){if(0===this.#En.size)return!0;if(!e)return Oae("Optional content group not defined."),!0;if("OCG"===e.type)return this.#En.has(e.id)?this.#En.get(e.id).visible:(Aae(`Optional content group not found: ${e.id}`),!0);if("OCMD"===e.type){if(e.expression)return this.#Vn(e.expression);if(!e.policy||"AnyOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!0}return!1}if("AllOn"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!1}return!0}if("AnyOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(!this.#En.get(t).visible)return!0}return!1}if("AllOff"===e.policy){for(const t of e.ids){if(!this.#En.has(t))return Aae(`Optional content group not found: ${t}`),!0;if(this.#En.get(t).visible)return!1}return!0}return Aae(`Unknown optional content policy ${e.policy}.`),!0}return Aae(`Unknown group type ${e.type}.`),!0}setVisibility(e,t=!0,n=!0){const r=this.#En.get(e);if(r){if(n&&t&&r.rbGroups.length)for(const t of r.rbGroups)for(const n of t)n!==e&&this.#En.get(n)?._setVisible(kce,!1,!0);r._setVisible(kce,!!t,!0),this.#Mn=null}else Aae(`Optional content group not found: ${e}`)}setOCGState({state:e,preserveRB:t}){let n;for(const r of e){switch(r){case"ON":case"OFF":case"Toggle":n=r;continue}const e=this.#En.get(r);if(e)switch(n){case"ON":this.setVisibility(r,!0,t);break;case"OFF":this.setVisibility(r,!1,t);break;case"Toggle":this.setVisibility(r,!e.visible,t)}}this.#Mn=null}get hasInitialVisibility(){return null===this.#bn||this.getHash()===this.#bn}getOrder(){return this.#En.size?this.#Hn?this.#Hn.slice():[...this.#En.keys()]:null}getGroups(){return this.#En.size>0?Yae(this.#En):null}getGroup(e){return this.#En.get(e)||null}getHash(){if(null!==this.#Mn)return this.#Mn;const e=new Poe;for(const[t,n]of this.#En)e.update(`${t}:${n.visible}`);return this.#Mn=e.hexdigest()}}class Tce{constructor(e,{disableRange:t=!1,disableStream:n=!1}){Nae(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');const{length:r,initialData:a,progressiveDone:o,contentDispositionFilename:c}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=c,a?.length>0){const e=a instanceof Uint8Array&&a.byteLength===a.buffer.byteLength?a.buffer:new Uint8Array(a).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=r,this._fullRequestReader=null,this._rangeReaders=[],e.addRangeListener(((e,t)=>{this._onReceiveData({begin:e,chunk:t})})),e.addProgressListener(((e,t)=>{this._onProgress({loaded:e,total:t})})),e.addProgressiveReadListener((e=>{this._onReceiveData({chunk:e})})),e.addProgressiveDoneListener((()=>{this._onProgressiveDone()})),e.transportReady()}_onReceiveData({begin:e,chunk:t}){const n=t instanceof Uint8Array&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t).buffer;void 0===e?this._fullRequestReader?this._fullRequestReader._enqueue(n):this._queuedChunks.push(n):Nae(this._rangeReaders.some((function(t){return t._begin===e&&(t._enqueue(n),!0)})),"_onReceiveData - no `PDFDataTransportStreamRangeReader` instance found.")}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}_onProgress(e){void 0===e.total?this._rangeReaders[0]?.onProgress?.({loaded:e.loaded}):this._fullRequestReader?.onProgress?.({loaded:e.loaded,total:e.total})}_onProgressiveDone(){this._fullRequestReader?.progressiveDone(),this._progressiveDone=!0}_removeRangeReader(e){const t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){Nae(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");const e=this._queuedChunks;return this._queuedChunks=null,new Oce(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Ace(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeReaders.slice(0))t.cancel(e);this._pdfDataRangeTransport.abort()}}class Oce{constructor(e,t,n=!1,r=null){this._stream=e,this._done=n||!1,this._filename=loe(r)?r:null,this._queuedChunks=t||[],this._loaded=0;for(const e of this._queuedChunks)this._loaded+=e.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){this._done||(this._requests.length>0?this._requests.shift().resolve({value:e,done:!1}):this._queuedChunks.push(e),this._loaded+=e.byteLength)}get headersReady(){return this._headersReady}get filename(){return this._filename}get isRangeSupported(){return this._stream._isRangeSupported}get isStreamingSupported(){return this._stream._isStreamingSupported}get contentLength(){return this._stream._contentLength}async read(){if(this._queuedChunks.length>0)return{value:this._queuedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){this._done||(this._done=!0)}}class Ace{constructor(e,t,n){this._stream=e,this._begin=t,this._end=n,this._queuedChunk=null,this._requests=[],this._done=!1,this.onProgress=null}_enqueue(e){if(!this._done){if(0===this._requests.length)this._queuedChunk=e;else{this._requests.shift().resolve({value:e,done:!1});for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}this._done=!0,this._stream._removeRangeReader(this)}}get isStreamingSupported(){return!1}async read(){if(this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function Rce(e,t){const n=new Headers;if(!e||!t||"object"!=typeof t)return n;for(const e in t){const r=t[e];void 0!==r&&n.append(e,r)}return n}function Nce(e){try{return new URL(e).origin}catch{}return null}function _ce({responseHeaders:e,isHttp:t,rangeChunkSize:n,disableRange:r}){const a={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(e.get("Content-Length"),10);return Number.isInteger(o)?(a.suggestedLength=o,o<=2*n||r||!t||"bytes"!==e.get("Accept-Ranges")||"identity"!==(e.get("Content-Encoding")||"identity")||(a.allowRangeRequests=!0),a):a}function Dce(e){const t=e.get("Content-Disposition");if(t){let e=function(e){let t=!0,n=r("filename\\*","i").exec(e);if(n){n=n[1];let e=c(n);return e=unescape(e),e=i(e),e=l(e),o(e)}if(n=function(e){const t=[];let n;const a=r("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(n=a.exec(e));){let[,e,r,a]=n;if(e=parseInt(e,10),e in t){if(0===e)break}else t[e]=[r,a]}const o=[];for(let e=0;e<t.length&&e in t;++e){let[n,r]=t[e];r=c(r),n&&(r=unescape(r),0===e&&(r=i(r))),o.push(r)}return o.join("")}(e),n)return o(l(n));if(n=r("filename","i").exec(e),n){n=n[1];let e=c(n);return e=l(e),o(e)}function r(e,t){return new RegExp("(?:^|;)\\s*"+e+'\\s*=\\s*([^";\\s][^;\\s]*|"(?:[^"\\\\]|\\\\"?)+"?)',t)}function a(e,n){if(e){if(!/^[\x00-\xFF]+$/.test(n))return n;try{const r=new TextDecoder(e,{fatal:!0}),a=Gae(n);n=r.decode(a),t=!1}catch{}}return n}function o(e){return t&&/[\x80-\xff]/.test(e)&&(e=a("utf-8",e),t&&(e=a("iso-8859-1",e))),e}function c(e){if(e.startsWith('"')){const t=e.slice(1).split('\\"');for(let e=0;e<t.length;++e){const n=t[e].indexOf('"');-1!==n&&(t[e]=t[e].slice(0,n),t.length=e+1),t[e]=t[e].replaceAll(/\\(.)/g,"$1")}e=t.join('"')}return e}function i(e){const t=e.indexOf("'");return-1===t?e:a(e.slice(0,t),e.slice(t+1).replace(/^[^']*'/,""))}function l(e){return!e.startsWith("=?")||/[\x00-\x19\x80-\xff]/.test(e)?e:e.replaceAll(/=\?([\w-]*)\?([QqBb])\?((?:[^?]|\?(?!=))*)\?=/g,(function(e,t,n,r){if("q"===n||"Q"===n)return a(t,r=(r=r.replaceAll("_"," ")).replaceAll(/=([0-9a-fA-F]{2})/g,(function(e,t){return String.fromCharCode(parseInt(t,16))})));try{r=atob(r)}catch{}return a(t,r)}))}return""}(t);if(e.includes("%"))try{e=decodeURIComponent(e)}catch{}if(loe(e))return e}return null}function Pce(e,t){return 404===e||0===e&&t.startsWith("file:")?new jae('Missing PDF "'+t+'".'):new Uae(`Unexpected server response (${e}) while retrieving PDF "${t}".`,e)}function Fce(e){return 200===e||206===e}function Ice(e,t,n){return{method:"GET",headers:e,signal:n.signal,mode:"cors",credentials:t?"include":"same-origin",redirect:"follow"}}function Bce(e){return e instanceof Uint8Array?e.buffer:e instanceof ArrayBuffer?e:(Aae(`getArrayBuffer - unexpected data format: ${e}`),new Uint8Array(e).buffer)}class jce{_responseOrigin=null;constructor(e){this.source=e,this.isHttp=/^https?:/i.test(e.url),this.headers=Rce(this.isHttp,e.httpHeaders),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Nae(!this._fullRequestReader,"PDFFetchStream.getFullReader can only be called once."),this._fullRequestReader=new Uce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Wce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class Uce{constructor(e){this._stream=e,this._reader=null,this._loaded=0,this._filename=null;const t=e.source;this._withCredentials=t.withCredentials||!1,this._contentLength=t.length,this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._abortController=new AbortController,this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange;const n=new Headers(e.headers),r=t.url;fetch(r,Ice(n,this._withCredentials,this._abortController)).then((t=>{if(e._responseOrigin=Nce(t.url),!Fce(t.status))throw Pce(t.status,r);this._reader=t.body.getReader(),this._headersCapability.resolve();const n=t.headers,{allowRangeRequests:a,suggestedLength:o}=_ce({responseHeaders:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=a,this._contentLength=o||this._contentLength,this._filename=Dce(n),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new $ae("Streaming is disabled."))})).catch(this._headersCapability.reject),this.onProgress=null}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._headersCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:Bce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class Wce{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;const r=e.source;this._withCredentials=r.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!r.disableStream,this._abortController=new AbortController;const a=new Headers(e.headers);a.append("Range",`bytes=${t}-${n-1}`);const o=r.url;fetch(o,Ice(a,this._withCredentials,this._abortController)).then((t=>{const n=Nce(t.url);if(n!==e._responseOrigin)throw new Error(`Expected range response-origin "${n}" to match "${e._responseOrigin}".`);if(!Fce(t.status))throw Pce(t.status,o);this._readCapability.resolve(),this._reader=t.body.getReader()})).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;const{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:Bce(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class $ce{_responseOrigin=null;constructor({url:e,httpHeaders:t,withCredentials:n}){this.url=e,this.isHttp=/^https?:/i.test(e),this.headers=Rce(this.isHttp,t),this.withCredentials=n||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}request(e){const t=new XMLHttpRequest,n=this.currXhrId++,r=this.pendingRequests[n]={xhr:t};t.open("GET",this.url),t.withCredentials=this.withCredentials;for(const[e,n]of this.headers)t.setRequestHeader(e,n);return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),r.expectedStatus=206):r.expectedStatus=200,t.responseType="arraybuffer",Nae(e.onError,"Expected `onError` callback to be provided."),t.onerror=()=>{e.onError(t.status)},t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),r.onHeadersReceived=e.onHeadersReceived,r.onDone=e.onDone,r.onError=e.onError,r.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){const n=this.pendingRequests[e];n&&n.onProgress?.(t)}onStateChange(e,t){const n=this.pendingRequests[e];if(!n)return;const r=n.xhr;if(r.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==r.readyState)return;if(!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===r.status&&this.isHttp)return void n.onError(r.status);const a=r.status||200;if((200!==a||206!==n.expectedStatus)&&a!==n.expectedStatus)return void n.onError(r.status);const o=function(e){const t=e.response;return"string"!=typeof t?t:Gae(t).buffer}(r);if(206===a){const e=r.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);t?n.onDone({begin:parseInt(t[1],10),chunk:o}):(Aae('Missing or invalid "Content-Range" header.'),n.onError(0))}else o?n.onDone({begin:0,chunk:o}):n.onError(r.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){const t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class qce{constructor(e){this._source=e,this._manager=new $ce(e),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){const t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return Nae(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new Gce(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){const n=new Yce(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class Gce{constructor(e,t){this._manager=e,this._url=t.url,this._fullRequestId=e.request({onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._headersCapability=Promise.withResolvers(),this._disableRange=t.disableRange||!1,this._contentLength=t.length,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!1,this._isRangeSupported=!1,this._cachedChunks=[],this._requests=[],this._done=!1,this._storedError=void 0,this._filename=null,this.onProgress=null}_onHeadersReceived(){const e=this._fullRequestId,t=this._manager.getRequestXhr(e);this._manager._responseOrigin=Nce(t.responseURL);const n=t.getAllResponseHeaders(),r=new Headers(n?n.trimStart().replace(/[^\S ]+$/,"").split(/[\r\n]+/).map((e=>{const[t,...n]=e.split(": ");return[t,n.join(": ")]})):[]),{allowRangeRequests:a,suggestedLength:o}=_ce({responseHeaders:r,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});a&&(this._isRangeSupported=!0),this._contentLength=o||this._contentLength,this._filename=Dce(r),this._isRangeSupported&&this._manager.abortRequest(e),this._headersCapability.resolve()}_onDone(e){if(e&&(this._requests.length>0?this._requests.shift().resolve({value:e.chunk,done:!1}):this._cachedChunks.push(e.chunk)),this._done=!0,!(this._cachedChunks.length>0)){for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){this._storedError=Pce(e,this._url),this._headersCapability.reject(this._storedError);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._cachedChunks.length=0}_onProgress(e){this.onProgress?.({loaded:e.loaded,total:e.lengthComputable?e.total:this._contentLength})}get filename(){return this._filename}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}get contentLength(){return this._contentLength}get headersReady(){return this._headersCapability.promise}async read(){if(await this._headersCapability.promise,this._storedError)throw this._storedError;if(this._cachedChunks.length>0)return{value:this._cachedChunks.shift(),done:!1};if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0,this._headersCapability.reject(e);for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class Yce{constructor(e,t,n){this._manager=e,this._url=e.url,this._requestId=e.request({begin:t,end:n,onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)}),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_onHeadersReceived(){const e=Nce(this._manager.getRequestXhr(this._requestId)?.responseURL);e!==this._manager._responseOrigin&&(this._storedError=new Error(`Expected range response-origin "${e}" to match "${this._manager._responseOrigin}".`),this._onError(0))}_close(){this.onClosed?.(this)}_onDone(e){const t=e.chunk;this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){this._storedError??=Pce(e,this._url);for(const e of this._requests)e.reject(this._storedError);this._requests.length=0,this._queuedChunk=null}_onProgress(e){this.isStreamingSupported||this.onProgress?.({loaded:e.loaded})}get isStreamingSupported(){return!1}async read(){if(this._storedError)throw this._storedError;if(null!==this._queuedChunk){const e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};const e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){this._done=!0;for(const e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._requestId)&&this._manager.abortRequest(this._requestId),this._close()}}const Kce=/^[a-z][a-z0-9\-+.]+:/i;class Xce{constructor(e){this.source=e,this.url=function(e){if(Kce.test(e))return new URL(e);const t=xt.getBuiltinModule("url");return new URL(t.pathToFileURL(e))}(e.url),Nae("file:"===this.url.protocol,"PDFNodeStream only supports file:// URLs."),this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return Nae(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=new Qce(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;const n=new Jce(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){this._fullRequestReader?.cancel(e);for(const t of this._rangeRequestReaders.slice(0))t.cancel(e)}}class Qce{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;const t=e.source;this._contentLength=t.length,this._loaded=0,this._filename=null,this._disableRange=t.disableRange||!1,this._rangeChunkSize=t.rangeChunkSize,this._rangeChunkSize||this._disableRange||(this._disableRange=!0),this._isStreamingSupported=!t.disableStream,this._isRangeSupported=!t.disableRange,this._readableStream=null,this._readCapability=Promise.withResolvers(),this._headersCapability=Promise.withResolvers();const n=xt.getBuiltinModule("fs");n.promises.lstat(this._url).then((e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(this._url)),this._headersCapability.resolve()}),(e=>{"ENOENT"===e.code&&(e=new jae(`Missing PDF "${this._url}".`)),this._storedError=e,this._headersCapability.reject(e)}))}get headersReady(){return this._headersCapability.promise}get filename(){return this._filename}get contentLength(){return this._contentLength}get isRangeSupported(){return this._isRangeSupported}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded,total:this._contentLength}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),!this._isStreamingSupported&&this._isRangeSupported&&this._error(new $ae("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class Jce{constructor(e,t,n){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();const r=e.source;this._isStreamingSupported=!r.disableStream;const a=xt.getBuiltinModule("fs");this._setReadableStream(a.createReadStream(this._url,{start:t,end:n-1}))}get isStreamingSupported(){return this._isStreamingSupported}async read(){if(await this._readCapability.promise,this._done)return{value:void 0,done:!0};if(this._storedError)throw this._storedError;const e=this._readableStream.read();return null===e?(this._readCapability=Promise.withResolvers(),this.read()):(this._loaded+=e.length,this.onProgress?.({loaded:this._loaded}),{value:new Uint8Array(e).buffer,done:!1})}cancel(e){this._readableStream?this._readableStream.destroy(e):this._error(e)}_error(e){this._storedError=e,this._readCapability.resolve()}_setReadableStream(e){this._readableStream=e,e.on("readable",(()=>{this._readCapability.resolve()})),e.on("end",(()=>{e.destroy(),this._done=!0,this._readCapability.resolve()})),e.on("error",(e=>{this._error(e)})),this._storedError&&this._readableStream.destroy(this._storedError)}}const Zce=30;class eie{#Cn=Promise.withResolvers();#me=null;#Ln=!1;#wn=!!globalThis.FontInspector?.enabled;#kn=null;#xn=null;#Sn=0;#Tn=0;#On=null;#An=null;#Rn=0;#Nn=0;#_n=Object.create(null);#Dn=[];#Pn=null;#Fn=[];#In=new WeakMap;#Bn=null;static#jn=new Map;static#Un=new Map;static#Wn=new WeakMap;static#$n=null;static#qn=new Set;constructor({textContentSource:e,container:t,viewport:n}){if(e instanceof ReadableStream)this.#Pn=e;else{if("object"!=typeof e)throw new Error('No "textContentSource" parameter specified.');this.#Pn=new ReadableStream({start(t){t.enqueue(e),t.close()}})}this.#me=this.#An=t,this.#Nn=n.scale*(globalThis.devicePixelRatio||1),this.#Rn=n.rotation,this.#xn={div:null,properties:null,ctx:null};const{pageWidth:r,pageHeight:a,pageX:o,pageY:c}=n.rawDims;this.#Bn=[1,0,0,-1,-o,c+a],this.#Tn=r,this.#Sn=a,eie.#Gn(),Moe(t,n),this.#Cn.promise.finally((()=>{eie.#qn.delete(this),this.#xn=null,this.#_n=null})).catch((()=>{}))}static get fontFamilyMap(){const{isWindows:e,isFirefox:t}=Kae.platform;return Dae(this,"fontFamilyMap",new Map([["sans-serif",(e&&t?"Calibri, ":"")+"sans-serif"],["monospace",(e&&t?"Lucida Console, ":"")+"monospace"]]))}render(){const e=()=>{this.#On.read().then((({value:t,done:n})=>{n?this.#Cn.resolve():(this.#kn??=t.lang,Object.assign(this.#_n,t.styles),this.#Yn(t.items),e())}),this.#Cn.reject)};return this.#On=this.#Pn.getReader(),eie.#qn.add(this),e(),this.#Cn.promise}update({viewport:e,onBefore:t=null}){const n=e.scale*(globalThis.devicePixelRatio||1),r=e.rotation;if(r!==this.#Rn&&(t?.(),this.#Rn=r,Moe(this.#An,{rotation:r})),n!==this.#Nn){t?.(),this.#Nn=n;const e={div:null,properties:null,ctx:eie.#Kn(this.#kn)};for(const t of this.#Fn)e.properties=this.#In.get(t),e.div=t,this.#Xn(e)}}cancel(){const e=new $ae("TextLayer task cancelled.");this.#On?.cancel(e).catch((()=>{})),this.#On=null,this.#Cn.reject(e)}get textDivs(){return this.#Fn}get textContentItemsStr(){return this.#Dn}#Yn(e){if(this.#Ln)return;this.#xn.ctx??=eie.#Kn(this.#kn);const t=this.#Fn,n=this.#Dn;for(const r of e){if(t.length>1e5)return Aae("Ignoring additional textDivs for performance reasons."),void(this.#Ln=!0);if(void 0!==r.str)n.push(r.str),this.#Qn(r);else if("beginMarkedContentProps"===r.type||"beginMarkedContent"===r.type){const e=this.#me;this.#me=document.createElement("span"),this.#me.classList.add("markedContent"),null!==r.id&&this.#me.setAttribute("id",`${r.id}`),e.append(this.#me)}else"endMarkedContent"===r.type&&(this.#me=this.#me.parentNode)}}#Qn(e){const t=document.createElement("span"),n={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#Fn.push(t);const r=Qae.transform(this.#Bn,e.transform);let a=Math.atan2(r[1],r[0]);const o=this.#_n[e.fontName];o.vertical&&(a+=Math.PI/2);let c=this.#wn&&o.fontSubstitution||o.fontFamily;c=eie.fontFamilyMap.get(c)||c;const i=Math.hypot(r[2],r[3]),l=i*eie.#Jn(c,this.#kn);let s,h;0===a?(s=r[4],h=r[5]-l):(s=r[4]+l*Math.sin(a),h=r[5]-l*Math.cos(a));const d="calc(var(--scale-factor)*",u=t.style;this.#me===this.#An?(u.left=`${(100*s/this.#Tn).toFixed(2)}%`,u.top=`${(100*h/this.#Sn).toFixed(2)}%`):(u.left=`${d}${s.toFixed(2)}px)`,u.top=`${d}${h.toFixed(2)}px)`),u.fontSize=`${d}${(eie.#$n*i).toFixed(2)}px)`,u.fontFamily=c,n.fontSize=i,t.setAttribute("role","presentation"),t.textContent=e.str,t.dir=e.dir,this.#wn&&(t.dataset.fontName=o.fontSubstitutionLoadedName||e.fontName),0!==a&&(n.angle=a*(180/Math.PI));let m=!1;if(e.str.length>1)m=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){const t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(m=!0)}if(m&&(n.canvasWidth=o.vertical?e.height:e.width),this.#In.set(t,n),this.#xn.div=t,this.#xn.properties=n,this.#Xn(this.#xn),n.hasText&&this.#me.append(t),n.hasEOL){const e=document.createElement("br");e.setAttribute("role","presentation"),this.#me.append(e)}}#Xn(e){const{div:t,properties:n,ctx:r}=e,{style:a}=t;let o="";if(eie.#$n>1&&(o=`scale(${1/eie.#$n})`),0!==n.canvasWidth&&n.hasText){const{fontFamily:e}=a,{canvasWidth:c,fontSize:i}=n;eie.#Zn(r,i*this.#Nn,e);const{width:l}=r.measureText(t.textContent);l>0&&(o=`scaleX(${c*this.#Nn/l}) ${o}`)}0!==n.angle&&(o=`rotate(${n.angle}deg) ${o}`),o.length>0&&(a.transform=o)}static cleanup(){if(!(this.#qn.size>0)){this.#jn.clear();for(const{canvas:e}of this.#Un.values())e.remove();this.#Un.clear()}}static#Kn(e=null){let t=this.#Un.get(e||="");if(!t){const n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),t=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#Un.set(e,t),this.#Wn.set(t,{size:0,family:""})}return t}static#Zn(e,t,n){const r=this.#Wn.get(e);t===r.size&&n===r.family||(e.font=`${t}px ${n}`,r.size=t,r.family=n)}static#Gn(){if(null!==this.#$n)return;const e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.style.position="absolute",e.textContent="X",document.body.append(e),this.#$n=e.getBoundingClientRect().height,e.remove()}static#Jn(e,t){const n=this.#jn.get(e);if(n)return n;const r=this.#Kn(t);r.canvas.width=r.canvas.height=Zce,this.#Zn(r,Zce,e);const a=r.measureText("");let o=a.fontBoundingBoxAscent,c=Math.abs(a.fontBoundingBoxDescent);if(o){const t=o/(o+c);return this.#jn.set(e,t),r.canvas.width=r.canvas.height=0,t}r.strokeStyle="red",r.clearRect(0,0,Zce,Zce),r.strokeText("g",0,0);let i=r.getImageData(0,0,Zce,Zce).data;c=0;for(let e=i.length-1-3;e>=0;e-=4)if(i[e]>0){c=Math.ceil(e/4/Zce);break}r.clearRect(0,0,Zce,Zce),r.strokeText("A",0,Zce),i=r.getImageData(0,0,Zce,Zce).data,o=0;for(let e=0,t=i.length;e<t;e+=4)if(i[e]>0){o=Zce-Math.floor(e/4/Zce);break}r.canvas.width=r.canvas.height=0;const l=o?o/(o+c):.8;return this.#jn.set(e,l),l}}class tie{static textContent(e){const t=[],n={items:t,styles:Object.create(null)};return function e(n){if(!n)return;let r=null;const a=n.name;if("#text"===a)r=n.value;else{if(!tie.shouldBuildText(a))return;n?.attributes?.textContent?r=n.attributes.textContent:n.value&&(r=n.value)}if(null!==r&&t.push({str:r}),n.children)for(const t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}const nie=65536,rie=gae?class extends Goe{_createCanvas(e,t){return xt.getBuiltinModule("module").createRequire(import.meta.url)("@napi-rs/canvas").createCanvas(e,t)}}:class extends Goe{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){const n=this._document.createElement("canvas");return n.width=e,n.height=t,n}},aie=gae?class extends Yoe{async _fetch(e){return Zoe(e)}}:Koe,oie=gae?class extends Xoe{}:class extends Xoe{#er;#tr;#nr;#rr;#ar;#or;#y=0;constructor({docId:e,ownerDocument:t=globalThis.document}){super(),this.#rr=e,this.#ar=t}get#E(){return this.#tr||=new Map}get#cr(){return this.#or||=new Map}get#ir(){if(!this.#nr){const e=this.#ar.createElement("div"),{style:t}=e;t.visibility="hidden",t.contain="strict",t.width=t.height=0,t.position="absolute",t.top=t.left=0,t.zIndex=-1;const n=this.#ar.createElementNS(noe,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#nr=this.#ar.createElementNS(noe,"defs"),e.append(n),n.append(this.#nr),this.#ar.body.append(e)}return this.#nr}#lr(e){if(1===e.length){const t=e[0],n=new Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;const r=n.join(",");return[r,r,r]}const[t,n,r]=e,a=new Array(256),o=new Array(256),c=new Array(256);for(let e=0;e<256;e++)a[e]=t[e]/255,o[e]=n[e]/255,c[e]=r[e]/255;return[a.join(","),o.join(","),c.join(",")]}#sr(e){if(void 0===this.#er){this.#er="";const e=this.#ar.URL;e!==this.#ar.baseURI&&(ioe(e)?Aae('#createUrl: ignore "data:"-URL for performance reasons.'):this.#er=e.split("#",1)[0])}return`url(${this.#er}#${e})`}addFilter(e){if(!e)return"none";let t=this.#E.get(e);if(t)return t;const[n,r,a]=this.#lr(e),o=1===e.length?n:`${n}${r}${a}`;if(t=this.#E.get(o),t)return this.#E.set(e,t),t;const c=`g_${this.#rr}_transfer_map_${this.#y++}`,i=this.#sr(c);this.#E.set(e,i),this.#E.set(o,i);const l=this.#hr(c);return this.#dr(n,r,a,l),i}addHCMFilter(e,t){const n=`${e}-${t}`,r="base";let a=this.#cr.get(r);if(a?.key===n)return a.url;if(a?(a.filter?.remove(),a.key=n,a.url="none",a.filter=null):(a={key:n,url:"none",filter:null},this.#cr.set(r,a)),!e||!t)return a.url;const o=this.#ur(e);e=Qae.makeHexColor(...o);const c=this.#ur(t);if(t=Qae.makeHexColor(...c),this.#ir.style.color="","#000000"===e&&"#ffffff"===t||e===t)return a.url;const i=new Array(256);for(let e=0;e<=255;e++){const t=e/255;i[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}const l=i.join(","),s=`g_${this.#rr}_hcm_filter`,h=a.filter=this.#hr(s);this.#dr(l,l,l,h),this.#mr(h);const d=(e,t)=>{const n=o[e]/255,r=c[e]/255,a=new Array(t+1);for(let e=0;e<=t;e++)a[e]=n+e/t*(r-n);return a.join(",")};return this.#dr(d(0,5),d(1,5),d(2,5),h),a.url=this.#sr(s),a.url}addAlphaFilter(e){let t=this.#E.get(e);if(t)return t;const[n]=this.#lr([e]),r=`alpha_${n}`;if(t=this.#E.get(r),t)return this.#E.set(e,t),t;const a=`g_${this.#rr}_alpha_map_${this.#y++}`,o=this.#sr(a);this.#E.set(e,o),this.#E.set(r,o);const c=this.#hr(a);return this.#pr(n,c),o}addLuminosityFilter(e){let t,n,r=this.#E.get(e||"luminosity");if(r)return r;if(e?([t]=this.#lr([e]),n=`luminosity_${t}`):n="luminosity",r=this.#E.get(n),r)return this.#E.set(e,r),r;const a=`g_${this.#rr}_luminosity_map_${this.#y++}`,o=this.#sr(a);this.#E.set(e,o),this.#E.set(n,o);const c=this.#hr(a);return this.#vr(c),e&&this.#pr(t,c),o}addHighlightHCMFilter(e,t,n,r,a){const o=`${t}-${n}-${r}-${a}`;let c=this.#cr.get(e);if(c?.key===o)return c.url;if(c?(c.filter?.remove(),c.key=o,c.url="none",c.filter=null):(c={key:o,url:"none",filter:null},this.#cr.set(e,c)),!t||!n)return c.url;const[i,l]=[t,n].map(this.#ur.bind(this));let s=Math.round(.2126*i[0]+.7152*i[1]+.0722*i[2]),h=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[d,u]=[r,a].map(this.#ur.bind(this));h<s&&([s,h,d,u]=[h,s,u,d]),this.#ir.style.color="";const m=(e,t,n)=>{const r=new Array(256),a=(h-s)/n,o=e/255,c=(t-e)/(255*n);let i=0;for(let e=0;e<=n;e++){const t=Math.round(s+e*a),n=o+e*c;for(let e=i;e<=t;e++)r[e]=n;i=t+1}for(let e=i;e<256;e++)r[e]=r[i-1];return r.join(",")},p=`g_${this.#rr}_hcm_${e}_filter`,v=c.filter=this.#hr(p);return this.#mr(v),this.#dr(m(d[0],u[0],5),m(d[1],u[1],5),m(d[2],u[2],5),v),c.url=this.#sr(p),c.url}destroy(e=!1){e&&this.#or?.size||(this.#nr?.parentNode.parentNode.remove(),this.#nr=null,this.#tr?.clear(),this.#tr=null,this.#or?.clear(),this.#or=null,this.#y=0)}#vr(e){const t=this.#ar.createElementNS(noe,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.3 0.59 0.11 0 0"),e.append(t)}#mr(e){const t=this.#ar.createElementNS(noe,"feColorMatrix");t.setAttribute("type","matrix"),t.setAttribute("values","0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0.2126 0.7152 0.0722 0 0 0 0 0 1 0"),e.append(t)}#hr(e){const t=this.#ar.createElementNS(noe,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#ir.append(t),t}#fr(e,t,n){const r=this.#ar.createElementNS(noe,t);r.setAttribute("type","discrete"),r.setAttribute("tableValues",n),e.append(r)}#dr(e,t,n,r){const a=this.#ar.createElementNS(noe,"feComponentTransfer");r.append(a),this.#fr(a,"feFuncR",e),this.#fr(a,"feFuncG",t),this.#fr(a,"feFuncB",n)}#pr(e,t){const n=this.#ar.createElementNS(noe,"feComponentTransfer");t.append(n),this.#fr(n,"feFuncA",e)}#ur(e){return this.#ir.style.color=e,zoe(getComputedStyle(this.#ir).getPropertyValue("color"))}},cie=gae?class extends Qoe{async _fetch(e){return Zoe(e)}}:Joe;function iie(e={}){"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t=new sie,{docId:n}=t,r=e.url?function(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(gae&&"string"==typeof e)return e}throw new Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,a=e.data?function(e){if(gae&&void 0!==wL&&e instanceof wL)throw new Error("Please provide binary data as `Uint8Array`, rather than `Buffer`.");if(e instanceof Uint8Array&&e.byteLength===e.buffer.byteLength)return e;if("string"==typeof e)return Gae(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw new Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,o=e.httpHeaders||null,c=!0===e.withCredentials,i=e.password??null,l=e.range instanceof hie?e.range:null,s=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:nie;let h=e.worker instanceof pie?e.worker:null;const d=e.verbosity,u="string"!=typeof e.docBaseUrl||ioe(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,p=!1!==e.cMapPacked,v=e.CMapReaderFactory||aie,f="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,z=e.StandardFontDataFactory||cie,g=!0!==e.stopAtErrors,y=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,M=!1!==e.isEvalSupported,E="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!gae,b="boolean"==typeof e.isImageDecoderSupported?e.isImageDecoderSupported:!gae&&(Kae.platform.isFirefox||!globalThis.chrome),H=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,V="boolean"==typeof e.disableFontFace?e.disableFontFace:gae,C=!0===e.fontExtraProperties,L=!0===e.enableXfa,w=e.ownerDocument||globalThis.document,k=!0===e.disableRange,x=!0===e.disableStream,S=!0===e.disableAutoFetch,T=!0===e.pdfBug,O=e.CanvasFactory||rie,A=e.FilterFactory||oie,R=!0===e.enableHWA,N=l?l.length:e.length??NaN,_="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!gae&&!V,D="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===Koe&&z===Joe&&m&&f&&uoe(m,document.baseURI)&&uoe(f,document.baseURI);!function(e){Number.isInteger(e)&&(Sae=e)}(d);const P={canvasFactory:new O({ownerDocument:w,enableHWA:R}),filterFactory:new A({docId:n,ownerDocument:w}),cMapReaderFactory:D?null:new v({baseUrl:m,isCompressed:p}),standardFontDataFactory:D?null:new z({baseUrl:f})};if(!h){const e={verbosity:d,port:Lce.workerPort};h=e.port?pie.fromPort(e):new pie(e),t._worker=h}const F={docId:n,apiVersion:"4.10.38",data:a,password:i,disableAutoFetch:S,rangeChunkSize:s,length:N,docBaseUrl:u,enableXfa:L,evaluatorOptions:{maxImageSize:y,disableFontFace:V,ignoreErrors:g,isEvalSupported:M,isOffscreenCanvasSupported:E,isImageDecoderSupported:b,canvasMaxAreaInBytes:H,fontExtraProperties:C,useSystemFonts:_,cMapUrl:D?m:null,standardFontDataUrl:D?f:null}},I={disableFontFace:V,fontExtraProperties:C,ownerDocument:w,pdfBug:T,styleElement:null,loadingParams:{disableAutoFetch:S,enableXfa:L}};return h.promise.then((function(){if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const e=h.messageHandler.sendWithPromise("GetDocRequest",F,a?[a.buffer]:null);let i;if(l)i=new Tce(l,{disableRange:k,disableStream:x});else if(!a){if(!r)throw new Error("getDocument - no `url` parameter provided.");let e;if(gae)if(uoe(r)){if("undefined"==typeof fetch||"undefined"==typeof Response||!("body"in Response.prototype))throw new Error("getDocument - the Fetch API was disabled in Node.js, see `--no-experimental-fetch`.");e=jce}else e=Xce;else e=uoe(r)?jce:qce;i=new e({url:r,length:N,httpHeaders:o,withCredentials:c,rangeChunkSize:s,disableRange:k,disableStream:x})}return e.then((e=>{if(t.destroyed)throw new Error("Loading aborted");if(h.destroyed)throw new Error("Worker was destroyed");const r=new qoe(n,e,h.port),a=new vie(r,t,i,I,P);t._transport=a,r.send("Ready",null)}))})).catch(t._capability.reject),t}function lie(e){return"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}class sie{static#rr=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId="d"+sie.#rr++,this.destroyed=!1,this.onPassword=null,this.onProgress=null}get promise(){return this._capability.promise}async destroy(){this.destroyed=!0;try{this._worker?.port&&(this._worker._pendingDestroy=!0),await(this._transport?.destroy())}catch(e){throw this._worker?.port&&delete this._worker._pendingDestroy,e}this._transport=null,this._worker?.destroy(),this._worker=null}}class hie{constructor(e,t,n=!1,r=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=r,this._rangeListeners=[],this._progressListeners=[],this._progressiveReadListeners=[],this._progressiveDoneListeners=[],this._readyCapability=Promise.withResolvers()}addRangeListener(e){this._rangeListeners.push(e)}addProgressListener(e){this._progressListeners.push(e)}addProgressiveReadListener(e){this._progressiveReadListeners.push(e)}addProgressiveDoneListener(e){this._progressiveDoneListeners.push(e)}onDataRange(e,t){for(const n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then((()=>{for(const n of this._progressListeners)n(e,t)}))}onDataProgressiveRead(e){this._readyCapability.promise.then((()=>{for(const t of this._progressiveReadListeners)t(e)}))}onDataProgressiveDone(){this._readyCapability.promise.then((()=>{for(const e of this._progressiveDoneListeners)e()}))}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){Rae("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class die{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get canvasFactory(){return this._transport.canvasFactory}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return Dae(this,"isPureXfa",!!this._transport._htmlForXfa)}get allXfaHtml(){return this._transport._htmlForXfa}getPage(e){return this._transport.getPage(e)}getPageIndex(e){return this._transport.getPageIndex(e)}getDestinations(){return this._transport.getDestinations()}getDestination(e){return this._transport.getDestination(e)}getPageLabels(){return this._transport.getPageLabels()}getPageLayout(){return this._transport.getPageLayout()}getPageMode(){return this._transport.getPageMode()}getViewerPreferences(){return this._transport.getViewerPreferences()}getOpenAction(){return this._transport.getOpenAction()}getAttachments(){return this._transport.getAttachments()}getJSActions(){return this._transport.getDocJSActions()}getOutline(){return this._transport.getOutline()}getOptionalContentConfig({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getOptionalContentConfig(t)}getPermissions(){return this._transport.getPermissions()}getMetadata(){return this._transport.getMetadata()}getMarkInfo(){return this._transport.getMarkInfo()}getData(){return this._transport.getData()}saveDocument(){return this._transport.saveDocument()}getDownloadInfo(){return this._transport.downloadInfoCapability.promise}cleanup(e=!1){return this._transport.startCleanup(e||this.isPureXfa)}destroy(){return this.loadingTask.destroy()}cachedPageNumber(e){return this._transport.cachedPageNumber(e)}get loadingParams(){return this._transport.loadingParams}get loadingTask(){return this._transport.loadingTask}getFieldObjects(){return this._transport.getFieldObjects()}hasJSActions(){return this._transport.hasJSActions()}getCalculationOrderIds(){return this._transport.getCalculationOrderIds()}}class uie{#zr=null;#gr=!1;constructor(e,t,n,r=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=r?new doe:null,this._pdfBug=r,this.commonObjs=n.commonObjs,this.objs=new zie,this._maybeCleanupAfterRender=!1,this._intentStates=new Map,this.destroyed=!1}get pageNumber(){return this._pageIndex+1}get rotate(){return this._pageInfo.rotate}get ref(){return this._pageInfo.ref}get userUnit(){return this._pageInfo.userUnit}get view(){return this._pageInfo.view}getViewport({scale:e,rotation:t=this.rotate,offsetX:n=0,offsetY:r=0,dontFlip:a=!1}={}){return new ooe({viewBox:this.view,userUnit:this.userUnit,scale:e,rotation:t,offsetX:n,offsetY:r,dontFlip:a})}getAnnotations({intent:e="display"}={}){const{renderingIntent:t}=this._transport.getRenderingIntent(e);return this._transport.getAnnotations(this._pageIndex,t)}getJSActions(){return this._transport.getPageJSActions(this._pageIndex)}get filterFactory(){return this._transport.filterFactory}get isPureXfa(){return Dae(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:r=bae.ENABLE,transform:a=null,background:o=null,optionalContentConfigPromise:c=null,annotationCanvasMap:i=null,pageColors:l=null,printAnnotationStorage:s=null,isEditing:h=!1}){this._stats?.time("Overall");const d=this._transport.getRenderingIntent(n,r,s,h),{renderingIntent:u,cacheKey:m}=d;this.#gr=!1,this.#yr(),c||=this._transport.getOptionalContentConfig(u);let p=this._intentStates.get(m);p||(p=Object.create(null),this._intentStates.set(m,p)),p.streamReaderCancelTimeout&&(clearTimeout(p.streamReaderCancelTimeout),p.streamReaderCancelTimeout=null);const v=!!(4&u);p.displayReadyCapability||(p.displayReadyCapability=Promise.withResolvers(),p.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(d));const f=e=>{p.renderTasks.delete(z),(this._maybeCleanupAfterRender||v)&&(this.#gr=!0),this.#Mr(!v),e?(z.capability.reject(e),this._abortOperatorList({intentState:p,reason:e instanceof Error?e:new Error(e)})):z.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},z=new yie({callback:f,params:{canvasContext:e,viewport:t,transform:a,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:i,operatorList:p.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!v,pdfBug:this._pdfBug,pageColors:l});(p.renderTasks||=new Set).add(z);const g=z.task;return Promise.all([p.displayReadyCapability.promise,c]).then((([e,t])=>{if(this.destroyed)f();else{if(this._stats?.time("Rendering"),!(t.renderingIntent&u))throw new Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");z.initializeGraphics({transparency:e,optionalContentConfig:t}),z.operatorListChanged()}})).catch(f),g}getOperatorList({intent:e="display",annotationMode:t=bae.ENABLE,printAnnotationStorage:n=null,isEditing:r=!1}={}){const a=this._transport.getRenderingIntent(e,t,n,r,!0);let o,c=this._intentStates.get(a.cacheKey);return c||(c=Object.create(null),this._intentStates.set(a.cacheKey,c)),c.opListReadCapability||(o=Object.create(null),o.operatorListChanged=function(){c.operatorList.lastChunk&&(c.opListReadCapability.resolve(c.operatorList),c.renderTasks.delete(o))},c.opListReadCapability=Promise.withResolvers(),(c.renderTasks||=new Set).add(o),c.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(a)),c.opListReadCapability.promise}streamTextContent({includeMarkedContent:e=!1,disableNormalization:t=!1}={}){return this._transport.messageHandler.sendWithStream("GetTextContent",{pageIndex:this._pageIndex,includeMarkedContent:!0===e,disableNormalization:!0===t},{highWaterMark:100,size:e=>e.items.length})}getTextContent(e={}){if(this._transport._htmlForXfa)return this.getXfa().then((e=>tie.textContent(e)));const t=this.streamTextContent(e);return new Promise((function(e,n){const r=t.getReader(),a={items:[],styles:Object.create(null),lang:null};!function t(){r.read().then((function({value:n,done:r}){r?e(a):(a.lang??=n.lang,Object.assign(a.styles,n.styles),a.items.push(...n.items),t())}),n)}()}))}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;const e=[];for(const t of this._intentStates.values())if(this._abortOperatorList({intentState:t,reason:new Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(const n of t.renderTasks)e.push(n.completed),n.cancel();return this.objs.clear(),this.#gr=!1,this.#yr(),Promise.all(e)}cleanup(e=!1){this.#gr=!0;const t=this.#Mr(!1);return e&&t&&(this._stats&&=new doe),t}#Mr(e=!1){if(this.#yr(),!this.#gr||this.destroyed)return!1;if(e)return this.#zr=setTimeout((()=>{this.#zr=null,this.#Mr(!1)}),5e3),!1;for(const{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#gr=!1,!0}#yr(){this.#zr&&(clearTimeout(this.#zr),this.#zr=null)}_startRenderPage(e,t){const n=this._intentStates.get(t);n&&(this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(e))}_renderPageChunk(e,t){for(let n=0,r=e.length;n<r;n++)t.operatorList.fnArray.push(e.fnArray[n]),t.operatorList.argsArray.push(e.argsArray[n]);t.operatorList.lastChunk=e.lastChunk,t.operatorList.separateAnnots=e.separateAnnots;for(const e of t.renderTasks)e.operatorListChanged();e.lastChunk&&this.#Mr(!0)}_pumpOperatorList({renderingIntent:e,cacheKey:t,annotationStorageSerializable:n,modifiedIds:r}){const{map:a,transfer:o}=n,c=this._transport.messageHandler.sendWithStream("GetOperatorList",{pageIndex:this._pageIndex,intent:e,cacheKey:t,annotationStorage:a,modifiedIds:r},o).getReader(),i=this._intentStates.get(t);i.streamReader=c;const l=()=>{c.read().then((({value:e,done:t})=>{t?i.streamReader=null:this._transport.destroyed||(this._renderPageChunk(e,i),l())}),(e=>{if(i.streamReader=null,!this._transport.destroyed){if(i.operatorList){i.operatorList.lastChunk=!0;for(const e of i.renderTasks)e.operatorListChanged();this.#Mr(!0)}if(i.displayReadyCapability)i.displayReadyCapability.reject(e);else{if(!i.opListReadCapability)throw e;i.opListReadCapability.reject(e)}}}))};l()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(e.streamReader){if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof coe){let n=100;return t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),void(e.streamReaderCancelTimeout=setTimeout((()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})}),n))}}if(e.streamReader.cancel(new $ae(t.message)).catch((()=>{})),e.streamReader=null,!this._transport.destroyed){for(const[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}}get stats(){return this._stats}}class mie{#Er=new Map;#br=Promise.resolve();postMessage(e,t){const n={data:structuredClone(e,t?{transfer:t}:null)};this.#br.then((()=>{for(const[e]of this.#Er)e.call(this,n)}))}addEventListener(e,t,n=null){let r=null;if(n?.signal instanceof AbortSignal){const{signal:a}=n;if(a.aborted)return void Aae("LoopbackPort - cannot use an `aborted` signal.");const o=()=>this.removeEventListener(e,t);r=()=>a.removeEventListener("abort",o),a.addEventListener("abort",o)}this.#Er.set(t,r)}removeEventListener(e,t){const n=this.#Er.get(t);n?.(),this.#Er.delete(t)}terminate(){for(const[,e]of this.#Er)e?.();this.#Er.clear()}}class pie{static#Hr=0;static#Vr=!1;static#Cr;static{gae&&(this.#Vr=!0,Lce.workerSrc||="./pdf.worker.mjs"),this._isSameOrigin=(e,t)=>{let n;try{if(n=new URL(e),!n.origin||"null"===n.origin)return!1}catch{return!1}const r=new URL(t,n);return n.origin===r.origin},this._createCDNWrapper=e=>{const t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))}}constructor({name:e=null,port:t=null,verbosity:n=Tae()}={}){if(this.name=e,this.destroyed=!1,this.verbosity=n,this._readyCapability=Promise.withResolvers(),this._port=null,this._webWorker=null,this._messageHandler=null,t){if(pie.#Cr?.has(t))throw new Error("Cannot use more than one PDFWorker per port.");return(pie.#Cr||=new WeakMap).set(t,this),void this._initializeFromPort(t)}this._initialize()}get promise(){return this._readyCapability.promise}#Lr(){this._readyCapability.resolve(),this._messageHandler.send("configure",{verbosity:this.verbosity})}get port(){return this._port}get messageHandler(){return this._messageHandler}_initializeFromPort(e){this._port=e,this._messageHandler=new qoe("main","worker",e),this._messageHandler.on("ready",(function(){})),this.#Lr()}_initialize(){if(pie.#Vr||pie.#wr)return void this._setupFakeWorker();let{workerSrc:e}=pie;try{pie._isSameOrigin(window.location.href,e)||(e=pie._createCDNWrapper(new URL(e,window.location).href));const t=new Worker(e,{type:"module"}),n=new qoe("main","worker",t),r=()=>{a.abort(),n.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(new Error("Worker was destroyed")):this._setupFakeWorker()},a=new AbortController;t.addEventListener("error",(()=>{this._webWorker||r()}),{signal:a.signal}),n.on("test",(e=>{a.abort(),!this.destroyed&&e?(this._messageHandler=n,this._port=t,this._webWorker=t,this.#Lr()):r()})),n.on("ready",(e=>{if(a.abort(),this.destroyed)r();else try{o()}catch{this._setupFakeWorker()}}));const o=()=>{const e=new Uint8Array;n.send("test",e,[e.buffer])};return void o()}catch{Oae("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){pie.#Vr||(Aae("Setting up fake worker."),pie.#Vr=!0),pie._setupFakeWorkerGlobal.then((e=>{if(this.destroyed)return void this._readyCapability.reject(new Error("Worker was destroyed"));const t=new mie;this._port=t;const n="fake"+pie.#Hr++,r=new qoe(n+"_worker",n,t);e.setup(r,t),this._messageHandler=new qoe(n,n+"_worker",t),this.#Lr()})).catch((e=>{this._readyCapability.reject(new Error(`Setting up fake worker failed: "${e.message}".`))}))}destroy(){this.destroyed=!0,this._webWorker?.terminate(),this._webWorker=null,pie.#Cr?.delete(this._port),this._port=null,this._messageHandler?.destroy(),this._messageHandler=null}static fromPort(e){if(!e?.port)throw new Error("PDFWorker.fromPort - invalid method signature.");const t=this.#Cr?.get(e.port);if(t){if(t._pendingDestroy)throw new Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new pie(e)}static get workerSrc(){if(Lce.workerSrc)return Lce.workerSrc;throw new Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get#wr(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return Dae(this,"_setupFakeWorkerGlobal",(async()=>this.#wr?this.#wr:(await import(this.workerSrc)).WorkerMessageHandler)())}}class vie{#kr=new Map;#xr=new Map;#Sr=new Map;#Tr=new Map;#Or=null;constructor(e,t,n,r,a){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new zie,this.fontLoader=new joe({ownerDocument:r.ownerDocument,styleElement:r.styleElement}),this.loadingParams=r.loadingParams,this._params=r,this.canvasFactory=a.canvasFactory,this.filterFactory=a.filterFactory,this.cMapReaderFactory=a.cMapReaderFactory,this.standardFontDataFactory=a.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#Ar(e,t=null){const n=this.#kr.get(e);if(n)return n;const r=this.messageHandler.sendWithPromise(e,t);return this.#kr.set(e,r),r}get annotationStorage(){return Dae(this,"annotationStorage",new Ioe)}getRenderingIntent(e,t=bae.ENABLE,n=null,r=!1,a=!1){let o=2,c=Foe;switch(e){case"any":o=1;break;case"display":break;case"print":o=4;break;default:Aae(`getRenderingIntent - invalid intent: ${e}`)}const i=4&o&&n instanceof Boe?n:this.annotationStorage;switch(t){case bae.DISABLE:o+=64;break;case bae.ENABLE:break;case bae.ENABLE_FORMS:o+=16;break;case bae.ENABLE_STORAGE:o+=32,c=i.serializable;break;default:Aae(`getRenderingIntent - invalid annotationMode: ${t}`)}r&&(o+=128),a&&(o+=256);const{ids:l,hash:s}=i.modifiedIds;return{renderingIntent:o,cacheKey:[o,c.hash,s].join("_"),annotationStorageSerializable:c,modifiedIds:l}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#Or?.reject(new Error("Worker was destroyed during onPassword callback"));const e=[];for(const t of this.#xr.values())e.push(t._destroy());this.#xr.clear(),this.#Sr.clear(),this.#Tr.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();const t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then((()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#kr.clear(),this.filterFactory.destroy(),eie.cleanup(),this._networkStream?.cancelAllRequests(new $ae("Worker was terminated.")),this.messageHandler?.destroy(),this.messageHandler=null,this.destroyCapability.resolve()}),this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){const{messageHandler:e,loadingTask:t}=this;e.on("GetReader",((e,t)=>{Nae(this._networkStream,"GetReader - no `IPDFStream` instance available."),this._fullReader=this._networkStream.getFullReader(),this._fullReader.onProgress=e=>{this._lastProgress={loaded:e.loaded,total:e.total}},t.onPull=()=>{this._fullReader.read().then((function({value:e,done:n}){n?t.close():(Nae(e instanceof ArrayBuffer,"GetReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{this._fullReader.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}})),e.on("ReaderHeadersReady",(async e=>{await this._fullReader.headersReady;const{isStreamingSupported:n,isRangeSupported:r,contentLength:a}=this._fullReader;return n&&r||(this._lastProgress&&t.onProgress?.(this._lastProgress),this._fullReader.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),{isStreamingSupported:n,isRangeSupported:r,contentLength:a}})),e.on("GetRangeReader",((e,t)=>{Nae(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");const n=this._networkStream.getRangeReader(e.begin,e.end);n?(t.onPull=()=>{n.read().then((function({value:e,done:n}){n?t.close():(Nae(e instanceof ArrayBuffer,"GetRangeReader - expected an ArrayBuffer."),t.enqueue(new Uint8Array(e),1,[e]))})).catch((e=>{t.error(e)}))},t.onCancel=e=>{n.cancel(e),t.ready.catch((e=>{if(!this.destroyed)throw e}))}):t.close()})),e.on("GetDoc",(({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new die(e,this))})),e.on("DocException",(e=>{t._capability.reject($oe(e))})),e.on("PasswordRequest",(e=>{this.#Or=Promise.withResolvers();try{if(!t.onPassword)throw $oe(e);const n=e=>{e instanceof Error?this.#Or.reject(e):this.#Or.resolve({password:e})};t.onPassword(n,e.code)}catch(e){this.#Or.reject(e)}return this.#Or.promise})),e.on("DataLoaded",(e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)})),e.on("StartRenderPage",(e=>{this.destroyed||this.#xr.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)})),e.on("commonobj",(([t,n,r])=>{if(this.destroyed)return null;if(this.commonObjs.has(t))return null;switch(n){case"Font":const{disableFontFace:a,fontExtraProperties:o,pdfBug:c}=this._params;if("error"in r){const e=r.error;Aae(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}const i=c&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null,l=new Uoe(r,{disableFontFace:a,fontExtraProperties:o,inspectFont:i});this.fontLoader.bind(l).catch((()=>e.sendWithPromise("FontFallback",{id:t}))).finally((()=>{!o&&l.data&&(l.data=null),this.commonObjs.resolve(t,l)}));break;case"CopyLocalImage":const{imageRef:s}=r;Nae(s,"The imageRef must be defined.");for(const e of this.#xr.values())for(const[,n]of e.objs)if(n?.ref===s)return n.dataLen?(this.commonObjs.resolve(t,structuredClone(n)),n.dataLen):null;break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,r);break;default:throw new Error(`Got unknown common object type ${n}`)}return null})),e.on("obj",(([e,t,n,r])=>{if(this.destroyed)return;const a=this.#xr.get(t);if(!a.objs.has(e))if(0!==a._intentStates.size)switch(n){case"Image":a.objs.resolve(e,r),r?.dataLen>1e7&&(a._maybeCleanupAfterRender=!0);break;case"Pattern":a.objs.resolve(e,r);break;default:throw new Error(`Got unknown object type ${n}`)}else r?.bitmap?.close()})),e.on("DocProgress",(e=>{this.destroyed||t.onProgress?.({loaded:e.loaded,total:e.total})})),e.on("FetchBuiltInCMap",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.cMapReaderFactory)throw new Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter.");return this.cMapReaderFactory.fetch(e)})),e.on("FetchStandardFontData",(async e=>{if(this.destroyed)throw new Error("Worker was destroyed.");if(!this.standardFontDataFactory)throw new Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.");return this.standardFontDataFactory.fetch(e)}))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&Aae("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");const{map:e,transfer:t}=this.annotationStorage.serializable;return this.messageHandler.sendWithPromise("SaveDocument",{isPureXfa:!!this._htmlForXfa,numPages:this._numPages,annotationStorage:e,filename:this._fullReader?.filename??null},t).finally((()=>{this.annotationStorage.resetModified()}))}getPage(e){if(!Number.isInteger(e)||e<=0||e>this._numPages)return Promise.reject(new Error("Invalid page request."));const t=e-1,n=this.#Sr.get(t);if(n)return n;const r=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then((n=>{if(this.destroyed)throw new Error("Transport destroyed");n.refStr&&this.#Tr.set(n.refStr,e);const r=new uie(t,n,this,this._params.pdfBug);return this.#xr.set(t,r),r}));return this.#Sr.set(t,r),r}getPageIndex(e){return lie(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(new Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#Ar("GetFieldObjects")}hasJSActions(){return this.#Ar("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(new Error("Invalid destination request.")):this.messageHandler.sendWithPromise("GetDestination",{id:e})}getPageLabels(){return this.messageHandler.sendWithPromise("GetPageLabels",null)}getPageLayout(){return this.messageHandler.sendWithPromise("GetPageLayout",null)}getPageMode(){return this.messageHandler.sendWithPromise("GetPageMode",null)}getViewerPreferences(){return this.messageHandler.sendWithPromise("GetViewerPreferences",null)}getOpenAction(){return this.messageHandler.sendWithPromise("GetOpenAction",null)}getAttachments(){return this.messageHandler.sendWithPromise("GetAttachments",null)}getDocJSActions(){return this.#Ar("GetDocJSActions")}getPageJSActions(e){return this.messageHandler.sendWithPromise("GetPageJSActions",{pageIndex:e})}getStructTree(e){return this.messageHandler.sendWithPromise("GetStructTree",{pageIndex:e})}getOutline(){return this.messageHandler.sendWithPromise("GetOutline",null)}getOptionalContentConfig(e){return this.#Ar("GetOptionalContentConfig").then((t=>new Sce(t,e)))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){const e="GetMetadata",t=this.#kr.get(e);if(t)return t;const n=this.messageHandler.sendWithPromise(e,null).then((e=>({info:e[0],metadata:e[1]?new wce(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null})));return this.#kr.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){await this.messageHandler.sendWithPromise("Cleanup",null);for(const e of this.#xr.values())if(!e.cleanup())throw new Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),e||this.fontLoader.clear(),this.#kr.clear(),this.filterFactory.destroy(!0),eie.cleanup()}}cachedPageNumber(e){if(!lie(e))return null;const t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#Tr.get(t)??null}}const fie=Symbol("INITIAL_DATA");class zie{#Rr=Object.create(null);#Nr(e){return this.#Rr[e]||={...Promise.withResolvers(),data:fie}}get(e,t=null){if(t){const n=this.#Nr(e);return n.promise.then((()=>t(n.data))),null}const n=this.#Rr[e];if(!n||n.data===fie)throw new Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){const t=this.#Rr[e];return!!t&&t.data!==fie}delete(e){const t=this.#Rr[e];return!(!t||t.data===fie||(delete this.#Rr[e],0))}resolve(e,t=null){const n=this.#Nr(e);n.data=t,n.resolve()}clear(){for(const e in this.#Rr){const{data:t}=this.#Rr[e];t?.bitmap?.close()}this.#Rr=Object.create(null)}*[Symbol.iterator](){for(const e in this.#Rr){const{data:t}=this.#Rr[e];t!==fie&&(yield[e,t])}}}class gie{#_r=null;constructor(e){this.#_r=e,this.onContinue=null}get promise(){return this.#_r.capability.promise}cancel(e=0){this.#_r.cancel(null,e)}get separateAnnots(){const{separateAnnots:e}=this.#_r.operatorList;if(!e)return!1;const{annotationCanvasMap:t}=this.#_r;return e.form||e.canvas&&t?.size>0}}class yie{#Dr=null;static#Pr=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:r,annotationCanvasMap:a,operatorList:o,pageIndex:c,canvasFactory:i,filterFactory:l,useRequestAnimationFrame:s=!1,pdfBug:h=!1,pageColors:d=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=r,this.annotationCanvasMap=a,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=c,this.canvasFactory=i,this.filterFactory=l,this._pdfBug=h,this.pageColors=d,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===s&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new gie(this),this._cancelBound=this.cancel.bind(this),this._continueBound=this._continue.bind(this),this._scheduleNextBound=this._scheduleNext.bind(this),this._nextBound=this._next.bind(this),this._canvas=t.canvasContext.canvas}get completed(){return this.capability.promise.catch((function(){}))}initializeGraphics({transparency:e=!1,optionalContentConfig:t}){if(this.cancelled)return;if(this._canvas){if(yie.#Pr.has(this._canvas))throw new Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");yie.#Pr.add(this._canvas)}this._pdfBug&&globalThis.StepperManager?.enabled&&(this.stepper=globalThis.StepperManager.create(this._pageIndex),this.stepper.init(this.operatorList),this.stepper.nextBreakPoint=this.stepper.getNextBreakPoint());const{canvasContext:n,viewport:r,transform:a,background:o}=this.params;this.gfx=new Cce(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:a,viewport:r,transparency:e,background:o}),this.operatorListIdx=0,this.graphicsReady=!0,this.graphicsReadyCallback?.()}cancel(e=null,t=0){this.running=!1,this.cancelled=!0,this.gfx?.endDrawing(),this.#Dr&&(window.cancelAnimationFrame(this.#Dr),this.#Dr=null),yie.#Pr.delete(this._canvas),this.callback(e||new coe(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){this.graphicsReady?(this.stepper?.updateOperatorList(this.operatorList),this.running||this._continue()):this.graphicsReadyCallback||=this._continueBound}_continue(){this.running=!0,this.cancelled||(this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext())}_scheduleNext(){this._useRequestAnimationFrame?this.#Dr=window.requestAnimationFrame((()=>{this.#Dr=null,this._nextBound().catch(this._cancelBound)})):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){this.cancelled||(this.operatorListIdx=this.gfx.executeOperatorList(this.operatorList,this.operatorListIdx,this._continueBound,this.stepper),this.operatorListIdx===this.operatorList.argsArray.length&&(this.running=!1,this.operatorList.lastChunk&&(this.gfx.endDrawing(),yie.#Pr.delete(this._canvas),this.callback())))}}const Mie="4.10.38",Eie="f9bea397f";function bie(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function Hie(e){return Math.max(0,Math.min(255,255*e))}class Vie{static CMYK_G([e,t,n,r]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+r)]}static G_CMYK([e]){return["CMYK",0,0,0,1-e]}static G_RGB([e]){return["RGB",e,e,e]}static G_rgb([e]){return[e=Hie(e),e,e]}static G_HTML([e]){const t=bie(e);return`#${t}${t}${t}`}static RGB_G([e,t,n]){return["G",.3*e+.59*t+.11*n]}static RGB_rgb(e){return e.map(Hie)}static RGB_HTML(e){return`#${e.map(bie).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,r]){return["RGB",1-Math.min(1,e+r),1-Math.min(1,n+r),1-Math.min(1,t+r)]}static CMYK_rgb([e,t,n,r]){return[Hie(1-Math.min(1,e+r)),Hie(1-Math.min(1,n+r)),Hie(1-Math.min(1,t+r))]}static CMYK_HTML(e){const t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){const r=1-e,a=1-t,o=1-n;return["CMYK",r,a,o,Math.min(r,a,o)]}}class Cie{create(e,t,n=!1){if(e<=0||t<=0)throw new Error("Invalid SVG dimensions");const r=this._createSVG("svg:svg");return r.setAttribute("version","1.1"),n||(r.setAttribute("width",`${e}px`),r.setAttribute("height",`${t}px`)),r.setAttribute("preserveAspectRatio","none"),r.setAttribute("viewBox",`0 0 ${e} ${t}`),r}createElement(e){if("string"!=typeof e)throw new Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){Rae("Abstract method `_createSVG` called.")}}class Lie extends Cie{_createSVG(e){return document.createElementNS(noe,e)}}class wie{static setupStorage(e,t,n,r,a){const o=r.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==o.value&&(e.textContent=o.value),"print"===a)break;e.addEventListener("input",(e=>{r.setValue(t,{value:e.target.value})}));break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(o.value===n.attributes.xfaOn?e.setAttribute("checked",!0):o.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===a)break;e.addEventListener("change",(e=>{r.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})}))}else{if(null!==o.value&&e.setAttribute("value",o.value),"print"===a)break;e.addEventListener("input",(e=>{r.setValue(t,{value:e.target.value})}))}break;case"select":if(null!==o.value){e.setAttribute("value",o.value);for(const e of n.children)e.attributes.value===o.value?e.attributes.selected=!0:e.attributes.hasOwnProperty("selected")&&delete e.attributes.selected}e.addEventListener("input",(e=>{const n=e.target.options,a=-1===n.selectedIndex?"":n[n.selectedIndex].value;r.setValue(t,{value:a})}))}}static setAttributes({html:e,element:t,storage:n=null,intent:r,linkService:a}){const{attributes:o}=t,c=e instanceof HTMLAnchorElement;"radio"===o.type&&(o.name=`${o.name}-${r}`);for(const[t,n]of Object.entries(o))if(null!=n)switch(t){case"class":n.length&&e.setAttribute(t,n.join(" "));break;case"dataId":break;case"id":e.setAttribute("data-element-id",n);break;case"style":Object.assign(e.style,n);break;case"textContent":e.textContent=n;break;default:(!c||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,n)}c&&a.addLinkAttributes(e,o.href,o.newWindow),n&&o.dataId&&this.setupStorage(e,o.dataId,t,n)}static render(e){const t=e.annotationStorage,n=e.linkService,r=e.xfaHtml,a=e.intent||"display",o=document.createElement(r.name);r.attributes&&this.setAttributes({html:o,element:r,intent:a,linkService:n});const c="richText"!==a,i=e.div;if(i.append(o),e.viewport){const t=`matrix(${e.viewport.transform.join(",")})`;i.style.transform=t}c&&i.setAttribute("class","xfaLayer xfaFont");const l=[];if(0===r.children.length){if(r.value){const e=document.createTextNode(r.value);o.append(e),c&&tie.shouldBuildText(r.name)&&l.push(e)}return{textDivs:l}}const s=[[r,-1,o]];for(;s.length>0;){const[e,r,o]=s.at(-1);if(r+1===e.children.length){s.pop();continue}const i=e.children[++s.at(-1)[1]];if(null===i)continue;const{name:h}=i;if("#text"===h){const e=document.createTextNode(i.value);l.push(e),o.append(e);continue}const d=i?.attributes?.xmlns?document.createElementNS(i.attributes.xmlns,h):document.createElement(h);if(o.append(d),i.attributes&&this.setAttributes({html:d,element:i,storage:t,intent:a,linkService:n}),i.children?.length>0)s.push([i,-1,d]);else if(i.value){const e=document.createTextNode(i.value);c&&tie.shouldBuildText(h)&&l.push(e),d.append(e)}}for(const e of i.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){const t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}const kie=1e3,xie=new WeakSet;function Sie(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class Tie{static create(e){switch(e.data.annotationType){case 2:return new Aie(e);case 1:return new Rie(e);case 20:switch(e.data.fieldType){case"Tx":return new _ie(e);case"Btn":return e.data.radioButton?new Fie(e):e.data.checkBox?new Pie(e):new Iie(e);case"Ch":return new Bie(e);case"Sig":return new Die(e)}return new Nie(e);case 16:return new jie(e);case 3:return new Wie(e);case 4:return new $ie(e);case 5:return new qie(e);case 6:return new Gie(e);case 8:return new Yie(e);case 14:return new Xie(e);case 15:return new Qie(e);case 7:return new Kie(e);case 9:return new Jie(e);case 10:return new Zie(e);case 11:return new ele(e);case 12:return new tle(e);case 13:return new nle(e);case 17:return new rle(e);default:return new Oie(e)}}}class Oie{#Fr=null;#Ir=!1;#Br=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:r=!1}={}){this.isRenderable=t,this.data=e.data,this.layer=e.layer,this.linkService=e.linkService,this.downloadManager=e.downloadManager,this.imageResourcesPath=e.imageResourcesPath,this.renderForms=e.renderForms,this.svgFactory=e.svgFactory,this.annotationStorage=e.annotationStorage,this.enableScripting=e.enableScripting,this.hasJSActions=e.hasJSActions,this._fieldObjects=e.fieldObjects,this.parent=e.parent,t&&(this.container=this._createContainer(n)),r&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get _isEditable(){return this.data.isEditable}get hasPopupData(){return Oie._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#Fr||={rect:this.data.rect.slice(0)};const{rect:t}=e;t&&this.#jr(t),this.#Br?.popup.updateEdited(e)}resetEdited(){this.#Fr&&(this.#jr(this.#Fr.rect),this.#Br?.popup.resetEdited(),this.#Fr=null)}#jr(e){const{container:{style:t},data:{rect:n,rotation:r},parent:{viewport:{rawDims:{pageWidth:a,pageHeight:o,pageX:c,pageY:i}}}}=this;n?.splice(0,4,...e);const{width:l,height:s}=Sie(e);t.left=100*(e[0]-c)/a+"%",t.top=100*(o-e[3]+i)/o+"%",0===r?(t.width=100*l/a+"%",t.height=100*s/o+"%"):this.setRotation(r)}_createContainer(e){const{data:t,parent:{page:n,viewport:r}}=this,a=document.createElement("section");a.setAttribute("data-annotation-id",t.id),this instanceof Nie||(a.tabIndex=kie);const{style:o}=a;if(o.zIndex=this.parent.zIndex++,t.alternativeText&&(a.title=t.alternativeText),t.noRotate&&a.classList.add("norotate"),!t.rect||this instanceof jie){const{rotation:e}=t;return t.hasOwnCanvas||0===e||this.setRotation(e,a),a}const{width:c,height:i}=Sie(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;const e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){const t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;o.borderRadius=t}else if(this instanceof Fie){const e=`calc(${c}px * var(--scale-factor)) / calc(${i}px * var(--scale-factor))`;o.borderRadius=e}switch(t.borderStyle.style){case 1:o.borderStyle="solid";break;case 2:o.borderStyle="dashed";break;case 3:Aae("Unimplemented border style: beveled");break;case 4:Aae("Unimplemented border style: inset");break;case 5:o.borderBottomStyle="solid"}const r=t.borderColor||null;r?(this.#Ir=!0,o.borderColor=Qae.makeHexColor(0|r[0],0|r[1],0|r[2])):o.borderWidth=0}const l=Qae.normalizeRect([t.rect[0],n.view[3]-t.rect[1]+n.view[1],t.rect[2],n.view[3]-t.rect[3]+n.view[1]]),{pageWidth:s,pageHeight:h,pageX:d,pageY:u}=r.rawDims;o.left=100*(l[0]-d)/s+"%",o.top=100*(l[1]-u)/h+"%";const{rotation:m}=t;return t.hasOwnCanvas||0===m?(o.width=100*c/s+"%",o.height=100*i/h+"%"):this.setRotation(m,a),a}setRotation(e,t=this.container){if(!this.data.rect)return;const{pageWidth:n,pageHeight:r}=this.parent.viewport.rawDims,{width:a,height:o}=Sie(this.data.rect);let c,i;e%180==0?(c=100*a/n,i=100*o/r):(c=100*o/n,i=100*a/r),t.style.width=`${c}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){const e=(e,t,n)=>{const r=n.detail[e],a=r[0],o=r.slice(1);n.target.style[t]=Vie[`${a}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[t]:Vie[`${a}_rgb`](o)})};return Dae(this,"_commonActions",{display:e=>{const{display:t}=e.detail,n=t%2==1;this.container.style.visibility=n?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noView:n,noPrint:1===t||2===t})},print:e=>{this.annotationStorage.setValue(this.data.id,{noPrint:!e.detail.print})},hidden:e=>{const{hidden:t}=e.detail;this.container.style.visibility=t?"hidden":"visible",this.annotationStorage.setValue(this.data.id,{noPrint:t,noView:t})},focus:e=>{setTimeout((()=>e.target.focus({preventScroll:!1})),0)},userName:e=>{e.target.title=e.detail.userName},readonly:e=>{e.target.disabled=e.detail.readonly},required:e=>{this._setRequired(e.target,e.detail.required)},bgColor:t=>{e("bgColor","backgroundColor",t)},fillColor:t=>{e("fillColor","backgroundColor",t)},fgColor:t=>{e("fgColor","color",t)},textColor:t=>{e("textColor","color",t)},borderColor:t=>{e("borderColor","borderColor",t)},strokeColor:t=>{e("strokeColor","borderColor",t)},rotation:e=>{const t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){const n=this._commonActions;for(const r of Object.keys(t.detail)){const a=e[r]||n[r];a?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;const t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;const n=this._commonActions;for(const[r,a]of Object.entries(t)){const o=n[r];o&&(o({detail:{[r]:a},target:e}),delete t[r])}}_createQuadrilaterals(){if(!this.container)return;const{quadPoints:e}=this.data;if(!e)return;const[t,n,r,a]=this.data.rect.map((e=>Math.fround(e)));if(8===e.length){const[o,c,i,l]=e.subarray(2,6);if(r===o&&a===c&&t===i&&n===l)return}const{style:o}=this.container;let c;if(this.#Ir){const{borderColor:e,borderWidth:t}=o;o.borderWidth=0,c=["url('data:image/svg+xml;utf8,",'<svg xmlns="http://www.w3.org/2000/svg"',' preserveAspectRatio="none" viewBox="0 0 1 1">',`<g fill="transparent" stroke="${e}" stroke-width="${t}">`],this.container.classList.add("hasBorder")}const i=r-t,l=a-n,{svgFactory:s}=this,h=s.createElement("svg");h.classList.add("quadrilateralsContainer"),h.setAttribute("width",0),h.setAttribute("height",0);const d=s.createElement("defs");h.append(d);const u=s.createElement("clipPath"),m=`clippath_${this.data.id}`;u.setAttribute("id",m),u.setAttribute("clipPathUnits","objectBoundingBox"),d.append(u);for(let n=2,r=e.length;n<r;n+=8){const r=e[n],o=e[n+1],h=e[n+2],d=e[n+3],m=s.createElement("rect"),p=(h-t)/i,v=(a-o)/l,f=(r-h)/i,z=(o-d)/l;m.setAttribute("x",p),m.setAttribute("y",v),m.setAttribute("width",f),m.setAttribute("height",z),u.append(m),c?.push(`<rect vector-effect="non-scaling-stroke" x="${p}" y="${v}" width="${f}" height="${z}"/>`)}this.#Ir&&(c.push("</g></svg>')"),o.backgroundImage=c.join("")),this.container.append(h),this.container.style.clipPath=`url(#${m})`}_createPopup(){const{data:e}=this,t=this.#Br=new jie({data:{color:e.color,titleObj:e.titleObj,modificationDate:e.modificationDate,contentsObj:e.contentsObj,richText:e.richText,parentRect:e.rect,borderStyle:0,id:`popup_${e.id}`,rotation:e.rotation},parent:this.parent,elements:[this]});this.parent.div.append(t.render())}render(){Rae("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){const n=[];if(this._fieldObjects){const r=this._fieldObjects[e];if(r)for(const{page:e,id:a,exportValues:o}of r){if(-1===e)continue;if(a===t)continue;const r="string"==typeof o?o:null,c=document.querySelector(`[data-element-id="${a}"]`);!c||xie.has(c)?n.push({id:a,exportValue:r,domElement:c}):Aae(`_getElementsByName - element not allowed: ${a}`)}return n}for(const r of document.getElementsByName(e)){const{exportValue:e}=r,a=r.getAttribute("data-element-id");a!==t&&xie.has(r)&&n.push({id:a,exportValue:e,domElement:r})}return n}show(){this.container&&(this.container.hidden=!1),this.popup?.maybeShow()}hide(){this.container&&(this.container.hidden=!0),this.popup?.forceHide()}getElementsToTriggerPopup(){return this.container}addHighlightArea(){const e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(const t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}_editOnDoubleClick(){if(!this._isEditable)return;const{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",(()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})}))}}class Aie extends Oie{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){const{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let r=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),r=!0):e.action?(this._bindNamedAction(n,e.action),r=!0):e.attachment?(this.#Ur(n,e.attachment,e.attachmentDest),r=!0):e.setOCGState?(this.#Wr(n,e.setOCGState),r=!0):e.dest?(this._bindLink(n,e.dest),r=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),r=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),r=!0):this.isTooltipOnly&&!r&&(this._bindLink(n,""),r=!0)),this.container.classList.add("linkAnnotation"),r&&this.container.append(n),this.container}#$r(){this.container.setAttribute("data-internal-link","")}_bindLink(e,t){e.href=this.linkService.getDestinationHash(t),e.onclick=()=>(t&&this.linkService.goToDestination(t),!1),(t||""===t)&&this.#$r()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#$r()}#Ur(e,t,n=null){e.href=this.linkService.getAnchorUrl(""),t.description&&(e.title=t.description),e.onclick=()=>(this.downloadManager?.openOrDownloadData(t.content,t.filename,n),!1),this.#$r()}#Wr(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#$r()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");const n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(const r of Object.keys(t.actions)){const a=n.get(r);a&&(e[a]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:r}}),!1))}e.onclick||(e.onclick=()=>!1),this.#$r()}_bindResetFormAction(e,t){const n=e.onclick;if(n||(e.href=this.linkService.getAnchorUrl("")),this.#$r(),!this._fieldObjects)return Aae('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),void(n||(e.onclick=()=>!1));e.onclick=()=>{n?.();const{fields:e,refs:r,include:a}=t,o=[];if(0!==e.length||0!==r.length){const t=new Set(r);for(const n of e){const e=this._fieldObjects[n]||[];for(const{id:n}of e)t.add(n)}for(const e of Object.values(this._fieldObjects))for(const n of e)t.has(n.id)===a&&o.push(n)}else for(const e of Object.values(this._fieldObjects))o.push(...e);const c=this.annotationStorage,i=[];for(const e of o){const{id:t}=e;switch(i.push(t),e.type){case"text":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{const n=e.defaultValue===e.exportValues;c.setValue(t,{value:n});break}case"combobox":case"listbox":{const n=e.defaultValue||"";c.setValue(t,{value:n});break}default:continue}const n=document.querySelector(`[data-element-id="${t}"]`);n&&(xie.has(n)?n.dispatchEvent(new Event("resetform")):Aae(`_bindResetFormAction - element not allowed: ${t}`))}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:i,name:"ResetForm"}}),!1}}}class Rie extends Oie{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");const e=document.createElement("img");return e.src=this.imageResourcesPath+"annotation-"+this.data.name.toLowerCase()+".svg",e.setAttribute("data-l10n-id","pdfjs-text-annotation-type"),e.setAttribute("data-l10n-args",JSON.stringify({type:this.data.name})),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.append(e),this.container}}class Nie extends Oie{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&("CANVAS"===e.previousSibling?.nodeName&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return Kae.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,r,a){n.includes("mouse")?e.addEventListener(n,(e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})})):e.addEventListener(n,(e=>{if("blur"===n){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===n){if(t.focused)return;t.focused=!0}a&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:r,value:a(e)}})}))}_setEventListeners(e,t,n,r){for(const[a,o]of n)("Action"===o||this.data.actions?.[o])&&("Focus"!==o&&"Blur"!==o||(t||={focused:!1}),this._setEventListener(e,t,a,o,r),"Focus"!==o||this.data.actions?.Blur?"Blur"!==o||this.data.actions?.Focus||this._setEventListener(e,t,"focus","Focus",null):this._setEventListener(e,t,"blur","Blur",null))}_setBackgroundColor(e){const t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":Qae.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){const{fontColor:t}=this.data.defaultAppearanceData,n=this.data.defaultAppearanceData.fontSize||9,r=e.style;let a;const o=e=>Math.round(10*e)/10;if(this.data.multiLine){const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),t=e/(Math.round(e/(Eae*n))||1);a=Math.min(n,o(t/Eae))}else{const e=Math.abs(this.data.rect[3]-this.data.rect[1]-2);a=Math.min(n,o(e/Eae))}r.fontSize=`calc(${a}px * var(--scale-factor))`,r.color=Qae.makeHexColor(t[0],t[1],t[2]),null!==this.data.textAlignment&&(r.textAlign=["left","center","right"][this.data.textAlignment])}_setRequired(e,t){t?e.setAttribute("required",!0):e.removeAttribute("required"),e.setAttribute("aria-required",t)}}class _ie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,r){const a=this.annotationStorage;for(const o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=n),a.setValue(o.id,{[r]:n})}render(){const e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){const r=e.getValue(t,{value:this.data.fieldValue});let a=r.value||"";const o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&a.length>o&&(a=a.slice(0,o));let c=r.formattedValue||this.data.textContent?.join("\n")||null;c&&this.data.comb&&(c=c.replaceAll(/\s+/g,""));const i={userValue:a,formattedValue:c,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?(n=document.createElement("textarea"),n.textContent=c??a,this.data.doNotScroll&&(n.style.overflowY="hidden")):(n=document.createElement("input"),n.type="text",n.setAttribute("value",c??a),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),xie.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=kie,this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",(r=>{e.setValue(t,{value:r.target.value}),this.setPropertyOnSiblings(n,"value",r.target.value,"value"),i.formattedValue=null})),n.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue??"";n.value=i.userValue=t,i.formattedValue=null}));let l=e=>{const{formattedValue:t}=i;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",(e=>{if(i.focused)return;const{target:t}=e;i.userValue&&(t.value=i.userValue),i.lastCommittedValue=t.value,i.commitKey=1,this.data.actions?.Focus||(i.focused=!0)})),n.addEventListener("updatefromsandbox",(n=>{this.showElementAndHideCanvas(n.target);const r={value(n){i.userValue=n.detail.value??"",e.setValue(t,{value:i.userValue.toString()}),n.target.value=i.userValue},formattedValue(n){const{formattedValue:r}=n.detail;i.formattedValue=r,null!=r&&n.target!==document.activeElement&&(n.target.value=r),e.setValue(t,{formattedValue:r})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{const{charLimit:r}=n.detail,{target:a}=n;if(0===r)return void a.removeAttribute("maxLength");a.setAttribute("maxLength",r);let o=i.userValue;!o||o.length<=r||(o=o.slice(0,r),a.value=i.userValue=o,e.setValue(t,{value:o}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,willCommit:!0,commitKey:1,selStart:a.selectionStart,selEnd:a.selectionEnd}}))}};this._dispatchEventFromSandbox(r,n)})),n.addEventListener("keydown",(e=>{i.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(i.commitKey=3):n=2,-1===n)return;const{value:r}=e.target;i.lastCommittedValue!==r&&(i.lastCommittedValue=r,i.userValue=r,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}))}));const r=l;l=null,n.addEventListener("blur",(e=>{if(!i.focused||!e.relatedTarget)return;this.data.actions?.Blur||(i.focused=!1);const{value:n}=e.target;i.userValue=n,i.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:i.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),r(e)})),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",(e=>{i.lastCommittedValue=null;const{data:n,target:r}=e,{value:a,selectionStart:o,selectionEnd:c}=r;let l=o,s=c;switch(e.inputType){case"deleteWordBackward":{const e=a.substring(0,o).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{const e=a.substring(o).match(/^[^\w]*\w*/);e&&(s+=e[0].length);break}case"deleteContentBackward":o===c&&(l-=1);break;case"deleteContentForward":o===c&&(s+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,change:n||"",willCommit:!1,selStart:l,selEnd:s}})})),this._setEventListeners(n,i,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.value))}if(l&&n.addEventListener("blur",l),this.data.comb){const e=(this.data.rect[2]-this.data.rect[0])/o;n.classList.add("comb"),n.style.letterSpacing=`calc(${e}px * var(--scale-factor) - 1ch)`}}else n=document.createElement("div"),n.textContent=this.data.fieldValue,n.style.verticalAlign="middle",n.style.display="table-cell",this.data.hasOwnCanvas&&(n.hidden=!0);return this._setTextStyle(n),this._setBackgroundColor(n),this._setDefaultPropertiesFromJS(n),this.container.append(n),this.container}}class Die extends Nie{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class Pie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms})}render(){const e=this.annotationStorage,t=this.data,n=t.id;let r=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof r&&(r="Off"!==r,e.setValue(n,{value:r})),this.container.classList.add("buttonWidgetAnnotation","checkBox");const a=document.createElement("input");return xie.add(a),a.setAttribute("data-element-id",n),a.disabled=t.readOnly,this._setRequired(a,this.data.required),a.type="checkbox",a.name=t.fieldName,r&&a.setAttribute("checked",!0),a.setAttribute("exportValue",t.exportValue),a.tabIndex=kie,a.addEventListener("change",(r=>{const{name:a,checked:o}=r.target;for(const r of this._getElementsByName(a,n)){const n=o&&r.exportValue===t.exportValue;r.domElement&&(r.domElement.checked=n),e.setValue(r.id,{value:n})}e.setValue(n,{value:o})})),a.addEventListener("resetform",(e=>{const n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue})),this.enableScripting&&this.hasJSActions&&(a.addEventListener("updatefromsandbox",(t=>{const r={value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}};this._dispatchEventFromSandbox(r,t)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))),this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Fie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");const e=this.annotationStorage,t=this.data,n=t.id;let r=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof r&&(r=r!==t.buttonValue,e.setValue(n,{value:r})),r)for(const r of this._getElementsByName(t.fieldName,n))e.setValue(r.id,{value:!1});const a=document.createElement("input");if(xie.add(a),a.setAttribute("data-element-id",n),a.disabled=t.readOnly,this._setRequired(a,this.data.required),a.type="radio",a.name=t.fieldName,r&&a.setAttribute("checked",!0),a.tabIndex=kie,a.addEventListener("change",(t=>{const{name:r,checked:a}=t.target;for(const t of this._getElementsByName(r,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:a})})),a.addEventListener("resetform",(e=>{const n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue})),this.enableScripting&&this.hasJSActions){const r=t.buttonValue;a.addEventListener("updatefromsandbox",(t=>{const a={value:t=>{const a=r===t.detail.value;for(const r of this._getElementsByName(t.target.name)){const t=a&&r.id===n;r.domElement&&(r.domElement.checked=t),e.setValue(r.id,{value:t})}}};this._dispatchEventFromSandbox(a,t)})),this._setEventListeners(a,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],(e=>e.target.checked))}return this._setBackgroundColor(a),this._setDefaultPropertiesFromJS(a),this.container.append(a),this.container}}class Iie extends Aie{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){const e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");const t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",(e=>{this._dispatchEventFromSandbox({},e)}))),e}}class Bie extends Nie{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");const e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),r=document.createElement("select");xie.add(r),r.setAttribute("data-element-id",t),r.disabled=this.data.readOnly,this._setRequired(r,this.data.required),r.name=this.data.fieldName,r.tabIndex=kie;let a=this.data.combo&&this.data.options.length>0;this.data.combo||(r.size=this.data.options.length,this.data.multiSelect&&(r.multiple=!0)),r.addEventListener("resetform",(e=>{const t=this.data.defaultFieldValue;for(const e of r.options)e.selected=e.value===t}));for(const e of this.data.options){const t=document.createElement("option");t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),a=!1),r.append(t)}let o=null;if(a){const e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),r.prepend(e),o=()=>{e.remove(),r.removeEventListener("input",o),o=null},r.addEventListener("input",o)}const c=e=>{const t=e?"value":"textContent",{options:n,multiple:a}=r;return a?Array.prototype.filter.call(n,(e=>e.selected)).map((e=>e[t])):-1===n.selectedIndex?null:n[n.selectedIndex][t]};let i=c(!1);const l=e=>{const t=e.target.options;return Array.prototype.map.call(t,(e=>({displayValue:e.textContent,exportValue:e.value})))};return this.enableScripting&&this.hasJSActions?(r.addEventListener("updatefromsandbox",(n=>{const a={value(n){o?.();const a=n.detail.value,l=new Set(Array.isArray(a)?a:[a]);for(const e of r.options)e.selected=l.has(e.value);e.setValue(t,{value:c(!0)}),i=c(!1)},multipleSelection(e){r.multiple=!0},remove(n){const a=r.options,o=n.detail.remove;a[o].selected=!1,r.remove(o),a.length>0&&-1===Array.prototype.findIndex.call(a,(e=>e.selected))&&(a[0].selected=!0),e.setValue(t,{value:c(!0),items:l(n)}),i=c(!1)},clear(n){for(;0!==r.length;)r.remove(0);e.setValue(t,{value:null,items:[]}),i=c(!1)},insert(n){const{index:a,displayValue:o,exportValue:s}=n.detail.insert,h=r.children[a],d=document.createElement("option");d.textContent=o,d.value=s,h?h.before(d):r.append(d),e.setValue(t,{value:c(!0),items:l(n)}),i=c(!1)},items(n){const{items:a}=n.detail;for(;0!==r.length;)r.remove(0);for(const e of a){const{displayValue:t,exportValue:n}=e,a=document.createElement("option");a.textContent=t,a.value=n,r.append(a)}r.options.length>0&&(r.options[0].selected=!0),e.setValue(t,{value:c(!0),items:l(n)}),i=c(!1)},indices(n){const r=new Set(n.detail.indices);for(const e of n.target.options)e.selected=r.has(e.index);e.setValue(t,{value:c(!0)}),i=c(!1)},editable(e){e.target.disabled=!e.detail.editable}};this._dispatchEventFromSandbox(a,n)})),r.addEventListener("input",(n=>{const r=c(!0),a=c(!1);e.setValue(t,{value:r}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,change:a,changeEx:r,willCommit:!1,commitKey:1,keyDown:!1}})})),this._setEventListeners(r,null,[["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"],["input","Action"],["input","Validate"]],(e=>e.target.value))):r.addEventListener("input",(function(n){e.setValue(t,{value:c(!0)})})),this.data.combo&&this._setTextStyle(r),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class jie extends Oie{constructor(e){const{data:t,elements:n}=e;super(e,{isRenderable:Oie._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");const e=this.popup=new Uie({container:this.container,color:this.data.color,titleObj:this.data.titleObj,modificationDate:this.data.modificationDate,contentsObj:this.data.contentsObj,richText:this.data.richText,rect:this.data.rect,parentRect:this.data.parentRect||null,parent:this.parent,elements:this.elements,open:this.data.open}),t=[];for(const n of this.elements)n.popup=e,n.container.ariaHasPopup="dialog",t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.map((e=>`${toe}${e}`)).join(",")),this.container}}class Uie{#qr=this.#Gr.bind(this);#Yr=this.#Kr.bind(this);#Xr=this.#Qr.bind(this);#Jr=this.#Zr.bind(this);#ea=null;#me=null;#ta=null;#na=null;#ra=null;#aa=null;#oa=null;#ca=!1;#ia=null;#L=null;#la=null;#sa=null;#ha=null;#Fr=null;#da=!1;constructor({container:e,color:t,elements:n,titleObj:r,modificationDate:a,contentsObj:o,richText:c,parent:i,rect:l,parentRect:s,open:h}){this.#me=e,this.#ha=r,this.#ta=o,this.#sa=c,this.#aa=i,this.#ea=t,this.#la=l,this.#oa=s,this.#ra=n,this.#na=voe.toDateObject(a),this.trigger=n.flatMap((e=>e.getElementsToTriggerPopup()));for(const e of this.trigger)e.addEventListener("click",this.#Jr),e.addEventListener("mouseenter",this.#Xr),e.addEventListener("mouseleave",this.#Yr),e.classList.add("popupTriggerArea");for(const e of n)e.container?.addEventListener("keydown",this.#qr);this.#me.hidden=!0,h&&this.#Zr()}render(){if(this.#ia)return;const e=this.#ia=document.createElement("div");if(e.className="popup",this.#ea){const t=e.style.outlineColor=Qae.makeHexColor(...this.#ea);if(CSS.supports("background-color","color-mix(in srgb, red 30%, white)"))e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`;else{const t=.7;e.style.backgroundColor=Qae.makeHexColor(...this.#ea.map((e=>Math.floor(t*(255-e)+e))))}}const t=document.createElement("span");t.className="header";const n=document.createElement("h1");if(t.append(n),({dir:n.dir,str:n.textContent}=this.#ha),e.append(t),this.#na){const e=document.createElement("span");e.classList.add("popupDate"),e.setAttribute("data-l10n-id","pdfjs-annotation-date-time-string"),e.setAttribute("data-l10n-args",JSON.stringify({dateObj:this.#na.valueOf()})),t.append(e)}const r=this.#ua;if(r)wie.render({xfaHtml:r,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{const t=this._formatContents(this.#ta);e.append(t)}this.#me.append(e)}get#ua(){const e=this.#sa,t=this.#ta;return!e?.str||t?.str&&t.str!==e.str?null:this.#sa.html||null}get#ma(){return this.#ua?.attributes?.style?.fontSize||0}get#pa(){return this.#ua?.attributes?.style?.color||null}#va(e){const t=[],n={str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}},r={style:{color:this.#pa,fontSize:this.#ma?`calc(${this.#ma}px * var(--scale-factor))`:""}};for(const n of e.split("\n"))t.push({name:"span",value:n,attributes:r});return n}_formatContents({str:e,dir:t}){const n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;const r=e.split(/(?:\r\n?|\n)/);for(let e=0,t=r.length;e<t;++e){const a=r[e];n.append(document.createTextNode(a)),e<t-1&&n.append(document.createElement("br"))}return n}#Gr(e){e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||("Enter"===e.key||"Escape"===e.key&&this.#ca)&&this.#Zr()}updateEdited({rect:e,popupContent:t}){this.#Fr||={contentsObj:this.#ta,richText:this.#sa},e&&(this.#L=null),t&&(this.#sa=this.#va(t),this.#ta=null),this.#ia?.remove(),this.#ia=null}resetEdited(){this.#Fr&&(({contentsObj:this.#ta,richText:this.#sa}=this.#Fr),this.#Fr=null,this.#ia?.remove(),this.#ia=null,this.#L=null)}#fa(){if(null!==this.#L)return;const{page:{view:e},viewport:{rawDims:{pageWidth:t,pageHeight:n,pageX:r,pageY:a}}}=this.#aa;let o=!!this.#oa,c=o?this.#oa:this.#la;for(const e of this.#ra)if(!c||null!==Qae.intersect(e.data.rect,c)){c=e.data.rect,o=!0;break}const i=Qae.normalizeRect([c[0],e[3]-c[1]+e[1],c[2],e[3]-c[3]+e[1]]),l=o?c[2]-c[0]+5:0,s=i[0]+l,h=i[1];this.#L=[100*(s-r)/t,100*(h-a)/n];const{style:d}=this.#me;d.left=`${this.#L[0]}%`,d.top=`${this.#L[1]}%`}#Zr(){this.#ca=!this.#ca,this.#ca?(this.#Qr(),this.#me.addEventListener("click",this.#Jr),this.#me.addEventListener("keydown",this.#qr)):(this.#Kr(),this.#me.removeEventListener("click",this.#Jr),this.#me.removeEventListener("keydown",this.#qr))}#Qr(){this.#ia||this.render(),this.isVisible?this.#ca&&this.#me.classList.add("focused"):(this.#fa(),this.#me.hidden=!1,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)+1e3)}#Kr(){this.#me.classList.remove("focused"),!this.#ca&&this.isVisible&&(this.#me.hidden=!0,this.#me.style.zIndex=parseInt(this.#me.style.zIndex)-1e3)}forceHide(){this.#da=this.isVisible,this.#da&&(this.#me.hidden=!0)}maybeShow(){this.#da&&(this.#ia||this.#Qr(),this.#da=!1,this.#me.hidden=!1)}get isVisible(){return!1===this.#me.hidden}}class Wie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.textContent=e.data.textContent,this.textPosition=e.data.textPosition,this.annotationEditorType=Hae.FREETEXT}render(){if(this.container.classList.add("freeTextAnnotation"),this.textContent){const e=document.createElement("div");e.classList.add("annotationTextContent"),e.setAttribute("role","comment");for(const t of this.textContent){const n=document.createElement("span");n.textContent=t,e.append(n)}this.container.append(e)}return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class $ie extends Oie{#za=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("lineAnnotation");const e=this.data,{width:t,height:n}=Sie(e.rect),r=this.svgFactory.create(t,n,!0),a=this.#za=this.svgFactory.createElement("svg:line");return a.setAttribute("x1",e.rect[2]-e.lineCoordinates[0]),a.setAttribute("y1",e.rect[3]-e.lineCoordinates[1]),a.setAttribute("x2",e.rect[2]-e.lineCoordinates[2]),a.setAttribute("y2",e.rect[3]-e.lineCoordinates[3]),a.setAttribute("stroke-width",e.borderStyle.width||1),a.setAttribute("stroke","transparent"),a.setAttribute("fill","transparent"),r.append(a),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#za}addHighlightArea(){this.container.classList.add("highlightArea")}}class qie extends Oie{#ga=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("squareAnnotation");const e=this.data,{width:t,height:n}=Sie(e.rect),r=this.svgFactory.create(t,n,!0),a=e.borderStyle.width,o=this.#ga=this.svgFactory.createElement("svg:rect");return o.setAttribute("x",a/2),o.setAttribute("y",a/2),o.setAttribute("width",t-a),o.setAttribute("height",n-a),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ga}addHighlightArea(){this.container.classList.add("highlightArea")}}class Gie extends Oie{#ya=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){this.container.classList.add("circleAnnotation");const e=this.data,{width:t,height:n}=Sie(e.rect),r=this.svgFactory.create(t,n,!0),a=e.borderStyle.width,o=this.#ya=this.svgFactory.createElement("svg:ellipse");return o.setAttribute("cx",t/2),o.setAttribute("cy",n/2),o.setAttribute("rx",t/2-a/2),o.setAttribute("ry",n/2-a/2),o.setAttribute("stroke-width",a||1),o.setAttribute("stroke","transparent"),o.setAttribute("fill","transparent"),r.append(o),this.container.append(r),!e.popupRef&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#ya}addHighlightArea(){this.container.classList.add("highlightArea")}}class Yie extends Oie{#Ma=null;constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="polylineAnnotation",this.svgElementName="svg:polyline"}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,vertices:t,borderStyle:n,popupRef:r}}=this;if(!t)return this.container;const{width:a,height:o}=Sie(e),c=this.svgFactory.create(a,o,!0);let i=[];for(let n=0,r=t.length;n<r;n+=2){const r=t[n]-e[0],a=e[3]-t[n+1];i.push(`${r},${a}`)}i=i.join(" ");const l=this.#Ma=this.svgFactory.createElement(this.svgElementName);return l.setAttribute("points",i),l.setAttribute("stroke-width",n.width||1),l.setAttribute("stroke","transparent"),l.setAttribute("fill","transparent"),c.append(l),this.container.append(c),!r&&this.hasPopupData&&this._createPopup(),this.container}getElementsToTriggerPopup(){return this.#Ma}addHighlightArea(){this.container.classList.add("highlightArea")}}class Kie extends Yie{constructor(e){super(e),this.containerClassName="polygonAnnotation",this.svgElementName="svg:polygon"}}class Xie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0})}render(){return this.container.classList.add("caretAnnotation"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container}}class Qie extends Oie{#Ea=null;#ba=[];constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.containerClassName="inkAnnotation",this.svgElementName="svg:polyline",this.annotationEditorType="InkHighlight"===this.data.it?Hae.HIGHLIGHT:Hae.INK}#Ha(e,t){switch(e){case 90:return{transform:`rotate(90) translate(${-t[0]},${t[1]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};case 180:return{transform:`rotate(180) translate(${-t[2]},${t[1]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]};case 270:return{transform:`rotate(270) translate(${-t[2]},${t[3]}) scale(1,-1)`,width:t[3]-t[1],height:t[2]-t[0]};default:return{transform:`translate(${-t[0]},${t[3]}) scale(1,-1)`,width:t[2]-t[0],height:t[3]-t[1]}}}render(){this.container.classList.add(this.containerClassName);const{data:{rect:e,rotation:t,inkLists:n,borderStyle:r,popupRef:a}}=this,{transform:o,width:c,height:i}=this.#Ha(t,e),l=this.svgFactory.create(c,i,!0),s=this.#Ea=this.svgFactory.createElement("svg:g");l.append(s),s.setAttribute("stroke-width",r.width||1),s.setAttribute("stroke-linecap","round"),s.setAttribute("stroke-linejoin","round"),s.setAttribute("stroke-miterlimit",10),s.setAttribute("stroke","transparent"),s.setAttribute("fill","transparent"),s.setAttribute("transform",o);for(let e=0,t=n.length;e<t;e++){const t=this.svgFactory.createElement(this.svgElementName);this.#ba.push(t),t.setAttribute("points",n[e].join(",")),s.append(t)}return!a&&this.hasPopupData&&this._createPopup(),this.container.append(l),this._editOnDoubleClick(),this.container}updateEdited(e){super.updateEdited(e);const{thickness:t,points:n,rect:r}=e,a=this.#Ea;if(t>=0&&a.setAttribute("stroke-width",t||1),n)for(let e=0,t=this.#ba.length;e<t;e++)this.#ba[e].setAttribute("points",n[e].join(","));if(r){const{transform:e,width:t,height:n}=this.#Ha(this.data.rotation,r);a.parentElement.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("transform",e)}}getElementsToTriggerPopup(){return this.#ba}addHighlightArea(){this.container.classList.add("highlightArea")}}class Jie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0}),this.annotationEditorType=Hae.HIGHLIGHT}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("highlightAnnotation"),this._editOnDoubleClick(),this.container}}class Zie extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("underlineAnnotation"),this.container}}class ele extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("squigglyAnnotation"),this.container}}class tle extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0,createQuadrilaterals:!0})}render(){return!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this.container.classList.add("strikeoutAnnotation"),this.container}}class nle extends Oie{constructor(e){super(e,{isRenderable:!0,ignoreBorder:!0}),this.annotationEditorType=Hae.STAMP}render(){return this.container.classList.add("stampAnnotation"),this.container.setAttribute("role","img"),!this.data.popupRef&&this.hasPopupData&&this._createPopup(),this._editOnDoubleClick(),this.container}}class rle extends Oie{#Va=null;constructor(e){super(e,{isRenderable:!0});const{file:t}=this.data;this.filename=t.filename,this.content=t.content,this.linkService.eventBus?.dispatch("fileattachmentannotation",{source:this,...t})}render(){this.container.classList.add("fileAttachmentAnnotation");const{container:e,data:t}=this;let n;t.hasAppearance||0===t.fillAlpha?n=document.createElement("div"):(n=document.createElement("img"),n.src=`${this.imageResourcesPath}annotation-${/paperclip/i.test(t.name)?"paperclip":"pushpin"}.svg`,t.fillAlpha&&t.fillAlpha<1&&(n.style=`filter: opacity(${Math.round(100*t.fillAlpha)}%);`)),n.addEventListener("dblclick",this.#Ca.bind(this)),this.#Va=n;const{isMac:r}=Kae.platform;return e.addEventListener("keydown",(e=>{"Enter"===e.key&&(r?e.metaKey:e.ctrlKey)&&this.#Ca()})),!t.popupRef&&this.hasPopupData?this._createPopup():n.classList.add("popupTriggerArea"),e.append(n),e}getElementsToTriggerPopup(){return this.#Va}addHighlightArea(){this.container.classList.add("highlightArea")}#Ca(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class ale{#La=null;#wa=null;#ka=new Map;#xa=null;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:r,page:a,viewport:o,structTreeLayer:c}){this.div=e,this.#La=t,this.#wa=n,this.#xa=c||null,this.page=a,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=r}hasEditableAnnotations(){return this.#ka.size>0}async#Sa(e,t){const n=e.firstChild||e,r=n.id=`${toe}${t}`,a=await(this.#xa?.getAriaAttributes(r));if(a)for(const[e,t]of a)n.setAttribute(e,t);this.div.append(e),this.#La?.moveElementInDOM(this.div,e,n,!1)}async render(e){const{annotations:t}=e,n=this.div;Moe(n,this.viewport);const r=new Map,a={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new Lie,annotationStorage:e.annotationStorage||new Ioe,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(const e of t){if(e.noHTML)continue;const t=16===e.annotationType;if(t){const t=r.get(e.id);if(!t)continue;a.elements=t}else{const{width:t,height:n}=Sie(e.rect);if(t<=0||n<=0)continue}a.data=e;const n=Tie.create(a);if(!n.isRenderable)continue;if(!t&&e.popupRef){const t=r.get(e.popupRef);t?t.push(n):r.set(e.popupRef,[n])}const o=n.render();e.hidden&&(o.style.visibility="hidden"),await this.#Sa(o,e.id),n._isEditable&&(this.#ka.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#Ta()}update({viewport:e}){const t=this.div;this.viewport=e,Moe(t,{rotation:e.rotation}),this.#Ta(),t.hidden=!1}#Ta(){if(!this.#wa)return;const e=this.div;for(const[t,n]of this.#wa){const r=e.querySelector(`[data-annotation-id="${t}"]`);if(!r)continue;n.className="annotationContent";const{firstChild:a}=r;a?"CANVAS"===a.nodeName?a.replaceWith(n):a.classList.contains("annotationContent")?a.after(n):a.before(n):r.append(n)}this.#wa.clear()}getEditableAnnotations(){return Array.from(this.#ka.values())}getEditableAnnotation(e){return this.#ka.get(e)}}const ole=/\r\n?|\n/g;class cle extends Aoe{#ea;#Oa="";#Aa=`${this.id}-editor`;#Ra=null;#ma;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){const e=cle.prototype,t=e=>e.isEmpty(),n=Soe.TRANSLATE_SMALL,r=Soe.TRANSLATE_BIG;return Dae(this,"_keyboardManager",new koe([[["ctrl+s","mac+meta+s","ctrl+p","mac+meta+p"],e.commitOrRemove,{bubbles:!0}],[["ctrl+Enter","mac+meta+Enter","Escape","mac+Escape"],e.commitOrRemove],[["ArrowLeft","mac+ArrowLeft"],e._translateEmpty,{args:[-n,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e._translateEmpty,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,r],checker:t}]]))}static _type="freetext";static _editorType=Hae.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"}),this.#ea=e.color||cle._defaultColor||Aoe._defaultLineColor,this.#ma=e.fontSize||cle._defaultFontSize}static initialize(e,t){Aoe.initialize(e,t);const n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case Vae.FREETEXT_SIZE:cle._defaultFontSize=t;break;case Vae.FREETEXT_COLOR:cle._defaultColor=t}}updateParams(e,t){switch(e){case Vae.FREETEXT_SIZE:this.#Na(t);break;case Vae.FREETEXT_COLOR:this.#_a(t)}}static get defaultPropertiesToUpdate(){return[[Vae.FREETEXT_SIZE,cle._defaultFontSize],[Vae.FREETEXT_COLOR,cle._defaultColor||Aoe._defaultLineColor]]}get propertiesToUpdate(){return[[Vae.FREETEXT_SIZE,this.#ma],[Vae.FREETEXT_COLOR,this.#ea]]}#Na(e){const t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#ma)*this.parentScale),this.#ma=e,this.#Da()},n=this.#ma;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#_a(e){const t=e=>{this.#ea=this.editorDiv.style.color=e},n=this.#ea;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){const e=this.parentScale;return[-cle._internalPadding*e,-(cle._internalPadding+this.#ma)*e]}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.isAttachedToDOM||this.parent.add(this)))}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(Hae.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant"),this.#Ra=new AbortController;const e=this._uiManager.combinedSignal(this.#Ra);this.editorDiv.addEventListener("keydown",this.editorDivKeydown.bind(this),{signal:e}),this.editorDiv.addEventListener("focus",this.editorDivFocus.bind(this),{signal:e}),this.editorDiv.addEventListener("blur",this.editorDivBlur.bind(this),{signal:e}),this.editorDiv.addEventListener("input",this.editorDivInput.bind(this),{signal:e}),this.editorDiv.addEventListener("paste",this.editorDivPaste.bind(this),{signal:e})}disableEditMode(){this.isInEditMode()&&(this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#Aa),this._isDraggable=!0,this.#Ra?.abort(),this.#Ra=null,this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing"))}focusin(e){this._focusEventsAllowed&&(super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus())}onceAdded(e){this.width||(this.enableEditMode(),e&&this.editorDiv.focus(),this._initialOptions?.isCentered&&this.center(),this._initialOptions=null)}isEmpty(){return!this.editorDiv||""===this.editorDiv.innerText.trim()}remove(){this.isEditing=!1,this.parent&&(this.parent.setEditingState(!0),this.parent.div.classList.add("freetextEditing")),super.remove()}#Pa(){const e=[];this.editorDiv.normalize();let t=null;for(const n of this.editorDiv.childNodes)t?.nodeType===Node.TEXT_NODE&&"BR"===n.nodeName||(e.push(cle.#Fa(n)),t=n);return e.join("\n")}#Da(){const[e,t]=this.parentDimensions;let n;if(this.isAttachedToDOM)n=this.div.getBoundingClientRect();else{const{currentLayer:e,div:t}=this,r=t.style.display,a=t.classList.contains("hidden");t.classList.remove("hidden"),t.style.display="hidden",e.div.append(this.div),n=t.getBoundingClientRect(),t.remove(),t.style.display=r,t.classList.toggle("hidden",a)}this.rotation%180==this.parentRotation%180?(this.width=n.width/e,this.height=n.height/t):(this.width=n.height/e,this.height=n.width/t),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();const e=this.#Oa,t=this.#Oa=this.#Pa().trimEnd();if(e===t)return;const n=e=>{this.#Oa=e,e?(this.#Ia(),this._uiManager.rebuild(this),this.#Da()):this.remove()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#Da()}shouldGetKeyboardEvents(){return this.isInEditMode()}enterInEditMode(){this.enableEditMode(),this.editorDiv.focus()}dblclick(e){this.enterInEditMode()}keydown(e){e.target===this.div&&"Enter"===e.key&&(this.enterInEditMode(),e.preventDefault())}editorDivKeydown(e){cle._keyboardManager.exec(this,e)}editorDivFocus(e){this.isEditing=!0}editorDivBlur(e){this.isEditing=!1}editorDivInput(e){this.parent.div.classList.toggle("freetextEditing",this.isEmpty())}disableEditing(){this.editorDiv.setAttribute("role","comment"),this.editorDiv.removeAttribute("aria-multiline")}enableEditing(){this.editorDiv.setAttribute("role","textbox"),this.editorDiv.setAttribute("aria-multiline",!0)}render(){if(this.div)return this.div;let e,t;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#Aa),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text2"),this.editorDiv.setAttribute("data-l10n-attrs","default-content"),this.enableEditing(),this.editorDiv.contentEditable=!0;const{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#ma}px * var(--scale-factor))`,n.color=this.#ea,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),Voe(this,this.div,["dblclick","keydown"]),this.width){const[n,r]=this.parentDimensions;if(this.annotationElementId){const{position:a}=this._initialData;let[o,c]=this.getInitialTranslation();[o,c]=this.pageTranslationToScreen(o,c);const[i,l]=this.pageDimensions,[s,h]=this.pageTranslation;let d,u;switch(this.rotation){case 0:d=e+(a[0]-s)/i,u=t+this.height-(a[1]-h)/l;break;case 90:d=e+(a[0]-s)/i,u=t-(a[1]-h)/l,[o,c]=[c,-o];break;case 180:d=e-this.width+(a[0]-s)/i,u=t-(a[1]-h)/l,[o,c]=[-o,-c];break;case 270:d=e+(a[0]-s-this.height*l)/i,u=t+(a[1]-h-this.width*i)/l,[o,c]=[-c,o]}this.setAt(d*n,u*r,o,c)}else this.setAt(e*n,t*r,this.width*n,this.height*r);this.#Ia(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static#Fa(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(ole,"")}editorDivPaste(e){const t=e.clipboardData||window.clipboardData,{types:n}=t;if(1===n.length&&"text/plain"===n[0])return;e.preventDefault();const r=cle.#Ba(t.getData("text")||"").replaceAll(ole,"\n");if(!r)return;const a=window.getSelection();if(!a.rangeCount)return;this.editorDiv.normalize(),a.deleteFromDocument();const o=a.getRangeAt(0);if(!r.includes("\n"))return o.insertNode(document.createTextNode(r)),this.editorDiv.normalize(),void a.collapseToStart();const{startContainer:c,startOffset:i}=o,l=[],s=[];if(c.nodeType===Node.TEXT_NODE){const e=c.parentElement;if(s.push(c.nodeValue.slice(i).replaceAll(ole,"")),e!==this.editorDiv){let t=l;for(const n of this.editorDiv.childNodes)n!==e?t.push(cle.#Fa(n)):t=s}l.push(c.nodeValue.slice(0,i).replaceAll(ole,""))}else if(c===this.editorDiv){let e=l,t=0;for(const n of this.editorDiv.childNodes)t++===i&&(e=s),e.push(cle.#Fa(n))}this.#Oa=`${l.join("\n")}${r}${s.join("\n")}`,this.#Ia();const h=new Range;let d=l.reduce(((e,t)=>e+t.length),0);for(const{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){const t=e.nodeValue.length;if(d<=t){h.setStart(e,d),h.setEnd(e,d);break}d-=t}a.removeAllRanges(),a.addRange(h)}#Ia(){if(this.editorDiv.replaceChildren(),this.#Oa)for(const e of this.#Oa.split("\n")){const t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#ja(){return this.#Oa.replaceAll(" "," ")}static#Ba(e){return e.replaceAll(" "," ")}get contentDiv(){return this.editorDiv}static async deserialize(e,t,n){let r=null;if(e instanceof Wie){const{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:a,rotation:o,id:c,popupRef:i},textContent:l,textPosition:s,parent:{page:{pageNumber:h}}}=e;if(!l||0===l.length)return null;r=e={annotationType:Hae.FREETEXT,color:Array.from(n),fontSize:t,value:l.join("\n"),position:s,pageIndex:h-1,rect:a.slice(0),rotation:o,id:c,deleted:!1,popupRef:i}}const a=await super.deserialize(e,t,n);return a.#ma=e.fontSize,a.#ea=Qae.makeHexColor(...e.color),a.#Oa=cle.#Ba(e.value),a.annotationElementId=e.id||null,a._initialData=r,a}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const t=cle._internalPadding*this.parentScale,n=this.getRect(t,t),r=Aoe._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#ea),a={annotationType:Hae.FREETEXT,color:r,fontSize:this.#ma,value:this.#ja(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?a:this.annotationElementId&&!this.#Ua(a)?null:(a.id=this.annotationElementId,a)}#Ua(e){const{value:t,fontSize:n,color:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some(((e,t)=>e!==r[t]))||e.pageIndex!==a}renderAnnotationElement(e){const t=super.renderAnnotationElement(e);if(this.deleted)return t;const{style:n}=t;n.fontSize=`calc(${this.#ma}px * var(--scale-factor))`,n.color=this.#ea,t.replaceChildren();for(const e of this.#Oa.split("\n")){const n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),t.append(n)}const r=cle._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(r,r),popupContent:this.#Oa}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class ile{static PRECISION=1e-4;toSVGPath(){Rae("Abstract method `toSVGPath` must be implemented.")}get box(){Rae("Abstract getter `box` must be implemented.")}serialize(e,t){Rae("Abstract method `serialize` must be implemented.")}static _rescale(e,t,n,r,a,o){o||=new Float32Array(e.length);for(let c=0,i=e.length;c<i;c+=2)o[c]=t+e[c]*r,o[c+1]=n+e[c+1]*a;return o}static _rescaleAndSwap(e,t,n,r,a,o){o||=new Float32Array(e.length);for(let c=0,i=e.length;c<i;c+=2)o[c]=t+e[c+1]*r,o[c+1]=n+e[c]*a;return o}static _translate(e,t,n,r){r||=new Float32Array(e.length);for(let a=0,o=e.length;a<o;a+=2)r[a]=t+e[a],r[a+1]=n+e[a+1];return r}static svgRound(e){return Math.round(1e4*e)}static _normalizePoint(e,t,n,r,a){switch(a){case 90:return[1-t/n,e/r];case 180:return[1-e/n,1-t/r];case 270:return[t/n,1-e/r];default:return[e/n,t/r]}}static _normalizePagePoint(e,t,n){switch(n){case 90:return[1-t,e];case 180:return[1-e,1-t];case 270:return[t,1-e];default:return[e,t]}}static createBezierPoints(e,t,n,r,a,o){return[(e+5*n)/6,(t+5*r)/6,(5*n+a)/6,(5*r+o)/6,(n+a)/2,(r+o)/2]}}class lle{#Wa;#$a=[];#qa;#Ga;#Ya=[];#Ka=new Float32Array(18);#Xa;#Qa;#Ja;#Za;#eo;#to;#no=[];static#ro=8;static#ao=2;static#oo=lle.#ro+lle.#ao;constructor({x:e,y:t},n,r,a,o,c=0){this.#Wa=n,this.#to=a*r,this.#Ga=o,this.#Ka.set([NaN,NaN,NaN,NaN,e,t],6),this.#qa=c,this.#Za=lle.#ro*r,this.#Ja=lle.#oo*r,this.#eo=r,this.#no.push(e,t)}isEmpty(){return isNaN(this.#Ka[8])}#co(){const e=this.#Ka.subarray(4,6),t=this.#Ka.subarray(16,18),[n,r,a,o]=this.#Wa;return[(this.#Xa+(e[0]-t[0])/2-n)/a,(this.#Qa+(e[1]-t[1])/2-r)/o,(this.#Xa+(t[0]-e[0])/2-n)/a,(this.#Qa+(t[1]-e[1])/2-r)/o]}add({x:e,y:t}){this.#Xa=e,this.#Qa=t;const[n,r,a,o]=this.#Wa;let[c,i,l,s]=this.#Ka.subarray(8,12);const h=e-l,d=t-s,u=Math.hypot(h,d);if(u<this.#Ja)return!1;const m=u-this.#Za,p=m/u,v=p*h,f=p*d;let z=c,g=i;c=l,i=s,l+=v,s+=f,this.#no?.push(e,t);const y=v/m,M=-f/m*this.#to,E=y*this.#to;return this.#Ka.set(this.#Ka.subarray(2,8),0),this.#Ka.set([l+M,s+E],4),this.#Ka.set(this.#Ka.subarray(14,18),12),this.#Ka.set([l-M,s-E],16),isNaN(this.#Ka[6])?(0===this.#Ya.length&&(this.#Ka.set([c+M,i+E],2),this.#Ya.push(NaN,NaN,NaN,NaN,(c+M-n)/a,(i+E-r)/o),this.#Ka.set([c-M,i-E],14),this.#$a.push(NaN,NaN,NaN,NaN,(c-M-n)/a,(i-E-r)/o)),this.#Ka.set([z,g,c,i,l,s],6),!this.isEmpty()):(this.#Ka.set([z,g,c,i,l,s],6),Math.abs(Math.atan2(g-i,z-c)-Math.atan2(f,v))<Math.PI/2?([c,i,l,s]=this.#Ka.subarray(2,6),this.#Ya.push(NaN,NaN,NaN,NaN,((c+l)/2-n)/a,((i+s)/2-r)/o),[c,i,z,g]=this.#Ka.subarray(14,18),this.#$a.push(NaN,NaN,NaN,NaN,((z+c)/2-n)/a,((g+i)/2-r)/o),!0):([z,g,c,i,l,s]=this.#Ka.subarray(0,6),this.#Ya.push(((z+5*c)/6-n)/a,((g+5*i)/6-r)/o,((5*c+l)/6-n)/a,((5*i+s)/6-r)/o,((c+l)/2-n)/a,((i+s)/2-r)/o),[l,s,c,i,z,g]=this.#Ka.subarray(12,18),this.#$a.push(((z+5*c)/6-n)/a,((g+5*i)/6-r)/o,((5*c+l)/6-n)/a,((5*i+s)/6-r)/o,((c+l)/2-n)/a,((i+s)/2-r)/o),!0))}toSVGPath(){if(this.isEmpty())return"";const e=this.#Ya,t=this.#$a;if(isNaN(this.#Ka[6])&&!this.isEmpty())return this.#io();const n=[];n.push(`M${e[4]} ${e[5]}`);for(let t=6;t<e.length;t+=6)isNaN(e[t])?n.push(`L${e[t+4]} ${e[t+5]}`):n.push(`C${e[t]} ${e[t+1]} ${e[t+2]} ${e[t+3]} ${e[t+4]} ${e[t+5]}`);this.#lo(n);for(let e=t.length-6;e>=6;e-=6)isNaN(t[e])?n.push(`L${t[e+4]} ${t[e+5]}`):n.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return this.#so(n),n.join(" ")}#io(){const[e,t,n,r]=this.#Wa,[a,o,c,i]=this.#co();return`M${(this.#Ka[2]-e)/n} ${(this.#Ka[3]-t)/r} L${(this.#Ka[4]-e)/n} ${(this.#Ka[5]-t)/r} L${a} ${o} L${c} ${i} L${(this.#Ka[16]-e)/n} ${(this.#Ka[17]-t)/r} L${(this.#Ka[14]-e)/n} ${(this.#Ka[15]-t)/r} Z`}#so(e){const t=this.#$a;e.push(`L${t[4]} ${t[5]} Z`)}#lo(e){const[t,n,r,a]=this.#Wa,o=this.#Ka.subarray(4,6),c=this.#Ka.subarray(16,18),[i,l,s,h]=this.#co();e.push(`L${(o[0]-t)/r} ${(o[1]-n)/a} L${i} ${l} L${s} ${h} L${(c[0]-t)/r} ${(c[1]-n)/a}`)}newFreeDrawOutline(e,t,n,r,a,o){return new sle(e,t,n,r,a,o)}getOutlines(){const e=this.#Ya,t=this.#$a,n=this.#Ka,[r,a,o,c]=this.#Wa,i=new Float32Array((this.#no?.length??0)+2);for(let e=0,t=i.length-2;e<t;e+=2)i[e]=(this.#no[e]-r)/o,i[e+1]=(this.#no[e+1]-a)/c;if(i[i.length-2]=(this.#Xa-r)/o,i[i.length-1]=(this.#Qa-a)/c,isNaN(n[6])&&!this.isEmpty())return this.#ho(i);const l=new Float32Array(this.#Ya.length+24+this.#$a.length);let s=e.length;for(let t=0;t<s;t+=2)isNaN(e[t])?l[t]=l[t+1]=NaN:(l[t]=e[t],l[t+1]=e[t+1]);s=this.#do(l,s);for(let e=t.length-6;e>=6;e-=6)for(let n=0;n<6;n+=2)isNaN(t[e+n])?(l[s]=l[s+1]=NaN,s+=2):(l[s]=t[e+n],l[s+1]=t[e+n+1],s+=2);return this.#uo(l,s),this.newFreeDrawOutline(l,i,this.#Wa,this.#eo,this.#qa,this.#Ga)}#ho(e){const t=this.#Ka,[n,r,a,o]=this.#Wa,[c,i,l,s]=this.#co(),h=new Float32Array(36);return h.set([NaN,NaN,NaN,NaN,(t[2]-n)/a,(t[3]-r)/o,NaN,NaN,NaN,NaN,(t[4]-n)/a,(t[5]-r)/o,NaN,NaN,NaN,NaN,c,i,NaN,NaN,NaN,NaN,l,s,NaN,NaN,NaN,NaN,(t[16]-n)/a,(t[17]-r)/o,NaN,NaN,NaN,NaN,(t[14]-n)/a,(t[15]-r)/o],0),this.newFreeDrawOutline(h,e,this.#Wa,this.#eo,this.#qa,this.#Ga)}#uo(e,t){const n=this.#$a;return e.set([NaN,NaN,NaN,NaN,n[4],n[5]],t),t+6}#do(e,t){const n=this.#Ka.subarray(4,6),r=this.#Ka.subarray(16,18),[a,o,c,i]=this.#Wa,[l,s,h,d]=this.#co();return e.set([NaN,NaN,NaN,NaN,(n[0]-a)/c,(n[1]-o)/i,NaN,NaN,NaN,NaN,l,s,NaN,NaN,NaN,NaN,h,d,NaN,NaN,NaN,NaN,(r[0]-a)/c,(r[1]-o)/i],t),t+24}}class sle extends ile{#Wa;#mo=new Float32Array(4);#qa;#Ga;#no;#eo;#po;constructor(e,t,n,r,a,o){super(),this.#po=e,this.#no=t,this.#Wa=n,this.#eo=r,this.#qa=a,this.#Ga=o,this.lastPoint=[NaN,NaN],this.#vo(o);const[c,i,l,s]=this.#mo;for(let t=0,n=e.length;t<n;t+=2)e[t]=(e[t]-c)/l,e[t+1]=(e[t+1]-i)/s;for(let e=0,n=t.length;e<n;e+=2)t[e]=(t[e]-c)/l,t[e+1]=(t[e+1]-i)/s}toSVGPath(){const e=[`M${this.#po[4]} ${this.#po[5]}`];for(let t=6,n=this.#po.length;t<n;t+=6)isNaN(this.#po[t])?e.push(`L${this.#po[t+4]} ${this.#po[t+5]}`):e.push(`C${this.#po[t]} ${this.#po[t+1]} ${this.#po[t+2]} ${this.#po[t+3]} ${this.#po[t+4]} ${this.#po[t+5]}`);return e.push("Z"),e.join(" ")}serialize([e,t,n,r],a){const o=n-e,c=r-t;let i,l;switch(a){case 0:i=ile._rescale(this.#po,e,r,o,-c),l=ile._rescale(this.#no,e,r,o,-c);break;case 90:i=ile._rescaleAndSwap(this.#po,e,t,o,c),l=ile._rescaleAndSwap(this.#no,e,t,o,c);break;case 180:i=ile._rescale(this.#po,n,t,-o,c),l=ile._rescale(this.#no,n,t,-o,c);break;case 270:i=ile._rescaleAndSwap(this.#po,n,r,-o,-c),l=ile._rescaleAndSwap(this.#no,n,r,-o,-c)}return{outline:Array.from(i),points:[Array.from(l)]}}#vo(e){const t=this.#po;let n=t[4],r=t[5],a=n,o=r,c=n,i=r,l=n,s=r;const h=e?Math.max:Math.min;for(let e=6,d=t.length;e<d;e+=6){if(isNaN(t[e]))a=Math.min(a,t[e+4]),o=Math.min(o,t[e+5]),c=Math.max(c,t[e+4]),i=Math.max(i,t[e+5]),s<t[e+5]?(l=t[e+4],s=t[e+5]):s===t[e+5]&&(l=h(l,t[e+4]));else{const d=Qae.bezierBoundingBox(n,r,...t.slice(e,e+6));a=Math.min(a,d[0]),o=Math.min(o,d[1]),c=Math.max(c,d[2]),i=Math.max(i,d[3]),s<d[3]?(l=d[2],s=d[3]):s===d[3]&&(l=h(l,d[2]))}n=t[e+4],r=t[e+5]}const d=this.#mo;d[0]=a-this.#qa,d[1]=o-this.#qa,d[2]=c-a+2*this.#qa,d[3]=i-o+2*this.#qa,this.lastPoint=[l,s]}get box(){return this.#mo}newOutliner(e,t,n,r,a,o=0){return new lle(e,t,n,r,a,o)}getNewOutline(e,t){const[n,r,a,o]=this.#mo,[c,i,l,s]=this.#Wa,h=a*l,d=o*s,u=n*l+c,m=r*s+i,p=this.newOutliner({x:this.#no[0]*h+u,y:this.#no[1]*d+m},this.#Wa,this.#eo,e,this.#Ga,t??this.#qa);for(let e=2;e<this.#no.length;e+=2)p.add({x:this.#no[e]*h+u,y:this.#no[e+1]*d+m});return p.getOutlines()}}class hle{#Wa;#fo;#zo=[];#go=[];constructor(e,t=0,n=0,r=!0){let a=1/0,o=-1/0,c=1/0,i=-1/0;const l=10**-4;for(const{x:n,y:r,width:s,height:h}of e){const e=Math.floor((n-t)/l)*l,d=Math.ceil((n+s+t)/l)*l,u=Math.floor((r-t)/l)*l,m=Math.ceil((r+h+t)/l)*l,p=[e,u,m,!0],v=[d,u,m,!1];this.#zo.push(p,v),a=Math.min(a,e),o=Math.max(o,d),c=Math.min(c,u),i=Math.max(i,m)}const s=o-a+2*n,h=i-c+2*n,d=a-n,u=c-n,m=this.#zo.at(r?-1:-2),p=[m[0],m[2]];for(const e of this.#zo){const[t,n,r]=e;e[0]=(t-d)/s,e[1]=(n-u)/h,e[2]=(r-u)/h}this.#Wa=new Float32Array([d,u,s,h]),this.#fo=p}getOutlines(){this.#zo.sort(((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]));const e=[];for(const t of this.#zo)t[3]?(e.push(...this.#yo(t)),this.#Mo(t)):(this.#Eo(t),e.push(...this.#yo(t)));return this.#bo(e)}#bo(e){const t=[],n=new Set;for(const n of e){const[e,r,a]=n;t.push([e,r,n],[e,a,n])}t.sort(((e,t)=>e[1]-t[1]||e[0]-t[0]));for(let e=0,r=t.length;e<r;e+=2){const r=t[e][2],a=t[e+1][2];r.push(a),a.push(r),n.add(r),n.add(a)}const r=[];let a;for(;n.size>0;){const e=n.values().next().value;let[t,o,c,i,l]=e;n.delete(e);let s=t,h=o;for(a=[t,c],r.push(a);;){let e;if(n.has(i))e=i;else{if(!n.has(l))break;e=l}n.delete(e),[t,o,c,i,l]=e,s!==t&&(a.push(s,h,t,h===o?o:c),s=t),h=h===o?c:o}a.push(s,h)}return new dle(r,this.#Wa,this.#fo)}#Ho(e){const t=this.#go;let n=0,r=t.length-1;for(;n<=r;){const a=n+r>>1,o=t[a][0];if(o===e)return a;o<e?n=a+1:r=a-1}return r+1}#Mo([,e,t]){const n=this.#Ho(e);this.#go.splice(n,0,[e,t])}#Eo([,e,t]){const n=this.#Ho(e);for(let r=n;r<this.#go.length;r++){const[n,a]=this.#go[r];if(n!==e)break;if(n===e&&a===t)return void this.#go.splice(r,1)}for(let r=n-1;r>=0;r--){const[n,a]=this.#go[r];if(n!==e)break;if(n===e&&a===t)return void this.#go.splice(r,1)}}#yo(e){const[t,n,r]=e,a=[[t,n,r]],o=this.#Ho(r);for(let e=0;e<o;e++){const[n,r]=this.#go[e];for(let e=0,o=a.length;e<o;e++){const[,c,i]=a[e];if(!(r<=c||i<=n))if(c>=n)if(i>r)a[e][1]=r;else{if(1===o)return[];a.splice(e,1),e--,o--}else a[e][2]=n,i>r&&a.push([t,r,i])}}return a}}class dle extends ile{#Wa;#Vo;constructor(e,t,n){super(),this.#Vo=e,this.#Wa=t,this.lastPoint=n}toSVGPath(){const e=[];for(const t of this.#Vo){let[n,r]=t;e.push(`M${n} ${r}`);for(let a=2;a<t.length;a+=2){const o=t[a],c=t[a+1];o===n?(e.push(`V${c}`),r=c):c===r&&(e.push(`H${o}`),n=o)}e.push("Z")}return e.join(" ")}serialize([e,t,n,r],a){const o=[],c=n-e,i=r-t;for(const t of this.#Vo){const n=new Array(t.length);for(let a=0;a<t.length;a+=2)n[a]=e+t[a]*c,n[a+1]=r-t[a+1]*i;o.push(n)}return o}get box(){return this.#Wa}get classNamesForOutlining(){return["highlightOutline"]}}class ule extends lle{newFreeDrawOutline(e,t,n,r,a,o){return new mle(e,t,n,r,a,o)}}class mle extends sle{newOutliner(e,t,n,r,a,o=0){return new ule(e,t,n,r,a,o)}}class ple{#Co=null;#Lo=null;#wo;#ko=null;#xo=!1;#So=!1;#o=null;#To;#Oo=null;#v=null;#Ao;static#Ro=null;static get _keyboardManager(){return Dae(this,"_keyboardManager",new koe([[["Escape","mac+Escape"],ple.prototype._hideDropdownFromKeyboard],[[" ","mac+ "],ple.prototype._colorSelectFromKeyboard],[["ArrowDown","ArrowRight","mac+ArrowDown","mac+ArrowRight"],ple.prototype._moveToNext],[["ArrowUp","ArrowLeft","mac+ArrowUp","mac+ArrowLeft"],ple.prototype._moveToPrevious],[["Home","mac+Home"],ple.prototype._moveToBeginning],[["End","mac+End"],ple.prototype._moveToEnd]]))}constructor({editor:e=null,uiManager:t=null}){e?(this.#So=!1,this.#Ao=Vae.HIGHLIGHT_COLOR,this.#o=e):(this.#So=!0,this.#Ao=Vae.HIGHLIGHT_DEFAULT_COLOR),this.#v=e?._uiManager||t,this.#To=this.#v._eventBus,this.#wo=e?.color||this.#v?.highlightColors.values().next().value||"#FFFF98",ple.#Ro||=Object.freeze({blue:"pdfjs-editor-colorpicker-blue",green:"pdfjs-editor-colorpicker-green",pink:"pdfjs-editor-colorpicker-pink",red:"pdfjs-editor-colorpicker-red",yellow:"pdfjs-editor-colorpicker-yellow"})}renderButton(){const e=this.#Co=document.createElement("button");e.className="colorPicker",e.tabIndex="0",e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-button"),e.setAttribute("aria-haspopup",!0);const t=this.#v._signal;e.addEventListener("click",this.#No.bind(this),{signal:t}),e.addEventListener("keydown",this.#Gr.bind(this),{signal:t});const n=this.#Lo=document.createElement("span");return n.className="swatch",n.setAttribute("aria-hidden",!0),n.style.backgroundColor=this.#wo,e.append(n),e}renderMainDropdown(){const e=this.#ko=this.#_o();return e.setAttribute("aria-orientation","horizontal"),e.setAttribute("aria-labelledby","highlightColorPickerLabel"),e}#_o(){const e=document.createElement("div"),t=this.#v._signal;e.addEventListener("contextmenu",moe,{signal:t}),e.className="dropdown",e.role="listbox",e.setAttribute("aria-multiselectable",!1),e.setAttribute("aria-orientation","vertical"),e.setAttribute("data-l10n-id","pdfjs-editor-colorpicker-dropdown");for(const[n,r]of this.#v.highlightColors){const a=document.createElement("button");a.tabIndex="0",a.role="option",a.setAttribute("data-color",r),a.title=n,a.setAttribute("data-l10n-id",ple.#Ro[n]);const o=document.createElement("span");a.append(o),o.className="swatch",o.style.backgroundColor=r,a.setAttribute("aria-selected",r===this.#wo),a.addEventListener("click",this.#Do.bind(this,r),{signal:t}),e.append(a)}return e.addEventListener("keydown",this.#Gr.bind(this),{signal:t}),e}#Do(e,t){t.stopPropagation(),this.#To.dispatch("switchannotationeditorparams",{source:this,type:this.#Ao,value:e})}_colorSelectFromKeyboard(e){if(e.target===this.#Co)return void this.#No(e);const t=e.target.getAttribute("data-color");t&&this.#Do(t,e)}_moveToNext(e){this.#Po?e.target!==this.#Co?e.target.nextSibling?.focus():this.#ko.firstChild?.focus():this.#No(e)}_moveToPrevious(e){e.target!==this.#ko?.firstChild&&e.target!==this.#Co?(this.#Po||this.#No(e),e.target.previousSibling?.focus()):this.#Po&&this._hideDropdownFromKeyboard()}_moveToBeginning(e){this.#Po?this.#ko.firstChild?.focus():this.#No(e)}_moveToEnd(e){this.#Po?this.#ko.lastChild?.focus():this.#No(e)}#Gr(e){ple._keyboardManager.exec(this,e)}#No(e){if(this.#Po)return void this.hideDropdown();if(this.#xo=0===e.detail,this.#Oo||(this.#Oo=new AbortController,window.addEventListener("pointerdown",this.#s.bind(this),{signal:this.#v.combinedSignal(this.#Oo)})),this.#ko)return void this.#ko.classList.remove("hidden");const t=this.#ko=this.#_o();this.#Co.append(t)}#s(e){this.#ko?.contains(e.target)||this.hideDropdown()}hideDropdown(){this.#ko?.classList.add("hidden"),this.#Oo?.abort(),this.#Oo=null}get#Po(){return this.#ko&&!this.#ko.classList.contains("hidden")}_hideDropdownFromKeyboard(){this.#So||(this.#Po?(this.hideDropdown(),this.#Co.focus({preventScroll:!0,focusVisible:this.#xo})):this.#o?.unselect())}updateColor(e){if(this.#Lo&&(this.#Lo.style.backgroundColor=e),!this.#ko)return;const t=this.#v.highlightColors.values();for(const n of this.#ko.children)n.setAttribute("aria-selected",t.next().value===e)}destroy(){this.#Co?.remove(),this.#Co=null,this.#Lo=null,this.#ko?.remove(),this.#ko=null}}class vle extends Aoe{#Fo=null;#Io=0;#Bo;#jo=null;#a=null;#Uo=null;#Wo=null;#$o=0;#qo=null;#Go=null;#y=null;#Yo=!1;#fo=null;#Ko;#Xo=null;#Qo="";#to;#Jo="";static _defaultColor=null;static _defaultOpacity=1;static _defaultThickness=12;static _type="highlight";static _editorType=Hae.HIGHLIGHT;static _freeHighlightId=-1;static _freeHighlight=null;static _freeHighlightClipId="";static get _keyboardManager(){const e=vle.prototype;return Dae(this,"_keyboardManager",new koe([[["ArrowLeft","mac+ArrowLeft"],e._moveCaret,{args:[0]}],[["ArrowRight","mac+ArrowRight"],e._moveCaret,{args:[1]}],[["ArrowUp","mac+ArrowUp"],e._moveCaret,{args:[2]}],[["ArrowDown","mac+ArrowDown"],e._moveCaret,{args:[3]}]]))}constructor(e){super({...e,name:"highlightEditor"}),this.color=e.color||vle._defaultColor,this.#to=e.thickness||vle._defaultThickness,this.#Ko=e.opacity||vle._defaultOpacity,this.#Bo=e.boxes||null,this.#Jo=e.methodOfCreation||"",this.#Qo=e.text||"",this._isDraggable=!1,e.highlightId>-1?(this.#Yo=!0,this.#Zo(e),this.#ec()):this.#Bo&&(this.#Fo=e.anchorNode,this.#Io=e.anchorOffset,this.#Wo=e.focusNode,this.#$o=e.focusOffset,this.#tc(),this.#ec(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#Yo?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#to,methodOfCreation:this.#Jo}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#tc(){const e=new hle(this.#Bo,.001);this.#Go=e.getOutlines(),[this.x,this.y,this.width,this.height]=this.#Go.box;const t=new hle(this.#Bo,.0025,.001,"ltr"===this._uiManager.direction);this.#Uo=t.getOutlines();const{lastPoint:n}=this.#Uo;this.#fo=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#Zo({highlightOutlines:e,highlightId:t,clipPathId:n}){if(this.#Go=e,this.#Uo=e.getNewOutline(this.#to/2+1.5,.0025),t>=0)this.#y=t,this.#jo=n,this.parent.drawLayer.finalizeDraw(t,{bbox:e.box,path:{d:e.toSVGPath()}}),this.#Xo=this.parent.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:!0},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},!0);else if(this.parent){const t=this.parent.viewport.rotation;this.parent.drawLayer.updateProperties(this.#y,{bbox:vle.#nc(this.#Go.box,(t-this.rotation+360)%360),path:{d:e.toSVGPath()}}),this.parent.drawLayer.updateProperties(this.#Xo,{bbox:vle.#nc(this.#Uo.box,t),path:{d:this.#Uo.toSVGPath()}})}const[r,a,o,c]=e.box;switch(this.rotation){case 0:this.x=r,this.y=a,this.width=o,this.height=c;break;case 90:{const[e,t]=this.parentDimensions;this.x=a,this.y=1-r,this.width=o*t/e,this.height=c*e/t;break}case 180:this.x=1-r,this.y=1-a,this.width=o,this.height=c;break;case 270:{const[e,t]=this.parentDimensions;this.x=1-a,this.y=r,this.width=o*t/e,this.height=c*e/t;break}}const{lastPoint:i}=this.#Uo;this.#fo=[(i[0]-r)/o,(i[1]-a)/c]}static initialize(e,t){Aoe.initialize(e,t),vle._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case Vae.HIGHLIGHT_DEFAULT_COLOR:vle._defaultColor=t;break;case Vae.HIGHLIGHT_THICKNESS:vle._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#fo}updateParams(e,t){switch(e){case Vae.HIGHLIGHT_COLOR:this.#_a(t);break;case Vae.HIGHLIGHT_THICKNESS:this.#rc(t)}}static get defaultPropertiesToUpdate(){return[[Vae.HIGHLIGHT_DEFAULT_COLOR,vle._defaultColor],[Vae.HIGHLIGHT_THICKNESS,vle._defaultThickness]]}get propertiesToUpdate(){return[[Vae.HIGHLIGHT_COLOR,this.color||vle._defaultColor],[Vae.HIGHLIGHT_THICKNESS,this.#to||vle._defaultThickness],[Vae.HIGHLIGHT_FREE,this.#Yo]]}#_a(e){const t=(e,t)=>{this.color=e,this.#Ko=t,this.parent?.drawLayer.updateProperties(this.#y,{root:{fill:e,"fill-opacity":t}}),this.#a?.updateColor(e)},n=this.color,r=this.#Ko;this.addCommands({cmd:t.bind(this,e,vle._defaultOpacity),undo:t.bind(this,n,r),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#rc(e){const t=this.#to,n=e=>{this.#to=e,this.#ac(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:Vae.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}async addEditToolbar(){const e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#a=new ple({editor:this}),e.addColorPicker(this.#a)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#oc())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#oc())}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),e&&this.div.focus()}remove(){this.#cc(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?this.#cc():e&&(this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#ac(e){if(!this.#Yo)return;this.#Zo({highlightOutlines:this.#Go.getNewOutline(e/2)}),this.fixAndSetPosition();const[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#cc(){null!==this.#y&&this.parent&&(this.parent.drawLayer.remove(this.#y),this.#y=null,this.parent.drawLayer.remove(this.#Xo),this.#Xo=null)}#ec(e=this.parent){null===this.#y&&(({id:this.#y,clipPathId:this.#jo}=e.drawLayer.draw({bbox:this.#Go.box,root:{viewBox:"0 0 1 1",fill:this.color,"fill-opacity":this.#Ko},rootClass:{highlight:!0,free:this.#Yo},path:{d:this.#Go.toSVGPath()}},!1,!0)),this.#Xo=e.drawLayer.drawOutline({rootClass:{highlightOutline:!0,free:this.#Yo},bbox:this.#Uo.box,path:{d:this.#Uo.toSVGPath()}},this.#Yo),this.#qo&&(this.#qo.style.clipPath=this.#jo))}static#nc([e,t,n,r],a){switch(a){case 90:return[1-t-r,e,r,n];case 180:return[1-e-n,1-t-r,n,r];case 270:return[t,1-e-n,r,n]}return[e,t,n,r]}rotate(e){const{drawLayer:t}=this.parent;let n;this.#Yo?(e=(e-this.rotation+360)%360,n=vle.#nc(this.#Go.box,e)):n=vle.#nc([this.x,this.y,this.width,this.height],e),t.updateProperties(this.#y,{bbox:n,root:{"data-main-rotation":e}}),t.updateProperties(this.#Xo,{bbox:vle.#nc(this.#Uo.box,e),root:{"data-main-rotation":e}})}render(){if(this.div)return this.div;const e=super.render();this.#Qo&&(e.setAttribute("aria-label",this.#Qo),e.setAttribute("role","mark")),this.#Yo?e.classList.add("free"):this.div.addEventListener("keydown",this.#ic.bind(this),{signal:this._uiManager._signal});const t=this.#qo=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#jo;const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),Voe(this,this.#qo,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!0}})}pointerleave(){this.isSelected||this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1}})}#ic(e){vle._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#lc(!0);break;case 1:case 3:this.#lc(!1)}}#lc(e){if(!this.#Fo)return;const t=window.getSelection();e?t.setPosition(this.#Fo,this.#Io):t.setPosition(this.#Wo,this.#$o)}select(){super.select(),this.#Xo&&this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{hovered:!1,selected:!0}})}unselect(){super.unselect(),this.#Xo&&(this.parent?.drawLayer.updateProperties(this.#Xo,{rootClass:{selected:!1}}),this.#Yo||this.#lc(!1))}get _mustFixPosition(){return!this.#Yo}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.updateProperties(this.#y,{rootClass:{hidden:!e}}),this.parent.drawLayer.updateProperties(this.#Xo,{rootClass:{hidden:!e}}))}#oc(){return this.#Yo?this.rotation:0}#sc(){if(this.#Yo)return null;const[e,t]=this.pageDimensions,[n,r]=this.pageTranslation,a=this.#Bo,o=new Float32Array(8*a.length);let c=0;for(const{x:i,y:l,width:s,height:h}of a){const a=i*e+n,d=(1-l)*t+r;o[c]=o[c+4]=a,o[c+1]=o[c+3]=d,o[c+2]=o[c+6]=a+s*e,o[c+5]=o[c+7]=d-h*t,c+=8}return o}#hc(e){return this.#Go.serialize(e,this.#oc())}static startHighlighting(e,t,{target:n,x:r,y:a}){const{x:o,y:c,width:i,height:l}=n.getBoundingClientRect(),s=new AbortController,h=e.combinedSignal(s),d=t=>{s.abort(),this.#dc(e,t)};window.addEventListener("blur",d,{signal:h}),window.addEventListener("pointerup",d,{signal:h}),window.addEventListener("pointerdown",poe,{capture:!0,passive:!1,signal:h}),window.addEventListener("contextmenu",moe,{signal:h}),n.addEventListener("pointermove",this.#uc.bind(this,e),{signal:h}),this._freeHighlight=new ule({x:r,y:a},[o,c,i,l],e.scale,this._defaultThickness/2,t,.001),({id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:this._defaultColor,"fill-opacity":this._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:this._freeHighlight.toSVGPath()}},!0,!0))}static#uc(e,t){this._freeHighlight.add(t)&&e.drawLayer.updateProperties(this._freeHighlightId,{path:{d:this._freeHighlight.toSVGPath()}})}static#dc(e,t){this._freeHighlight.isEmpty()?e.drawLayer.remove(this._freeHighlightId):e.createAndAddNewEditor(t,!1,{highlightId:this._freeHighlightId,highlightOutlines:this._freeHighlight.getOutlines(),clipPathId:this._freeHighlightClipId,methodOfCreation:"main_toolbar"}),this._freeHighlightId=-1,this._freeHighlight=null,this._freeHighlightClipId=""}static async deserialize(e,t,n){let r=null;if(e instanceof Jie){const{data:{quadPoints:t,rect:n,rotation:a,id:o,color:c,opacity:i,popupRef:l},parent:{page:{pageNumber:s}}}=e;r=e={annotationType:Hae.HIGHLIGHT,color:Array.from(c),opacity:i,quadPoints:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:a,id:o,deleted:!1,popupRef:l}}else if(e instanceof Qie){const{data:{inkLists:t,rect:n,rotation:a,id:o,color:c,borderStyle:{rawWidth:i},popupRef:l},parent:{page:{pageNumber:s}}}=e;r=e={annotationType:Hae.HIGHLIGHT,color:Array.from(c),thickness:i,inkLists:t,boxes:null,pageIndex:s-1,rect:n.slice(0),rotation:a,id:o,deleted:!1,popupRef:l}}const{color:a,quadPoints:o,inkLists:c,opacity:i}=e,l=await super.deserialize(e,t,n);l.color=Qae.makeHexColor(...a),l.#Ko=i||1,c&&(l.#to=e.thickness),l.annotationElementId=e.id||null,l._initialData=r;const[s,h]=l.pageDimensions,[d,u]=l.pageTranslation;if(o){const e=l.#Bo=[];for(let t=0;t<o.length;t+=8)e.push({x:(o[t]-d)/s,y:1-(o[t+1]-u)/h,width:(o[t+2]-o[t])/s,height:(o[t+1]-o[t+5])/h});l.#tc(),l.#ec(),l.rotate(l.rotation)}else if(c){l.#Yo=!0;const e=c[0],n={x:e[0]-d,y:h-(e[1]-u)},r=new ule(n,[0,0,s,h],1,l.#to/2,!0,.001);for(let t=0,a=e.length;t<a;t+=2)n.x=e[t]-d,n.y=h-(e[t+1]-u),r.add(n);const{id:a,clipPathId:o}=t.drawLayer.draw({bbox:[0,0,1,1],root:{viewBox:"0 0 1 1",fill:l.color,"fill-opacity":l._defaultOpacity},rootClass:{highlight:!0,free:!0},path:{d:r.toSVGPath()}},!0,!0);l.#Zo({highlightOutlines:r.getOutlines(),highlightId:a,clipPathId:o}),l.#ec()}return l}serialize(e=!1){if(this.isEmpty()||e)return null;if(this.deleted)return this.serializeDeleted();const t=this.getRect(0,0),n=Aoe._colorManager.convert(this.color),r={annotationType:Hae.HIGHLIGHT,color:n,opacity:this.#Ko,thickness:this.#to,quadPoints:this.#sc(),outlines:this.#hc(t),pageIndex:this.pageIndex,rect:t,rotation:this.#oc(),structTreeParentId:this._structTreeParentId};return this.annotationElementId&&!this.#Ua(r)?null:(r.id=this.annotationElementId,r)}#Ua(e){const{color:t}=this._initialData;return e.color.some(((e,n)=>e!==t[n]))}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class fle{#mc=Object.create(null);updateProperty(e,t){this[e]=t,this.updateSVGProperty(e,t)}updateProperties(e){if(e)for(const[t,n]of Object.entries(e))this.updateProperty(t,n)}updateSVGProperty(e,t){this.#mc[e]=t}toSVGProperties(){const e=this.#mc;return this.#mc=Object.create(null),{root:e}}reset(){this.#mc=Object.create(null)}updateAll(e=this){this.updateProperties(e)}clone(){Rae("Not implemented")}}class zle extends Aoe{#pc=null;#vc;_drawId=null;static _currentDrawId=-1;static _currentParent=null;static#fc=null;static#zc=null;static#gc=null;static#yc=NaN;static#Mc=null;static#Ec=null;static#bc=NaN;static _INNER_MARGIN=3;constructor(e){super(e),this.#vc=e.mustBeCommitted||!1,e.drawOutlines&&(this.#Hc(e),this.#ec())}#Hc({drawOutlines:e,drawId:t,drawingOptions:n}){this.#pc=e,this._drawingOptions||=n,t>=0?(this._drawId=t,this.parent.drawLayer.finalizeDraw(t,e.defaultProperties)):this._drawId=this.#Vc(e,this.parent),this.#Cc(e.box)}#Vc(e,t){const{id:n}=t.drawLayer.draw(zle._mergeSVGProperties(this._drawingOptions.toSVGProperties(),e.defaultSVGProperties),!1,!1);return n}static _mergeSVGProperties(e,t){const n=new Set(Object.keys(e));for(const[r,a]of Object.entries(t))n.has(r)?Object.assign(e[r],a):e[r]=a;return e}static getDefaultDrawingOptions(e){Rae("Not implemented")}static get typesMap(){Rae("Not implemented")}static get isDrawer(){return!0}static get supportMultipleDrawings(){return!1}static updateDefaultParams(e,t){const n=this.typesMap.get(e);n&&this._defaultDrawingOptions.updateProperty(n,t),this._currentParent&&(zle.#fc.updateProperty(n,t),this._currentParent.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}updateParams(e,t){const n=this.constructor.typesMap.get(e);n&&this._updateProperty(e,n,t)}static get defaultPropertiesToUpdate(){const e=[],t=this._defaultDrawingOptions;for(const[n,r]of this.typesMap)e.push([n,t[r]]);return e}get propertiesToUpdate(){const e=[],{_drawingOptions:t}=this;for(const[n,r]of this.constructor.typesMap)e.push([n,t[r]]);return e}_updateProperty(e,t,n){const r=this._drawingOptions,a=r[t],o=e=>{r.updateProperty(t,e);const n=this.#pc.updateProperty(t,e);n&&this.#Cc(n),this.parent?.drawLayer.updateProperties(this._drawId,r.toSVGProperties())};this.addCommands({cmd:o.bind(this,n),undo:o.bind(this,a),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:e,overwriteIfSameType:!0,keepUndo:!0})}_onResizing(){this.parent?.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties(this.#pc.getPathResizingSVGProperties(this.#Lc()),{bbox:this.#wc()}))}_onResized(){this.parent?.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties(this.#pc.getPathResizedSVGProperties(this.#Lc()),{bbox:this.#wc()}))}_onTranslating(e,t){this.parent?.drawLayer.updateProperties(this._drawId,{bbox:this.#wc(e,t)})}_onTranslated(){this.parent?.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties(this.#pc.getPathTranslatedSVGProperties(this.#Lc(),this.parentDimensions),{bbox:this.#wc()}))}_onStartDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!0}})}_onStopDragging(){this.parent?.drawLayer.updateProperties(this._drawId,{rootClass:{moving:!1}})}commit(){super.commit(),this.disableEditMode(),this.disableEditing()}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}getBaseTranslation(){return[0,0]}get isResizable(){return!0}onceAdded(e){this.annotationElementId||this.parent.addUndoableEditor(this),this._isDraggable=!0,this.#vc&&(this.#vc=!1,this.commit(),this.parent.setSelected(this),e&&this.isOnScreen&&this.div.focus())}remove(){this.#cc(),super.remove()}rebuild(){this.parent&&(super.rebuild(),null!==this.div&&(this.#ec(),this.#Cc(this.#pc.box),this.isAttachedToDOM||this.parent.add(this)))}setParent(e){let t=!1;this.parent&&!e?(this._uiManager.removeShouldRescale(this),this.#cc()):e&&(this._uiManager.addShouldRescale(this),this.#ec(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),t&&this.select()}#cc(){null!==this._drawId&&this.parent&&(this.parent.drawLayer.remove(this._drawId),this._drawId=null,this._drawingOptions.reset())}#ec(e=this.parent){null!==this._drawId&&this.parent===e||(null===this._drawId?(this._drawingOptions.updateAll(),this._drawId=this.#Vc(this.#pc,e)):this.parent.drawLayer.updateParent(this._drawId,e.drawLayer))}#kc([e,t,n,r]){const{parentDimensions:[a,o],rotation:c}=this;switch(c){case 90:return[t,1-e,n*(o/a),r*(a/o)];case 180:return[1-e,1-t,n,r];case 270:return[1-t,e,n*(o/a),r*(a/o)];default:return[e,t,n,r]}}#Lc(){const{x:e,y:t,width:n,height:r,parentDimensions:[a,o],rotation:c}=this;switch(c){case 90:return[1-t,e,n*(a/o),r*(o/a)];case 180:return[1-e,1-t,n,r];case 270:return[t,1-e,n*(a/o),r*(o/a)];default:return[e,t,n,r]}}#Cc(e){if([this.x,this.y,this.width,this.height]=this.#kc(e),this.div){this.fixAndSetPosition();const[e,t]=this.parentDimensions;this.setDims(this.width*e,this.height*t)}this._onResized()}#wc(){const{x:e,y:t,width:n,height:r,rotation:a,parentRotation:o,parentDimensions:[c,i]}=this;switch((4*a+o)/90){case 1:return[1-t-r,e,r,n];case 2:return[1-e-n,1-t-r,n,r];case 3:return[t,1-e-n,r,n];case 4:return[e,t-n*(c/i),r*(i/c),n*(c/i)];case 5:return[1-t,e,n*(c/i),r*(i/c)];case 6:return[1-e-r*(i/c),1-t,r*(i/c),n*(c/i)];case 7:return[t-n*(c/i),1-e-r*(i/c),n*(c/i),r*(i/c)];case 8:return[e-n,t-r,n,r];case 9:return[1-t,e-n,r,n];case 10:return[1-e,1-t,n,r];case 11:return[t-r,1-e,r,n];case 12:return[e-r*(i/c),t,r*(i/c),n*(c/i)];case 13:return[1-t-n*(c/i),e-r*(i/c),n*(c/i),r*(i/c)];case 14:return[1-e,1-t-n*(c/i),r*(i/c),n*(c/i)];case 15:return[t,1-e,n*(c/i),r*(i/c)];default:return[e,t,n,r]}}rotate(){this.parent&&this.parent.drawLayer.updateProperties(this._drawId,zle._mergeSVGProperties({bbox:this.#wc()},this.#pc.updateRotation((this.parentRotation-this.rotation+360)%360)))}onScaleChanging(){this.parent&&this.#Cc(this.#pc.updateParentDimensions(this.parentDimensions,this.parent.scale))}static onScaleChangingWhenDrawing(){}render(){if(this.div)return this.div;const e=super.render();e.classList.add("draw");const t=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal";const[n,r]=this.parentDimensions;return this.setDims(this.width*n,this.height*r),this._uiManager.addShouldRescale(this),this.disableEditing(),e}static createDrawerInstance(e,t,n,r,a){Rae("Not implemented")}static startDrawing(e,t,n,r){const{target:a,offsetX:o,offsetY:c,pointerId:i,pointerType:l}=r;if(zle.#Mc&&zle.#Mc!==l)return;const{viewport:{rotation:s}}=e,{width:h,height:d}=a.getBoundingClientRect(),u=zle.#zc=new AbortController,m=e.combinedSignal(u);zle.#yc||=i,zle.#Mc??=l,window.addEventListener("pointerup",(e=>{zle.#yc===e.pointerId?this._endDraw(e):zle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointercancel",(e=>{zle.#yc===e.pointerId?this._currentParent.endDrawingSession():zle.#Ec?.delete(e.pointerId)}),{signal:m}),window.addEventListener("pointerdown",(e=>{zle.#Mc===e.pointerType&&((zle.#Ec||=new Set).add(e.pointerId),zle.#fc.isCancellable()&&(zle.#fc.removeLastElement(),zle.#fc.isEmpty()?this._currentParent.endDrawingSession(!0):this._endDraw(null)))}),{capture:!0,passive:!1,signal:m}),window.addEventListener("contextmenu",moe,{signal:m}),a.addEventListener("pointermove",this._drawMove.bind(this),{signal:m}),a.addEventListener("touchmove",(e=>{e.timeStamp===zle.#bc&&poe(e)}),{signal:m}),e.toggleDrawing(),t._editorUndoBar?.hide(),zle.#fc?e.drawLayer.updateProperties(this._currentDrawId,zle.#fc.startNew(o,c,h,d,s)):(t.updateUIForDefaultProperties(this),zle.#fc=this.createDrawerInstance(o,c,h,d,s),zle.#gc=this.getDefaultDrawingOptions(),this._currentParent=e,({id:this._currentDrawId}=e.drawLayer.draw(this._mergeSVGProperties(zle.#gc.toSVGProperties(),zle.#fc.defaultSVGProperties),!0,!1)))}static _drawMove(e){if(zle.#bc=-1,!zle.#fc)return;const{offsetX:t,offsetY:n,pointerId:r}=e;zle.#yc===r&&(zle.#Ec?.size>=1?this._endDraw(e):(this._currentParent.drawLayer.updateProperties(this._currentDrawId,zle.#fc.add(t,n)),zle.#bc=e.timeStamp,poe(e)))}static _cleanup(e){e&&(this._currentDrawId=-1,this._currentParent=null,zle.#fc=null,zle.#gc=null,zle.#Mc=null,zle.#bc=NaN),zle.#zc&&(zle.#zc.abort(),zle.#zc=null,zle.#yc=NaN,zle.#Ec=null)}static _endDraw(e){const t=this._currentParent;if(t)if(t.toggleDrawing(!0),this._cleanup(!1),e&&t.drawLayer.updateProperties(this._currentDrawId,zle.#fc.end(e.offsetX,e.offsetY)),this.supportMultipleDrawings){const e=zle.#fc,n=this._currentDrawId,r=e.getLastElement();t.addCommands({cmd:()=>{t.drawLayer.updateProperties(n,e.setLastElement(r))},undo:()=>{t.drawLayer.updateProperties(n,e.removeLastElement())},mustExec:!1,type:Vae.DRAW_STEP})}else this.endDrawing(!1)}static endDrawing(e){const t=this._currentParent;if(!t)return null;if(t.toggleDrawing(!0),t.cleanUndoStack(Vae.DRAW_STEP),!zle.#fc.isEmpty()){const{pageDimensions:[n,r],scale:a}=t,o=t.createAndAddNewEditor({offsetX:0,offsetY:0},!1,{drawId:this._currentDrawId,drawOutlines:zle.#fc.getOutlines(n*a,r*a,a,this._INNER_MARGIN),drawingOptions:zle.#gc,mustBeCommitted:!e});return this._cleanup(!0),o}return t.drawLayer.remove(this._currentDrawId),this._cleanup(!0),null}createDrawingOptions(e){}static deserializeDraw(e,t,n,r,a,o){Rae("Not implemented")}static async deserialize(e,t,n){const{rawDims:{pageWidth:r,pageHeight:a,pageX:o,pageY:c}}=t.viewport,i=this.deserializeDraw(o,c,r,a,this._INNER_MARGIN,e),l=await super.deserialize(e,t,n);return l.createDrawingOptions(e),l.#Hc({drawOutlines:i}),l.#ec(),l.onScaleChanging(),l.rotate(),l}serializeDraw(e){const[t,n]=this.pageTranslation,[r,a]=this.pageDimensions;return this.#pc.serialize([t,n,r,a],e)}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}static canCreateNewEmptyEditor(){return!1}}class gle{#Ka=new Float64Array(6);#za;#xc;#Rn;#to;#no;#Sc="";#Tc=0;#Vo=new yle;#Oc;#Ac;constructor(e,t,n,r,a,o){this.#Oc=n,this.#Ac=r,this.#Rn=a,this.#to=o,[e,t]=this.#Rc(e,t);const c=this.#za=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t],this.#xc=[{line:c,points:this.#no}],this.#Ka.set(c,0)}updateProperty(e,t){"stroke-width"===e&&(this.#to=t)}#Rc(e,t){return ile._normalizePoint(e,t,this.#Oc,this.#Ac,this.#Rn)}isEmpty(){return!this.#xc||0===this.#xc.length}isCancellable(){return this.#no.length<=10}add(e,t){[e,t]=this.#Rc(e,t);const[n,r,a,o]=this.#Ka.subarray(2,6),c=e-a,i=t-o;return Math.hypot(this.#Oc*c,this.#Ac*i)<=2?null:(this.#no.push(e,t),isNaN(n)?(this.#Ka.set([a,o,e,t],2),this.#za.push(NaN,NaN,NaN,NaN,e,t),{path:{d:this.toSVGPath()}}):(isNaN(this.#Ka[0])&&this.#za.splice(6,6),this.#Ka.set([n,r,a,o,e,t],0),this.#za.push(...ile.createBezierPoints(n,r,a,o,e,t)),{path:{d:this.toSVGPath()}}))}end(e,t){return this.add(e,t)||(2===this.#no.length?{path:{d:this.toSVGPath()}}:null)}startNew(e,t,n,r,a){this.#Oc=n,this.#Ac=r,this.#Rn=a,[e,t]=this.#Rc(e,t);const o=this.#za=[NaN,NaN,NaN,NaN,e,t];this.#no=[e,t];const c=this.#xc.at(-1);return c&&(c.line=new Float32Array(c.line),c.points=new Float32Array(c.points)),this.#xc.push({line:o,points:this.#no}),this.#Ka.set(o,0),this.#Tc=0,this.toSVGPath(),null}getLastElement(){return this.#xc.at(-1)}setLastElement(e){return this.#xc?(this.#xc.push(e),this.#za=e.line,this.#no=e.points,this.#Tc=0,{path:{d:this.toSVGPath()}}):this.#Vo.setLastElement(e)}removeLastElement(){if(!this.#xc)return this.#Vo.removeLastElement();this.#xc.pop(),this.#Sc="";for(let e=0,t=this.#xc.length;e<t;e++){const{line:t,points:n}=this.#xc[e];this.#za=t,this.#no=n,this.#Tc=0,this.toSVGPath()}return{path:{d:this.#Sc}}}toSVGPath(){const e=ile.svgRound(this.#za[4]),t=ile.svgRound(this.#za[5]);if(2===this.#no.length)return this.#Sc=`${this.#Sc} M ${e} ${t} Z`,this.#Sc;if(this.#no.length<=6){const n=this.#Sc.lastIndexOf("M");this.#Sc=`${this.#Sc.slice(0,n)} M ${e} ${t}`,this.#Tc=6}if(4===this.#no.length){const e=ile.svgRound(this.#za[10]),t=ile.svgRound(this.#za[11]);return this.#Sc=`${this.#Sc} L ${e} ${t}`,this.#Tc=12,this.#Sc}const n=[];0===this.#Tc&&(n.push(`M ${e} ${t}`),this.#Tc=6);for(let e=this.#Tc,t=this.#za.length;e<t;e+=6){const[t,r,a,o,c,i]=this.#za.slice(e,e+6).map(ile.svgRound);n.push(`C${t} ${r} ${a} ${o} ${c} ${i}`)}return this.#Sc+=n.join(" "),this.#Tc=this.#za.length,this.#Sc}getOutlines(e,t,n,r){const a=this.#xc.at(-1);return a.line=new Float32Array(a.line),a.points=new Float32Array(a.points),this.#Vo.build(this.#xc,e,t,n,this.#Rn,this.#to,r),this.#Ka=null,this.#za=null,this.#xc=null,this.#Sc=null,this.#Vo}get defaultSVGProperties(){return{root:{viewBox:"0 0 10000 10000"},rootClass:{draw:!0},bbox:[0,0,1,1]}}}class yle extends ile{#mo;#Nc=0;#qa;#xc;#Oc;#Ac;#_c;#Rn;#to;build(e,t,n,r,a,o,c){this.#Oc=t,this.#Ac=n,this.#_c=r,this.#Rn=a,this.#to=o,this.#qa=c??0,this.#xc=e,this.#Dc()}setLastElement(e){return this.#xc.push(e),{path:{d:this.toSVGPath()}}}removeLastElement(){return this.#xc.pop(),{path:{d:this.toSVGPath()}}}toSVGPath(){const e=[];for(const{line:t}of this.#xc)if(e.push(`M${ile.svgRound(t[4])} ${ile.svgRound(t[5])}`),6!==t.length)if(12!==t.length)for(let n=6,r=t.length;n<r;n+=6){const[r,a,o,c,i,l]=t.subarray(n,n+6).map(ile.svgRound);e.push(`C${r} ${a} ${o} ${c} ${i} ${l}`)}else e.push(`L${ile.svgRound(t[10])} ${ile.svgRound(t[11])}`);else e.push("Z");return e.join("")}serialize([e,t,n,r],a){const o=[],c=[],[i,l,s,h]=this.#Pc();let d,u,m,p,v,f,z,g,y;switch(this.#Rn){case 0:y=ile._rescale,d=e,u=t+r,m=n,p=-r,v=e+i*n,f=t+(1-l-h)*r,z=e+(i+s)*n,g=t+(1-l)*r;break;case 90:y=ile._rescaleAndSwap,d=e,u=t,m=n,p=r,v=e+l*n,f=t+i*r,z=e+(l+h)*n,g=t+(i+s)*r;break;case 180:y=ile._rescale,d=e+n,u=t,m=-n,p=r,v=e+(1-i-s)*n,f=t+l*r,z=e+(1-i)*n,g=t+(l+h)*r;break;case 270:y=ile._rescaleAndSwap,d=e+n,u=t+r,m=-n,p=-r,v=e+(1-l-h)*n,f=t+(1-i-s)*r,z=e+(1-l)*n,g=t+(1-i)*r}for(const{line:e,points:t}of this.#xc)o.push(y(e,d,u,m,p,a?new Array(e.length):null)),c.push(y(t,d,u,m,p,a?new Array(t.length):null));return{lines:o,points:c,rect:[v,f,z,g]}}static deserialize(e,t,n,r,a,{paths:{lines:o,points:c},rotation:i,thickness:l}){const s=[];let h,d,u,m,p;switch(i){case 0:p=ile._rescale,h=-e/n,d=t/r+1,u=1/n,m=-1/r;break;case 90:p=ile._rescaleAndSwap,h=-t/r,d=-e/n,u=1/r,m=1/n;break;case 180:p=ile._rescale,h=e/n+1,d=-t/r,u=-1/n,m=1/r;break;case 270:p=ile._rescaleAndSwap,h=t/r+1,d=e/n+1,u=-1/r,m=-1/n}if(!o){o=[];for(const e of c){const t=e.length;if(2===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1]]));continue}if(4===t){o.push(new Float32Array([NaN,NaN,NaN,NaN,e[0],e[1],NaN,NaN,NaN,NaN,e[2],e[3]]));continue}const n=new Float32Array(3*(t-2));o.push(n);let[r,a,c,i]=e.subarray(0,4);n.set([NaN,NaN,NaN,NaN,r,a],0);for(let o=4;o<t;o+=2){const t=e[o],l=e[o+1];n.set(ile.createBezierPoints(r,a,c,i,t,l),3*(o-2)),[r,a,c,i]=[c,i,t,l]}}}for(let e=0,t=o.length;e<t;e++)s.push({line:p(o[e].map((e=>e??NaN)),h,d,u,m),points:p(c[e].map((e=>e??NaN)),h,d,u,m)});const v=new yle;return v.build(s,n,r,1,i,l,a),v}#Fc(e=this.#to){const t=this.#qa+e/2*this.#_c;return this.#Rn%180==0?[t/this.#Oc,t/this.#Ac]:[t/this.#Ac,t/this.#Oc]}#Pc(){const[e,t,n,r]=this.#mo,[a,o]=this.#Fc(0);return[e+a,t+o,n-2*a,r-2*o]}#Dc(){const e=this.#mo=new Float32Array([1/0,1/0,-1/0,-1/0]);for(const{line:t}of this.#xc){if(t.length<=12){for(let n=4,r=t.length;n<r;n+=6){const[r,a]=t.subarray(n,n+2);e[0]=Math.min(e[0],r),e[1]=Math.min(e[1],a),e[2]=Math.max(e[2],r),e[3]=Math.max(e[3],a)}continue}let n=t[4],r=t[5];for(let a=6,o=t.length;a<o;a+=6){const[o,c,i,l,s,h]=t.subarray(a,a+6);Qae.bezierBoundingBox(n,r,o,c,i,l,s,h,e),n=s,r=h}}const[t,n]=this.#Fc();e[0]=Math.min(1,Math.max(0,e[0]-t)),e[1]=Math.min(1,Math.max(0,e[1]-n)),e[2]=Math.min(1,Math.max(0,e[2]+t)),e[3]=Math.min(1,Math.max(0,e[3]+n)),e[2]-=e[0],e[3]-=e[1]}get box(){return this.#mo}updateProperty(e,t){return"stroke-width"===e?this.#rc(t):null}#rc(e){const[t,n]=this.#Fc();this.#to=e;const[r,a]=this.#Fc(),[o,c]=[r-t,a-n],i=this.#mo;return i[0]-=o,i[1]-=c,i[2]+=2*o,i[3]+=2*c,i}updateParentDimensions([e,t],n){const[r,a]=this.#Fc();this.#Oc=e,this.#Ac=t,this.#_c=n;const[o,c]=this.#Fc(),i=o-r,l=c-a,s=this.#mo;return s[0]-=i,s[1]-=l,s[2]+=2*i,s[3]+=2*l,s}updateRotation(e){return this.#Nc=e,{path:{transform:this.rotationTransform}}}get viewBox(){return this.#mo.map(ile.svgRound).join(" ")}get defaultProperties(){const[e,t]=this.#mo;return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`}}}get rotationTransform(){const[,,e,t]=this.#mo;let n=0,r=0,a=0,o=0,c=0,i=0;switch(this.#Nc){case 90:r=t/e,a=-e/t,c=e;break;case 180:n=-1,o=-1,c=e,i=t;break;case 270:r=-t/e,a=e/t,i=t;break;default:return""}return`matrix(${n} ${r} ${a} ${o} ${ile.svgRound(c)} ${ile.svgRound(i)})`}getPathResizingSVGProperties([e,t,n,r]){const[a,o]=this.#Fc(),[c,i,l,s]=this.#mo;if(Math.abs(l-a)<=ile.PRECISION||Math.abs(s-o)<=ile.PRECISION){const a=e+n/2-(c+l/2),o=t+r/2-(i+s/2);return{path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`,transform:`${this.rotationTransform} translate(${a} ${o})`}}}const h=(n-2*a)/(l-2*a),d=(r-2*o)/(s-2*o),u=l/n,m=s/r;return{path:{"transform-origin":`${ile.svgRound(c)} ${ile.svgRound(i)}`,transform:`${this.rotationTransform} scale(${u} ${m}) translate(${ile.svgRound(a)} ${ile.svgRound(o)}) scale(${h} ${d}) translate(${ile.svgRound(-a)} ${ile.svgRound(-o)})`}}}getPathResizedSVGProperties([e,t,n,r]){const[a,o]=this.#Fc(),c=this.#mo,[i,l,s,h]=c;if(c[0]=e,c[1]=t,c[2]=n,c[3]=r,Math.abs(s-a)<=ile.PRECISION||Math.abs(h-o)<=ile.PRECISION){const a=e+n/2-(i+s/2),o=t+r/2-(l+h/2);for(const{line:e,points:t}of this.#xc)ile._translate(e,a,o,e),ile._translate(t,a,o,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}const d=(n-2*a)/(s-2*a),u=(r-2*o)/(h-2*o),m=-d*(i+a)+e+a,p=-u*(l+o)+t+o;if(1!==d||1!==u||0!==m||0!==p)for(const{line:e,points:t}of this.#xc)ile._rescale(e,m,p,d,u,e),ile._rescale(t,m,p,d,u,t);return{root:{viewBox:this.viewBox},path:{"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`,transform:this.rotationTransform||null,d:this.toSVGPath()}}}getPathTranslatedSVGProperties([e,t],n){const[r,a]=n,o=this.#mo,c=e-o[0],i=t-o[1];if(this.#Oc===r&&this.#Ac===a)for(const{line:e,points:t}of this.#xc)ile._translate(e,c,i,e),ile._translate(t,c,i,t);else{const e=this.#Oc/r,t=this.#Ac/a;this.#Oc=r,this.#Ac=a;for(const{line:n,points:r}of this.#xc)ile._rescale(n,c,i,e,t,n),ile._rescale(r,c,i,e,t,r);o[2]*=e,o[3]*=t}return o[0]=e,o[1]=t,{root:{viewBox:this.viewBox},path:{d:this.toSVGPath(),"transform-origin":`${ile.svgRound(e)} ${ile.svgRound(t)}`}}}get defaultSVGProperties(){const e=this.#mo;return{root:{viewBox:this.viewBox},rootClass:{draw:!0},path:{d:this.toSVGPath(),"transform-origin":`${ile.svgRound(e[0])} ${ile.svgRound(e[1])}`,transform:this.rotationTransform||null},bbox:e}}}class Mle extends fle{#Ic;constructor(e){super(),this.#Ic=e,super.updateProperties({fill:"none",stroke:Aoe._defaultLineColor,"stroke-opacity":1,"stroke-width":1,"stroke-linecap":"round","stroke-linejoin":"round","stroke-miterlimit":10})}updateSVGProperty(e,t){"stroke-width"===e&&(t??=this["stroke-width"],t*=this.#Ic.realScale),super.updateSVGProperty(e,t)}clone(){const e=new Mle(this.#Ic);return e.updateAll(this),e}}class Ele extends zle{static _type="ink";static _editorType=Hae.INK;static _defaultDrawingOptions=null;constructor(e){super({...e,name:"inkEditor"}),this._willKeepAspectRatio=!0}static initialize(e,t){Aoe.initialize(e,t),this._defaultDrawingOptions=new Mle(t.viewParameters)}static getDefaultDrawingOptions(e){const t=this._defaultDrawingOptions.clone();return t.updateProperties(e),t}static get supportMultipleDrawings(){return!0}static get typesMap(){return Dae(this,"typesMap",new Map([[Vae.INK_THICKNESS,"stroke-width"],[Vae.INK_COLOR,"stroke"],[Vae.INK_OPACITY,"stroke-opacity"]]))}static createDrawerInstance(e,t,n,r,a){return new gle(e,t,n,r,a,this._defaultDrawingOptions["stroke-width"])}static deserializeDraw(e,t,n,r,a,o){return yle.deserialize(e,t,n,r,a,o)}static async deserialize(e,t,n){let r=null;if(e instanceof Qie){const{data:{inkLists:t,rect:n,rotation:a,id:o,color:c,opacity:i,borderStyle:{rawWidth:l},popupRef:s},parent:{page:{pageNumber:h}}}=e;r=e={annotationType:Hae.INK,color:Array.from(c),thickness:l,opacity:i,paths:{points:t},boxes:null,pageIndex:h-1,rect:n.slice(0),rotation:a,id:o,deleted:!1,popupRef:s}}const a=await super.deserialize(e,t,n);return a.annotationElementId=e.id||null,a._initialData=r,a}onScaleChanging(){if(!this.parent)return;super.onScaleChanging();const{_drawId:e,_drawingOptions:t,parent:n}=this;t.updateSVGProperty("stroke-width"),n.drawLayer.updateProperties(e,t.toSVGProperties())}static onScaleChangingWhenDrawing(){const e=this._currentParent;e&&(super.onScaleChangingWhenDrawing(),this._defaultDrawingOptions.updateSVGProperty("stroke-width"),e.drawLayer.updateProperties(this._currentDrawId,this._defaultDrawingOptions.toSVGProperties()))}createDrawingOptions({color:e,thickness:t,opacity:n}){this._drawingOptions=Ele.getDefaultDrawingOptions({stroke:Qae.makeHexColor(...e),"stroke-width":t,"stroke-opacity":n})}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const{lines:t,points:n,rect:r}=this.serializeDraw(e),{_drawingOptions:{stroke:a,"stroke-opacity":o,"stroke-width":c}}=this,i={annotationType:Hae.INK,color:Aoe._colorManager.convert(a),opacity:o,thickness:c,paths:{lines:t,points:n},pageIndex:this.pageIndex,rect:r,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?i:this.annotationElementId&&!this.#Ua(i)?null:(i.id=this.annotationElementId,i)}#Ua(e){const{color:t,thickness:n,opacity:r,pageIndex:a}=this._initialData;return this._hasBeenMoved||this._hasBeenResized||e.color.some(((e,n)=>e!==t[n]))||e.thickness!==n||e.opacity!==r||e.pageIndex!==a}renderAnnotationElement(e){const{points:t,rect:n}=this.serializeDraw(!1);return e.updateEdited({rect:n,thickness:this._drawingOptions["stroke-width"],points:t}),null}}class ble extends Aoe{#Bc=null;#jc=null;#Uc=null;#Wc=null;#$c=null;#qc="";#Gc=null;#Yc=null;#Kc=!1;#Xc=!1;static _type="stamp";static _editorType=Hae.STAMP;constructor(e){super({...e,name:"stampEditor"}),this.#Wc=e.bitmapUrl,this.#$c=e.bitmapFile}static initialize(e,t){Aoe.initialize(e,t)}static get supportedTypes(){return Dae(this,"supportedTypes",["apng","avif","bmp","gif","jpeg","png","svg+xml","webp","x-icon"].map((e=>`image/${e}`)))}static get supportedTypesStr(){return Dae(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(Hae.STAMP,{bitmapFile:e.getAsFile()})}altTextFinish(){this._uiManager.useNewAltTextFlow&&(this.div.hidden=!1),super.altTextFinish()}get telemetryFinalData(){return{type:"stamp",hasAltText:!!this.altTextData?.altText}}static computeTelemetryFinalData(e){const t=e.get("hasAltText");return{hasAltText:t.get(!0)??0,hasNoAltText:t.get(!1)??0}}#Qc(e,t=!1){e?(this.#Bc=e.bitmap,t||(this.#jc=e.id,this.#Kc=e.isSvg),e.file&&(this.#qc=e.file.name),this.#Jc()):this.remove()}#Zc(){if(this.#Uc=null,this._uiManager.enableWaiting(!1),this.#Gc){if(this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Bc)return this._editToolbar.hide(),void this._uiManager.editAltText(this,!0);if(!this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&this.#Bc){this._reportTelemetry({action:"pdfjs.image.image_added",data:{alt_text_modal:!1,alt_text_type:"empty"}});try{this.mlGuessAltText()}catch{}}this.div.focus()}}async mlGuessAltText(e=null,t=!0){if(this.hasAltTextData())return null;const{mlManager:n}=this._uiManager;if(!n)throw new Error("No ML.");if(!await n.isEnabledFor("altText"))throw new Error("ML isn't enabled for alt text.");const{data:r,width:a,height:o}=e||this.copyCanvas(null,null,!0).imageData,c=await n.guess({name:"altText",request:{data:r,width:a,height:o,channels:r.length/(a*o)}});if(!c)throw new Error("No response from the AI service.");if(c.error)throw new Error("Error from the AI service.");if(c.cancel)return null;if(!c.output)throw new Error("No valid response from the AI service.");const i=c.output;return await this.setGuessedAltText(i),t&&!this.hasAltTextData()&&(this.altTextData={alt:i,decorative:!1}),i}#ei(){if(this.#jc)return this._uiManager.enableWaiting(!0),void this._uiManager.imageManager.getFromId(this.#jc).then((e=>this.#Qc(e,!0))).finally((()=>this.#Zc()));if(this.#Wc){const e=this.#Wc;return this.#Wc=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromUrl(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}if(this.#$c){const e=this.#$c;return this.#$c=null,this._uiManager.enableWaiting(!0),void(this.#Uc=this._uiManager.imageManager.getFromFile(e).then((e=>this.#Qc(e))).finally((()=>this.#Zc())))}const e=document.createElement("input");e.type="file",e.accept=ble.supportedTypesStr;const t=this._uiManager._signal;this.#Uc=new Promise((n=>{e.addEventListener("change",(async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);const t=await this._uiManager.imageManager.getFromFile(e.files[0]);this._reportTelemetry({action:"pdfjs.image.image_selected",data:{alt_text_modal:this._uiManager.useNewAltTextFlow}}),this.#Qc(t)}else this.remove();n()}),{signal:t}),e.addEventListener("cancel",(()=>{this.remove(),n()}),{signal:t})})).finally((()=>this.#Zc())),e.click()}remove(){this.#jc&&(this.#Bc=null,this._uiManager.imageManager.deleteId(this.#jc),this.#Gc?.remove(),this.#Gc=null,this.#Yc&&(clearTimeout(this.#Yc),this.#Yc=null)),super.remove()}rebuild(){this.parent?(super.rebuild(),null!==this.div&&(this.#jc&&null===this.#Gc&&this.#ei(),this.isAttachedToDOM||this.parent.add(this))):this.#jc&&this.#ei()}onceAdded(e){this._isDraggable=!0,e&&this.div.focus()}isEmpty(){return!(this.#Uc||this.#Bc||this.#Wc||this.#$c||this.#jc)}get isResizable(){return!0}render(){if(this.div)return this.div;let e,t;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.div.setAttribute("role","figure"),this.addAltTextButton(),this.#Bc?this.#Jc():this.#ei(),this.width&&!this.annotationElementId){const[n,r]=this.parentDimensions;this.setAt(e*n,t*r,this.width*n,this.height*r)}return this._uiManager.addShouldRescale(this),this.div}_onResized(){this.onScaleChanging()}onScaleChanging(){this.parent&&(null!==this.#Yc&&clearTimeout(this.#Yc),this.#Yc=setTimeout((()=>{this.#Yc=null,this.#ti()}),200))}#Jc(){const{div:e}=this;let{width:t,height:n}=this.#Bc;const[r,a]=this.pageDimensions,o=.75;if(this.width)t=this.width*r,n=this.height*a;else if(t>o*r||n>o*a){const e=Math.min(o*r/t,o*a/n);t*=e,n*=e}const[c,i]=this.parentDimensions;this.setDims(t*c/r,n*i/a),this._uiManager.enableWaiting(!1);const l=this.#Gc=document.createElement("canvas");l.setAttribute("role","img"),this.addContainer(l),this.width=t/r,this.height=n/a,this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,this._uiManager.useNewAltTextWhenAddingImage&&this._uiManager.useNewAltTextFlow&&!this.annotationElementId||(e.hidden=!1),this.#ti(),this.#Xc||(this.parent.addUndoableEditor(this),this.#Xc=!0),this._reportTelemetry({action:"inserted_image"}),this.#qc&&l.setAttribute("aria-label",this.#qc)}copyCanvas(e,t,n=!1){e||(e=224);const{width:r,height:a}=this.#Bc,o=new Eoe;let c=this.#Bc,i=r,l=a,s=null;if(t){if(r>t||a>t){const e=Math.min(t/r,t/a);i=Math.floor(r*e),l=Math.floor(a*e)}s=document.createElement("canvas");const e=s.width=Math.ceil(i*o.sx),n=s.height=Math.ceil(l*o.sy);this.#Kc||(c=this.#ni(e,n));const h=s.getContext("2d");h.filter=this._uiManager.hcmFilter;let d="white",u="#cfcfd8";"none"!==this._uiManager.hcmFilter?u="black":window.matchMedia?.("(prefers-color-scheme: dark)").matches&&(d="#8f8f9d",u="#42414d");const m=15,p=m*o.sx,v=m*o.sy,f=new OffscreenCanvas(2*p,2*v),z=f.getContext("2d");z.fillStyle=d,z.fillRect(0,0,2*p,2*v),z.fillStyle=u,z.fillRect(0,0,p,v),z.fillRect(p,v,p,v),h.fillStyle=h.createPattern(f,"repeat"),h.fillRect(0,0,e,n),h.drawImage(c,0,0,c.width,c.height,0,0,e,n)}let h=null;if(n){let t,n;if(o.symmetric&&c.width<e&&c.height<e)t=c.width,n=c.height;else if(c=this.#Bc,r>e||a>e){const o=Math.min(e/r,e/a);t=Math.floor(r*o),n=Math.floor(a*o),this.#Kc||(c=this.#ni(t,n))}const i=new OffscreenCanvas(t,n).getContext("2d",{willReadFrequently:!0});i.drawImage(c,0,0,c.width,c.height,0,0,t,n),h={width:t,height:n,data:i.getImageData(0,0,t,n).data}}return{canvas:s,width:i,height:l,imageData:h}}#ni(e,t){const{width:n,height:r}=this.#Bc;let a=n,o=r,c=this.#Bc;for(;a>2*e||o>2*t;){const n=a,r=o;a>2*e&&(a=a>=16384?Math.floor(a/2)-1:Math.ceil(a/2)),o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));const i=new OffscreenCanvas(a,o);i.getContext("2d").drawImage(c,0,0,n,r,0,0,a,o),c=i.transferToImageBitmap()}return c}#ti(){const[e,t]=this.parentDimensions,{width:n,height:r}=this,a=new Eoe,o=Math.ceil(n*e*a.sx),c=Math.ceil(r*t*a.sy),i=this.#Gc;if(!i||i.width===o&&i.height===c)return;i.width=o,i.height=c;const l=this.#Kc?this.#Bc:this.#ni(o,c),s=i.getContext("2d");s.filter=this._uiManager.hcmFilter,s.drawImage(l,0,0,l.width,l.height,0,0,o,c)}getImageForAltText(){return this.#Gc}#ri(e){if(e){if(this.#Kc){const e=this._uiManager.imageManager.getSvgUrl(this.#jc);if(e)return e}const e=document.createElement("canvas");return({width:e.width,height:e.height}=this.#Bc),e.getContext("2d").drawImage(this.#Bc,0,0),e.toDataURL()}if(this.#Kc){const[e,t]=this.pageDimensions,n=Math.round(this.width*e*roe.PDF_TO_CSS_UNITS),r=Math.round(this.height*t*roe.PDF_TO_CSS_UNITS),a=new OffscreenCanvas(n,r);return a.getContext("2d").drawImage(this.#Bc,0,0,this.#Bc.width,this.#Bc.height,0,0,n,r),a.transferToImageBitmap()}return structuredClone(this.#Bc)}static async deserialize(e,t,n){let r=null;if(e instanceof nle){const{data:{rect:a,rotation:o,id:c,structParent:i,popupRef:l},container:s,parent:{page:{pageNumber:h}}}=e,d=s.querySelector("canvas"),u=n.imageManager.getFromCanvas(s.id,d);d.remove();const m=(await t._structTree.getAriaAttributes(`${toe}${c}`))?.get("aria-label")||"";r=e={annotationType:Hae.STAMP,bitmapId:u.id,bitmap:u.bitmap,pageIndex:h-1,rect:a.slice(0),rotation:o,id:c,deleted:!1,accessibilityData:{decorative:!1,altText:m},isSvg:!1,structParent:i,popupRef:l}}const a=await super.deserialize(e,t,n),{rect:o,bitmap:c,bitmapUrl:i,bitmapId:l,isSvg:s,accessibilityData:h}=e;l&&n.imageManager.isValidId(l)?(a.#jc=l,c&&(a.#Bc=c)):a.#Wc=i,a.#Kc=s;const[d,u]=a.pageDimensions;return a.width=(o[2]-o[0])/d,a.height=(o[3]-o[1])/u,a.annotationElementId=e.id||null,h&&(a.altTextData=h),a._initialData=r,a.#Xc=!!r,a}serialize(e=!1,t=null){if(this.isEmpty())return null;if(this.deleted)return this.serializeDeleted();const n={annotationType:Hae.STAMP,bitmapId:this.#jc,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#Kc,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#ri(!0),n.accessibilityData=this.serializeAltText(!0),n;const{decorative:r,altText:a}=this.serializeAltText(!1);if(!r&&a&&(n.accessibilityData={type:"Figure",alt:a}),this.annotationElementId){const e=this.#Ua(n);if(e.isSame)return null;e.isSameAltText?delete n.accessibilityData:n.accessibilityData.structParent=this._initialData.structParent??-1}if(n.id=this.annotationElementId,null===t)return n;t.stamps||=new Map;const o=this.#Kc?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#jc)){if(this.#Kc){const e=t.stamps.get(this.#jc);o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=this.#ri(!1))}}else t.stamps.set(this.#jc,{area:o,serialized:n}),n.bitmap=this.#ri(!1);return n}#Ua(e){const{pageIndex:t,accessibilityData:{altText:n}}=this._initialData,r=e.pageIndex===t,a=(e.accessibilityData?.alt||"")===n;return{isSame:!this._hasBeenMoved&&!this._hasBeenResized&&r&&a,isSameAltText:a}}renderAnnotationElement(e){return e.updateEdited({rect:this.getRect(0,0)}),null}}class Hle{#La;#ai=!1;#oi=null;#ci=null;#ii=null;#li=new Map;#si=!1;#hi=!1;#di=!1;#ui=null;#mi=null;#pi=null;#vi=null;#v;static _initialized=!1;static#B=new Map([cle,Ele,ble,vle].map((e=>[e._editorType,e])));constructor({uiManager:e,pageIndex:t,div:n,structTreeLayer:r,accessibilityManager:a,annotationLayer:o,drawLayer:c,textLayer:i,viewport:l,l10n:s}){const h=[...Hle.#B.values()];if(!Hle._initialized){Hle._initialized=!0;for(const t of h)t.initialize(s,e)}e.registerEditorTypes(h),this.#v=e,this.pageIndex=t,this.div=n,this.#La=a,this.#oi=o,this.viewport=l,this.#pi=i,this.drawLayer=c,this._structTree=r,this.#v.addLayer(this)}get isEmpty(){return 0===this.#li.size}get isInvisible(){return this.isEmpty&&this.#v.getMode()===Hae.NONE}updateToolbar(e){this.#v.updateToolbar(e)}updateMode(e=this.#v.getMode()){switch(this.#fi(),e){case Hae.NONE:return this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),void this.disableClick();case Hae.INK:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick();break;case Hae.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);const{classList:t}=this.div;for(const n of Hle.#B.values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#pi?.div}setEditingState(e){this.#v.setEditingState(e)}addCommands(e){this.#v.addCommands(e)}cleanUndoStack(e){this.#v.cleanUndoStack(e)}toggleDrawing(e=!1){this.div.classList.toggle("drawing",!e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#oi?.div.classList.toggle("disabled",!e)}async enable(){this.#di=!0,this.div.tabIndex=0,this.togglePointerEvents(!0);const e=new Set;for(const t of this.#li.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#v.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!this.#oi)return void(this.#di=!1);const t=this.#oi.getEditableAnnotations();for(const n of t){if(n.hide(),this.#v.isDeletedAnnotationElement(n.data.id))continue;if(e.has(n.data.id))continue;const t=await this.deserialize(n);t&&(this.addOrRebuild(t),t.enableEditing())}this.#di=!1}disable(){this.#hi=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);const e=new Map,t=new Map;for(const n of this.#li.values())n.disableEditing(),n.annotationElementId&&(null===n.serialize()?(t.set(n.annotationElementId,n),this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()):e.set(n.annotationElementId,n));if(this.#oi){const n=this.#oi.getEditableAnnotations();for(const r of n){const{id:n}=r.data;if(this.#v.isDeletedAnnotationElement(n))continue;let a=t.get(n);a?(a.resetAnnotationElement(r),a.show(!1),r.show()):(a=e.get(n),a&&(this.#v.addChangedExistingAnnotation(a),a.renderAnnotationElement(r)&&a.show(!1)),r.show())}}this.#fi(),this.isEmpty&&(this.div.hidden=!0);const{classList:n}=this.div;for(const e of Hle.#B.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#hi=!1}getEditableAnnotation(e){return this.#oi?.getEditableAnnotation(e)||null}setActiveEditor(e){this.#v.getActive()!==e&&this.#v.setActiveEditor(e)}enableTextSelection(){if(this.div.tabIndex=-1,this.#pi?.div&&!this.#vi){this.#vi=new AbortController;const e=this.#v.combinedSignal(this.#vi);this.#pi.div.addEventListener("pointerdown",this.#zi.bind(this),{signal:e}),this.#pi.div.classList.add("highlighting")}}disableTextSelection(){this.div.tabIndex=0,this.#pi?.div&&this.#vi&&(this.#vi.abort(),this.#vi=null,this.#pi.div.classList.remove("highlighting"))}#zi(e){this.#v.unselectAll();const{target:t}=e;if(t===this.#pi.div||("img"===t.getAttribute("role")||t.classList.contains("endOfContent"))&&this.#pi.div.contains(t)){const{isMac:t}=Kae.platform;if(0!==e.button||e.ctrlKey&&t)return;this.#v.showAllEditors("highlight",!0,!0),this.#pi.div.classList.add("free"),this.toggleDrawing(),vle.startHighlighting(this,"ltr"===this.#v.direction,{target:this.#pi.div,x:e.x,y:e.y}),this.#pi.div.addEventListener("pointerup",(()=>{this.#pi.div.classList.remove("free"),this.toggleDrawing(!0)}),{once:!0,signal:this.#v._signal}),e.preventDefault()}}enableClick(){if(this.#ci)return;this.#ci=new AbortController;const e=this.#v.combinedSignal(this.#ci);this.div.addEventListener("pointerdown",this.pointerdown.bind(this),{signal:e});const t=this.pointerup.bind(this);this.div.addEventListener("pointerup",t,{signal:e}),this.div.addEventListener("pointercancel",t,{signal:e})}disableClick(){this.#ci?.abort(),this.#ci=null}attach(e){this.#li.set(e.id,e);const{annotationElementId:t}=e;t&&this.#v.isDeletedAnnotationElement(t)&&this.#v.removeDeletedAnnotationElement(e)}detach(e){this.#li.delete(e.id),this.#La?.removePointerInTextLayer(e.contentDiv),!this.#hi&&e.annotationElementId&&this.#v.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#v.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1}changeParent(e){e.parent!==this&&(e.parent&&e.annotationElementId&&(this.#v.addDeletedAnnotationElement(e.annotationElementId),Aoe.deleteAnnotationElement(e),e.annotationElementId=null),this.attach(e),e.parent?.detach(e),e.setParent(this),e.div&&e.isAttachedToDOM&&(e.div.remove(),this.div.append(e.div)))}add(e){if(e.parent!==this||!e.isAttachedToDOM){if(this.changeParent(e),this.#v.addEditor(e),this.attach(e),!e.isAttachedToDOM){const t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(!this.#di),this.#v.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;const{activeElement:t}=document;e.div.contains(t)&&!this.#ii&&(e._focusEventsAllowed=!1,this.#ii=setTimeout((()=>{this.#ii=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",(()=>{e._focusEventsAllowed=!0}),{once:!0,signal:this.#v._signal}),t.focus())}),0)),e._structTreeParentId=this.#La?.moveElementInDOM(this.div,e.div,e.contentDiv,!0)}addOrRebuild(e){e.needsToBeRebuilt()?(e.parent||=this,e.rebuild(),e.show()):this.add(e)}addUndoableEditor(e){this.addCommands({cmd:()=>e._uiManager.rebuild(e),undo:()=>{e.remove()},mustExec:!1})}getNextId(){return this.#v.getId()}get#gi(){return Hle.#B.get(this.#v.getMode())}combinedSignal(e){return this.#v.combinedSignal(e)}#yi(e){const t=this.#gi;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#gi?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#v.updateToolbar(e),this.#v.updateMode(e);const{offsetX:n,offsetY:r}=this.#Mi(),a=this.getNextId(),o=this.#yi({parent:this,id:a,x:n,y:r,uiManager:this.#v,isCentered:!0,...t});o&&this.add(o)}async deserialize(e){return await(Hle.#B.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#v))||null}createAndAddNewEditor(e,t,n={}){const r=this.getNextId(),a=this.#yi({parent:this,id:r,x:e.offsetX,y:e.offsetY,uiManager:this.#v,isCentered:t,...n});return a&&this.add(a),a}#Mi(){const{x:e,y:t,width:n,height:r}=this.div.getBoundingClientRect(),a=Math.max(0,e),o=Math.max(0,t),c=(a+Math.min(window.innerWidth,e+n))/2-e,i=(o+Math.min(window.innerHeight,t+r))/2-t,[l,s]=this.viewport.rotation%180==0?[c,i]:[i,c];return{offsetX:l,offsetY:s}}addNewEditor(){this.createAndAddNewEditor(this.#Mi(),!0)}setSelected(e){this.#v.setSelected(e)}toggleSelected(e){this.#v.toggleSelected(e)}unselect(e){this.#v.unselect(e)}pointerup(e){const{isMac:t}=Kae.platform;0!==e.button||e.ctrlKey&&t||e.target===this.div&&this.#si&&(this.#si=!1,this.#gi?.isDrawer&&this.#gi.supportMultipleDrawings||(this.#ai?this.#v.getMode()!==Hae.STAMP?this.createAndAddNewEditor(e,!1):this.#v.unselectAll():this.#ai=!0))}pointerdown(e){if(this.#v.getMode()===Hae.HIGHLIGHT&&this.enableTextSelection(),this.#si)return void(this.#si=!1);const{isMac:t}=Kae.platform;if(0!==e.button||e.ctrlKey&&t)return;if(e.target!==this.div)return;if(this.#si=!0,this.#gi?.isDrawer)return void this.startDrawingSession(e);const n=this.#v.getActive();this.#ai=!n||n.isEmpty()}startDrawingSession(e){if(this.div.focus(),this.#ui)return void this.#gi.startDrawing(this,this.#v,!1,e);this.#v.setCurrentDrawingSession(this),this.#ui=new AbortController;const t=this.#v.combinedSignal(this.#ui);this.div.addEventListener("blur",(({relatedTarget:e})=>{e&&!this.div.contains(e)&&(this.#mi=null,this.commitOrRemove())}),{signal:t}),this.#gi.startDrawing(this,this.#v,!1,e)}pause(e){if(e){const{activeElement:e}=document;this.div.contains(e)&&(this.#mi=e)}else this.#mi&&setTimeout((()=>{this.#mi?.focus(),this.#mi=null}),0)}endDrawingSession(e=!1){return this.#ui?(this.#v.setCurrentDrawingSession(null),this.#ui.abort(),this.#ui=null,this.#mi=null,this.#gi.endDrawing(e)):null}findNewParent(e,t,n){const r=this.#v.findParent(t,n);return null!==r&&r!==this&&(r.changeParent(e),!0)}commitOrRemove(){return!!this.#ui&&(this.endDrawingSession(),!0)}onScaleChanging(){this.#ui&&this.#gi.onScaleChangingWhenDrawing(this)}destroy(){this.commitOrRemove(),this.#v.getActive()?.parent===this&&(this.#v.commitOrRemove(),this.#v.setActiveEditor(null)),this.#ii&&(clearTimeout(this.#ii),this.#ii=null);for(const e of this.#li.values())this.#La?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#li.clear(),this.#v.removeLayer(this)}#fi(){for(const e of this.#li.values())e.isEmpty()&&e.remove()}render({viewport:e}){this.viewport=e,Moe(this.div,e);for(const e of this.#v.getEditors(this.pageIndex))this.add(e),e.rebuild();this.updateMode()}update({viewport:e}){this.#v.commitOrRemove(),this.#fi();const t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,Moe(this.div,{rotation:n}),t!==n)for(const e of this.#li.values())e.rotate(n)}get pageDimensions(){const{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#v.viewParameters.realScale}}class Vle{#aa=null;#y=0;#Ei=new Map;#bi=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(this.#aa){if(this.#aa!==e){if(this.#Ei.size>0)for(const t of this.#Ei.values())t.remove(),e.append(t);this.#aa=e}}else this.#aa=e}static get _svgFactory(){return Dae(this,"_svgFactory",new Lie)}static#Hi(e,[t,n,r,a]){const{style:o}=e;o.top=100*n+"%",o.left=100*t+"%",o.width=100*r+"%",o.height=100*a+"%"}#Vi(){const e=Vle._svgFactory.create(1,1,!0);return this.#aa.append(e),e.setAttribute("aria-hidden",!0),e}#Ci(e,t){const n=Vle._svgFactory.createElement("clipPath");e.append(n);const r=`clip_${t}`;n.setAttribute("id",r),n.setAttribute("clipPathUnits","objectBoundingBox");const a=Vle._svgFactory.createElement("use");return n.append(a),a.setAttribute("href",`#${t}`),a.classList.add("clip"),r}#Li(e,t){for(const[n,r]of Object.entries(t))null===r?e.removeAttribute(n):e.setAttribute(n,r)}draw(e,t=!1,n=!1){const r=this.#y++,a=this.#Vi(),o=Vle._svgFactory.createElement("defs");a.append(o);const c=Vle._svgFactory.createElement("path");o.append(c);const i=`path_p${this.pageIndex}_${r}`;c.setAttribute("id",i),c.setAttribute("vector-effect","non-scaling-stroke"),t&&this.#bi.set(r,c);const l=n?this.#Ci(o,i):null,s=Vle._svgFactory.createElement("use");return a.append(s),s.setAttribute("href",`#${i}`),this.updateProperties(a,e),this.#Ei.set(r,a),{id:r,clipPathId:`url(#${l})`}}drawOutline(e,t){const n=this.#y++,r=this.#Vi(),a=Vle._svgFactory.createElement("defs");r.append(a);const o=Vle._svgFactory.createElement("path");a.append(o);const c=`path_p${this.pageIndex}_${n}`;let i;if(o.setAttribute("id",c),o.setAttribute("vector-effect","non-scaling-stroke"),t){const e=Vle._svgFactory.createElement("mask");a.append(e),i=`mask_p${this.pageIndex}_${n}`,e.setAttribute("id",i),e.setAttribute("maskUnits","objectBoundingBox");const t=Vle._svgFactory.createElement("rect");e.append(t),t.setAttribute("width","1"),t.setAttribute("height","1"),t.setAttribute("fill","white");const r=Vle._svgFactory.createElement("use");e.append(r),r.setAttribute("href",`#${c}`),r.setAttribute("stroke","none"),r.setAttribute("fill","black"),r.setAttribute("fill-rule","nonzero"),r.classList.add("mask")}const l=Vle._svgFactory.createElement("use");r.append(l),l.setAttribute("href",`#${c}`),i&&l.setAttribute("mask",`url(#${i})`);const s=l.cloneNode();return r.append(s),l.classList.add("mainOutline"),s.classList.add("secondaryOutline"),this.updateProperties(r,e),this.#Ei.set(n,r),n}finalizeDraw(e,t){this.#bi.delete(e),this.updateProperties(e,t)}updateProperties(e,t){if(!t)return;const{root:n,bbox:r,rootClass:a,path:o}=t,c="number"==typeof e?this.#Ei.get(e):e;if(c){if(n&&this.#Li(c,n),r&&Vle.#Hi(c,r),a){const{classList:e}=c;for(const[t,n]of Object.entries(a))e.toggle(t,n)}if(o){const e=c.firstChild.firstChild;this.#Li(e,o)}}}updateParent(e,t){if(t===this)return;const n=this.#Ei.get(e);n&&(t.#aa.append(n),this.#Ei.delete(e),t.#Ei.set(e,n))}remove(e){this.#bi.delete(e),null!==this.#aa&&(this.#Ei.get(e).remove(),this.#Ei.delete(e))}destroy(){this.#aa=null;for(const e of this.#Ei.values())e.remove();this.#Ei.clear(),this.#bi.clear()}}globalThis.pdfjsTestingUtils={HighlightOutliner:hle};var Cle=zae.GlobalWorkerOptions,Lle=zae.TextLayer,wle=zae.getDocument;function kle(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&r.firstChild?r.insertBefore(a,r.firstChild):r.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}kle('.messageBar{--closing-button-icon:url(images/messageBar_closingButton.svg);--message-bar-close-button-color:var(--text-primary-color);--message-bar-close-button-color-hover:var(--text-primary-color);--message-bar-close-button-border-radius:4px;--message-bar-close-button-border:none;--message-bar-close-button-hover-bg-color:#15141a24;--message-bar-close-button-active-bg-color:#15141a36;--message-bar-close-button-focus-bg-color:#15141a12}@media (prefers-color-scheme:dark){.messageBar{--message-bar-close-button-hover-bg-color:#fbfbfe24;--message-bar-close-button-active-bg-color:#fbfbfe36;--message-bar-close-button-focus-bg-color:#fbfbfe12}}@media screen and (forced-colors:active){.messageBar{--message-bar-close-button-color:ButtonText;--message-bar-close-button-border:1px solid ButtonText;--message-bar-close-button-hover-bg-color:ButtonText;--message-bar-close-button-active-bg-color:ButtonText;--message-bar-close-button-focus-bg-color:ButtonText;--message-bar-close-button-color-hover:HighlightText}}.messageBar{align-items:center;background:var(--message-bar-bg-color);border:1px solid var(--message-bar-border-color);border-radius:4px;color:var(--message-bar-fg-color);display:flex;flex-direction:column;gap:8px;justify-content:center;padding:8px 8px 8px 16px;position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none}.messageBar>div{align-items:flex-start;align-self:stretch;display:flex;gap:8px}:is(.messageBar>div):before{background-color:var(--message-bar-icon-color);content:"";display:inline-block;flex-shrink:0;height:16px;-webkit-mask-image:var(--message-bar-icon);mask-image:var(--message-bar-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}.messageBar button{cursor:pointer}:is(.messageBar button):focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}.messageBar .closeButton{align-items:center;background:none;border:var(--message-bar-close-button-border);border-radius:var(--message-bar-close-button-border-radius);display:flex;height:32px;justify-content:center;width:32px}:is(.messageBar .closeButton):before{background-color:var(--message-bar-close-button-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--closing-button-icon);mask-image:var(--closing-button-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.messageBar .closeButton):is(:hover,:active,:focus):before{background-color:var(--message-bar-close-button-color-hover)}:is(.messageBar .closeButton):hover{background-color:var(--message-bar-close-button-hover-bg-color)}:is(.messageBar .closeButton):active{background-color:var(--message-bar-close-button-active-bg-color)}:is(.messageBar .closeButton):focus{background-color:var(--message-bar-close-button-focus-bg-color)}:is(.messageBar .closeButton)>span{display:inline-block;height:0;overflow:hidden;width:0}#editorUndoBar{--text-primary-color:#15141a;--message-bar-icon:url(images/secondaryToolbarButton-documentProperties.svg);--message-bar-icon-color:#0060df;--message-bar-bg-color:#deeafc;--message-bar-fg-color:var(--text-primary-color);--message-bar-border-color:#00000014;--undo-button-bg-color:#15141a12;--undo-button-bg-color-hover:#15141a24;--undo-button-bg-color-active:#15141a36;--undo-button-fg-color:var(--message-bar-fg-color);--undo-button-fg-color-hover:var(--undo-button-fg-color);--undo-button-fg-color-active:var(--undo-button-fg-color);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color)}@media (prefers-color-scheme:dark){#editorUndoBar{--text-primary-color:#fbfbfe;--message-bar-icon-color:#73a7f3;--message-bar-bg-color:#003070;--message-bar-border-color:#ffffff14;--undo-button-bg-color:#ffffff14;--undo-button-bg-color-hover:#ffffff24;--undo-button-bg-color-active:#ffffff36}}@media screen and (forced-colors:active){#editorUndoBar{--text-primary-color:CanvasText;--message-bar-icon-color:CanvasText;--message-bar-bg-color:Canvas;--message-bar-border-color:CanvasText;--undo-button-bg-color:ButtonText;--undo-button-bg-color-hover:SelectedItem;--undo-button-bg-color-active:SelectedItem;--undo-button-fg-color:ButtonFace;--undo-button-fg-color-hover:SelectedItemText;--undo-button-fg-color-active:SelectedItemText;--focus-ring-color:CanvasText}}#editorUndoBar{cursor:default;font:menu;font-size:15px;left:50%;padding-block:8px;padding-inline:16px 8px;position:fixed;top:50px;transform:translateX(-50%);z-index:10}#editorUndoBar button{cursor:pointer}#editorUndoBar #editorUndoBarUndoButton{background-color:var(--undo-button-bg-color);border:none;border-radius:4px;color:var(--undo-button-fg-color);font-weight:590;height:32px;line-height:19.5px;margin-inline-start:8px;padding:4px 16px}:is(#editorUndoBar #editorUndoBarUndoButton):hover{background-color:var(--undo-button-bg-color-hover);color:var(--undo-button-fg-color-hover)}:is(#editorUndoBar #editorUndoBarUndoButton):active{background-color:var(--undo-button-bg-color-active);color:var(--undo-button-fg-color-active)}#editorUndoBar>div{align-items:center}.dialog{--dialog-bg-color:#fff;--dialog-border-color:#fff;--dialog-shadow:0 2px 14px 0 #3a394433;--text-primary-color:#15141a;--text-secondary-color:#5b5b66;--hover-filter:brightness(0.9);--focus-ring-color:#0060df;--focus-ring-outline:2px solid var(--focus-ring-color);--link-fg-color:#0060df;--link-hover-fg-color:#0250bb;--separator-color:#f0f0f4;--textarea-border-color:#8f8f9d;--textarea-bg-color:#fff;--textarea-fg-color:var(--text-secondary-color);--radio-bg-color:#f0f0f4;--radio-checked-bg-color:#fbfbfe;--radio-border-color:#8f8f9d;--radio-checked-border-color:#0060df;--button-secondary-bg-color:#f0f0f4;--button-secondary-fg-color:var(--text-primary-color);--button-secondary-border-color:var(--button-secondary-bg-color);--button-secondary-hover-bg-color:var(--button-secondary-bg-color);--button-secondary-hover-fg-color:var(--button-secondary-fg-color);--button-secondary-hover-border-color:var(--button-secondary-hover-bg-color);--button-primary-bg-color:#0060df;--button-primary-fg-color:#fbfbfe;--button-primary-border-color:var(--button-primary-bg-color);--button-primary-hover-bg-color:var(--button-primary-bg-color);--button-primary-hover-fg-color:var(--button-primary-fg-color);--button-primary-hover-border-color:var(--button-primary-hover-bg-color)}@media (prefers-color-scheme:dark){.dialog{--dialog-bg-color:#1c1b22;--dialog-border-color:#1c1b22;--dialog-shadow:0 2px 14px 0 #15141a;--text-primary-color:#fbfbfe;--text-secondary-color:#cfcfd8;--focus-ring-color:#0df;--hover-filter:brightness(1.4);--link-fg-color:#0df;--link-hover-fg-color:#80ebff;--separator-color:#52525e;--textarea-bg-color:#42414d;--radio-bg-color:#2b2a33;--radio-checked-bg-color:#15141a;--radio-checked-border-color:#0df;--button-secondary-bg-color:#2b2a33;--button-primary-bg-color:#0df;--button-primary-fg-color:#15141a}}@media screen and (forced-colors:active){.dialog{--dialog-bg-color:Canvas;--dialog-border-color:CanvasText;--dialog-shadow:none;--text-primary-color:CanvasText;--text-secondary-color:CanvasText;--hover-filter:none;--focus-ring-color:ButtonBorder;--link-fg-color:LinkText;--link-hover-fg-color:LinkText;--separator-color:CanvasText;--textarea-border-color:ButtonBorder;--textarea-bg-color:Field;--textarea-fg-color:ButtonText;--radio-bg-color:ButtonFace;--radio-checked-bg-color:ButtonFace;--radio-border-color:ButtonText;--radio-checked-border-color:ButtonText;--button-secondary-bg-color:ButtonFace;--button-secondary-fg-color:ButtonText;--button-secondary-border-color:ButtonText;--button-secondary-hover-bg-color:AccentColor;--button-secondary-hover-fg-color:AccentColorText;--button-primary-bg-color:ButtonText;--button-primary-fg-color:ButtonFace;--button-primary-hover-bg-color:AccentColor;--button-primary-hover-fg-color:AccentColorText}}.dialog{background:var(--dialog-bg-color);border:1px solid var(--dialog-border-color);border-radius:4px;box-shadow:var(--dialog-shadow);color:var(--text-primary-color);font:message-box;font-size:13px;font-weight:400;line-height:150%;padding:12px 16px}:is(.dialog .mainContainer) :focus-visible{outline:var(--focus-ring-outline);outline-offset:2px}:is(.dialog .mainContainer) .title{align-items:flex-start;display:flex;flex-direction:column;gap:12px;justify-content:flex-end;width:auto}:is(:is(.dialog .mainContainer) .title)>span{font-size:13px;font-style:normal;font-weight:590;line-height:150%}:is(.dialog .mainContainer) .dialogSeparator{border-bottom:none;border-top:1px solid var(--separator-color);height:0;margin-block:4px;width:100%}:is(.dialog .mainContainer) .dialogButtonsGroup{align-self:flex-end;display:flex;gap:12px}:is(.dialog .mainContainer) .radio{align-items:flex-start;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog .mainContainer) .radio)>.radioButton{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--radio-bg-color);border:1px solid var(--radio-border-color);border-radius:50%;box-sizing:border-box;height:16px;width:16px}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):hover{filter:var(--hover-filter)}:is(:is(:is(:is(.dialog .mainContainer) .radio)>.radioButton) input):checked{background-color:var(--radio-checked-bg-color);border:4px solid var(--radio-checked-border-color)}:is(:is(.dialog .mainContainer) .radio)>.radioLabel{align-items:flex-start;align-self:stretch;display:flex;gap:10px;padding-inline-start:24px}:is(:is(:is(.dialog .mainContainer) .radio)>.radioLabel)>span{color:var(--text-secondary-color);flex:1 0 0;font-size:11px}:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton)){border:1px solid;border-radius:4px;font:menu;font-weight:600;height:32px;padding:4px 16px;width:auto}:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{cursor:pointer;filter:var(--hover-filter)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-secondary-bg-color);border-color:var(--button-secondary-border-color);color:var(--button-secondary-fg-color)}.secondaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-secondary-hover-bg-color);border-color:var(--button-secondary-hover-border-color);color:var(--button-secondary-hover-fg-color)}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))){background-color:var(--button-primary-bg-color);border-color:var(--button-primary-border-color);color:var(--button-primary-fg-color);opacity:1}.primaryButton:is(:is(.dialog .mainContainer) button:not(:is(.toggle-button,.closeButton))):hover{background-color:var(--button-primary-hover-bg-color);border-color:var(--button-primary-hover-border-color);color:var(--button-primary-hover-fg-color)}:is(.dialog .mainContainer) a{color:var(--link-fg-color)}:is(:is(.dialog .mainContainer) a):hover{color:var(--link-hover-fg-color)}:is(.dialog .mainContainer) textarea{background:var(--textarea-bg-color);border:1px solid var(--textarea-border-color);border-radius:4px;box-sizing:border-box;color:var(--textarea-fg-color);font:inherit;margin:0;padding:8px;resize:none}:is(:is(.dialog .mainContainer) textarea):focus{border-color:#0000;outline-offset:0}:is(:is(.dialog .mainContainer) textarea):disabled{opacity:.4;pointer-events:none}:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#ffebcd;--message-bar-fg-color:#15141a;--message-bar-border-color:#00000014;--message-bar-icon:url(images/messageBar_warning.svg);--message-bar-icon-color:#cd411e}@media (prefers-color-scheme:dark){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:#5a3100;--message-bar-fg-color:#fbfbfe;--message-bar-border-color:#ffffff14;--message-bar-icon-color:#e49c49}}@media screen and (forced-colors:active){:is(.dialog .mainContainer) .messageBar{--message-bar-bg-color:HighlightText;--message-bar-fg-color:CanvasText;--message-bar-border-color:CanvasText;--message-bar-icon-color:CanvasText}}:is(.dialog .mainContainer) .messageBar{align-self:stretch}:is(:is(:is(.dialog .mainContainer) .messageBar)>div):before,:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{margin-block:4px}:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div{align-items:flex-start;display:flex;flex:1 0 0;flex-direction:column;gap:8px}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .title{font-size:13px;font-weight:590}:is(:is(:is(:is(.dialog .mainContainer) .messageBar)>div)>div) .description{font-size:13px}:is(.dialog .mainContainer) .toggler{align-items:center;align-self:stretch;display:flex;gap:8px}:is(:is(.dialog .mainContainer) .toggler)>.togglerLabel{-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer{-webkit-text-size-adjust:none;-moz-text-size-adjust:none;text-size-adjust:none;caret-color:CanvasText;forced-color-adjust:none;inset:0;line-height:1;opacity:1;overflow:clip;position:absolute;text-align:initial;transform-origin:0 0;z-index:0}.textLayer.highlighting{touch-action:none}.textLayer :is(span,br){color:#0000;cursor:text;position:absolute;transform-origin:0 0;white-space:pre}.textLayer .markedContent span:not(.markedContent),.textLayer>:not(.markedContent){z-index:1}.textLayer span.markedContent{height:0;top:0}.textLayer span[role=img]{cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none}.textLayer .highlight{--highlight-bg-color:#b400aa40;--highlight-selected-bg-color:#00640040;--highlight-backdrop-filter:none;--highlight-selected-backdrop-filter:none}@media screen and (forced-colors:active){.textLayer .highlight{--highlight-bg-color:#0000;--highlight-selected-bg-color:#0000;--highlight-backdrop-filter:var(--hcm-highlight-filter);--highlight-selected-backdrop-filter:var(\n --hcm-highlight-selected-filter\n )}}.textLayer .highlight{-webkit-backdrop-filter:var(--highlight-backdrop-filter);backdrop-filter:var(--highlight-backdrop-filter);background-color:var(--highlight-bg-color);border-radius:4px;margin:-1px;padding:1px}.appended:is(.textLayer .highlight){position:static}.begin:is(.textLayer .highlight){border-radius:4px 0 0 4px}.end:is(.textLayer .highlight){border-radius:0 4px 4px 0}.middle:is(.textLayer .highlight){border-radius:0}.selected:is(.textLayer .highlight){-webkit-backdrop-filter:var(--highlight-selected-backdrop-filter);backdrop-filter:var(--highlight-selected-backdrop-filter);background-color:var(--highlight-selected-bg-color)}.textLayer ::-moz-selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer ::selection{background:#0000ff40;background:color-mix(in srgb,AccentColor,#0000 75%)}.textLayer br::-moz-selection{background:#0000}.textLayer br::selection{background:#0000}.textLayer .endOfContent{cursor:default;display:block;inset:100% 0 0;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:0}.textLayer.selecting .endOfContent{top:0}.annotationLayer{--annotation-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--input-focus-border-color:Highlight;--input-focus-outline:1px solid Canvas;--input-unfocused-border-color:#0000;--input-disabled-border-color:#0000;--input-hover-border-color:#000;--link-outline:none}@media screen and (forced-colors:active){.annotationLayer{--input-focus-border-color:CanvasText;--input-unfocused-border-color:ActiveText;--input-disabled-border-color:GrayText;--input-hover-border-color:Highlight;--link-outline:1.5px solid LinkText}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid selectedItem}.annotationLayer .linkAnnotation{outline:var(--link-outline)}:is(.annotationLayer .linkAnnotation):hover{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter)}:is(.annotationLayer .linkAnnotation)>a:hover{background:none!important;box-shadow:none;opacity:0!important}.annotationLayer .popupAnnotation .popup{background-color:ButtonFace!important;color:ButtonText!important;outline:calc(1.5px*var(--scale-factor)) solid CanvasText!important}.annotationLayer .highlightArea:hover:after{-webkit-backdrop-filter:var(--hcm-highlight-filter);backdrop-filter:var(--hcm-highlight-filter);content:"";height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%}.annotationLayer .popupAnnotation.focused .popup{outline:calc(3px*var(--scale-factor)) solid Highlight!important}}.annotationLayer{left:0;pointer-events:none;position:absolute;top:0;transform-origin:0 0}.annotationLayer[data-main-rotation="90"] .norotate{transform:rotate(270deg) translateX(-100%)}.annotationLayer[data-main-rotation="180"] .norotate{transform:rotate(180deg) translate(-100%,-100%)}.annotationLayer[data-main-rotation="270"] .norotate{transform:rotate(90deg) translateY(-100%)}.annotationLayer.disabled .popup,.annotationLayer.disabled section{pointer-events:none}.annotationLayer .annotationContent{height:100%;pointer-events:none;position:absolute;width:100%}.freetext:is(.annotationLayer .annotationContent){background:#0000;border:none;font:10px sans-serif;inset:0;line-height:1.35;overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationLayer section{box-sizing:border-box;pointer-events:auto;position:absolute;text-align:initial;transform-origin:0 0}:is(.annotationLayer section):has(div.annotationContent) canvas.annotationContent{display:none}.textLayer.selecting~.annotationLayer section{pointer-events:none}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton)>a{font-size:1em;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer :is(.linkAnnotation,.buttonWidgetAnnotation.pushButton):not(.hasBorder)>a:hover{background-color:#ff0;box-shadow:0 2px 10px #ff0;opacity:.2}.annotationLayer .linkAnnotation.hasBorder:hover{background-color:#ff03}.annotationLayer .hasBorder{background-size:100% 100%}.annotationLayer .textAnnotation img{cursor:pointer;height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input,.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .textWidgetAnnotation :is(input,textarea){background-image:var(--annotation-unfocused-field-background);border:2px solid var(--input-unfocused-border-color);box-sizing:border-box;font:calc(9px*var(--scale-factor)) sans-serif;height:100%;margin:0;vertical-align:top;width:100%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:required,.annotationLayer .choiceWidgetAnnotation select:required,.annotationLayer .textWidgetAnnotation :is(input,textarea):required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select option{padding:0}.annotationLayer .buttonWidgetAnnotation.radioButton input{border-radius:50%}.annotationLayer .textWidgetAnnotation textarea{resize:none}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .textWidgetAnnotation [disabled]:is(input,textarea){background:none;border:2px solid var(--input-disabled-border-color);cursor:not-allowed}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .textWidgetAnnotation :is(input,textarea):hover{border-radius:2px}.annotationLayer .choiceWidgetAnnotation select:focus,.annotationLayer .textWidgetAnnotation :is(input,textarea):focus{background:none;border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) :focus{background-color:initial;background-image:none}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);border-radius:2px;outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{background-color:CanvasText;content:"";display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{height:80%;left:45%;width:1px}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before{transform:rotate(45deg)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{transform:rotate(-45deg)}.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{border-radius:50%;height:50%;left:25%;top:25%;width:50%}.annotationLayer .textWidgetAnnotation input.comb{font-family:monospace;padding-left:2px;padding-right:0}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation:is(.checkBox,.radioButton) input{-webkit-appearance:none;-moz-appearance:none;appearance:none}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{height:100%;width:100%}.annotationLayer .popupAnnotation{font-size:calc(9px*var(--scale-factor));height:auto;max-width:45%;pointer-events:none;position:absolute;width:-moz-max-content;width:max-content}.annotationLayer .popup{word-wrap:break-word;background-color:#ff9;border-radius:calc(2px*var(--scale-factor));box-shadow:0 calc(2px*var(--scale-factor)) calc(5px*var(--scale-factor)) #888;cursor:pointer;font:message-box;outline:1.5px solid #ffff4a;padding:calc(6px*var(--scale-factor));pointer-events:auto;white-space:normal}.annotationLayer .popupAnnotation.focused .popup{outline-width:3px}.annotationLayer .popup *{font-size:calc(9px*var(--scale-factor))}.annotationLayer .popup>.header{display:inline-block}.annotationLayer .popup>.header h1{display:inline}.annotationLayer .popup>.header .popupDate{display:inline-block;margin-left:calc(5px*var(--scale-factor));width:-moz-fit-content;width:fit-content}.annotationLayer .popupContent{border-top:1px solid #333;margin-top:calc(2px*var(--scale-factor));padding-top:calc(2px*var(--scale-factor))}.annotationLayer .richText>*{font-size:calc(9px*var(--scale-factor));white-space:pre-wrap}.annotationLayer .popupTriggerArea{cursor:pointer}.annotationLayer section svg{height:100%;left:0;position:absolute;top:0;width:100%}.annotationLayer .annotationTextContent{color:#0000;height:100%;opacity:0;pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100%}:is(.annotationLayer .annotationTextContent) span{display:inline-block;width:100%}.annotationLayer svg.quadrilateralsContainer{contain:strict;height:0;left:0;position:absolute;top:0;width:0;z-index:-1}:root{--xfa-unfocused-field-background:url(\'data:image/svg+xml;charset=utf-8,<svg width="1" height="1" xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="fill:rgba(0,54,255,.13)"/></svg>\');--xfa-focus-outline:auto}@media screen and (forced-colors:active){:root{--xfa-focus-outline:2px solid CanvasText}.xfaLayer :required{outline:1.5px solid selectedItem}}.xfaLayer{background-color:initial}.xfaLayer .highlight{background-color:#efcbed;border-radius:4px;margin:-1px;padding:1px}.xfaLayer .highlight.appended{position:static}.xfaLayer .highlight.begin{border-radius:4px 0 0 4px}.xfaLayer .highlight.end{border-radius:0 4px 4px 0}.xfaLayer .highlight.middle{border-radius:0}.xfaLayer .highlight.selected{background-color:#cbdfcb}.xfaPage{overflow:hidden;position:relative}.xfaContentarea{position:absolute}.xfaPrintOnly{display:none}.xfaLayer{left:0;line-height:1.2;position:absolute;text-align:initial;top:0;transform-origin:0 0}.xfaLayer *{background-color:initial;box-sizing:border-box;color:inherit;font:inherit;font-kerning:inherit;font-style:inherit;font-weight:inherit;letter-spacing:-.01px;line-height:inherit;margin:0;padding:0;pointer-events:auto;text-align:inherit;text-decoration:inherit}.xfaLayer :required{outline:1.5px solid red}.xfaLayer div,.xfaLayer svg,.xfaLayer svg *{pointer-events:none}.xfaLayer a{color:blue}.xfaRich li{margin-left:3em}.xfaFont{color:#000;font-kerning:none;font-size:10px;font-style:normal;font-weight:400;letter-spacing:0;text-decoration:none;vertical-align:0}.xfaCaption{flex:0 0 auto;overflow:hidden}.xfaCaptionForCheckButton{flex:1 1 auto;overflow:hidden}.xfaLabel{height:100%;width:100%}.xfaLeft{flex-direction:row}.xfaLeft,.xfaRight{align-items:center;display:flex}.xfaRight{flex-direction:row-reverse}:is(.xfaLeft,.xfaRight)>:is(.xfaCaption,.xfaCaptionForCheckButton){max-height:100%}.xfaTop{flex-direction:column}.xfaBottom,.xfaTop{align-items:flex-start;display:flex}.xfaBottom{flex-direction:column-reverse}:is(.xfaTop,.xfaBottom)>:is(.xfaCaption,.xfaCaptionForCheckButton){width:100%}.xfaBorder{background-color:initial;pointer-events:none;position:absolute}.xfaWrapped{height:100%;width:100%}:is(.xfaTextfield,.xfaSelect):focus{background-color:initial;background-image:none;outline:var(--xfa-focus-outline);outline-offset:-1px}:is(.xfaCheckbox,.xfaRadio):focus{outline:var(--xfa-focus-outline)}.xfaSelect,.xfaTextfield{background-image:var(--xfa-unfocused-field-background);border:none;flex:1 1 auto;height:100%;resize:none;width:100%}.xfaSelect{padding-inline:2px}:is(.xfaTop,.xfaBottom)>:is(.xfaTextfield,.xfaSelect){flex:0 1 auto}.xfaButton{border:none;cursor:pointer;text-align:center}.xfaButton,.xfaLink{height:100%;width:100%}.xfaLink{left:0;position:absolute;top:0}.xfaCheckbox,.xfaRadio{border:none;flex:0 0 auto;height:100%;width:100%}.xfaRich{white-space:pre-wrap}.xfaImage,.xfaRich{height:100%;width:100%}.xfaImage{-o-object-fit:contain;object-fit:contain;-o-object-position:left top;object-position:left top}.xfaLrTb,.xfaRlTb,.xfaTb{flex-direction:column}.xfaLr,.xfaLrTb,.xfaRlTb,.xfaTb{align-items:stretch;display:flex}.xfaLr{flex-direction:row}.xfaRl{align-items:stretch;display:flex;flex-direction:row-reverse}.xfaTb>div{justify-content:left}.xfaArea,.xfaPosition{position:relative}.xfaValignMiddle{align-items:center;display:flex}.xfaTable{flex-direction:column}.xfaTable,.xfaTable .xfaRow{align-items:stretch;display:flex}.xfaTable .xfaRow{flex-direction:row}.xfaTable .xfaRlRow{align-items:stretch;display:flex;flex:1;flex-direction:row-reverse}.xfaTable .xfaRlRow>div{flex:1}:is(.xfaNonInteractive,.xfaDisabled,.xfaReadOnly) :is(input,textarea){background:initial}@media print{.xfaSelect,.xfaTextfield{background:#0000}.xfaSelect{-webkit-appearance:none;-moz-appearance:none;appearance:none;text-indent:1px;text-overflow:""}}.canvasWrapper svg{transform:none}.moving:is(.canvasWrapper svg){z-index:100000}[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="90"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,1,-1,0,1,0)}[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="180"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(-1,0,0,-1,1,1)}[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) mask,[data-main-rotation="270"]:is(.highlight:is(.canvasWrapper svg),.highlightOutline:is(.canvasWrapper svg)) use:not(.clip,.mask){transform:matrix(0,-1,1,0,0,1)}.draw:is(.canvasWrapper svg){mix-blend-mode:normal;position:absolute}.draw[data-draw-rotation="90"]:is(.canvasWrapper svg){transform:rotate(90deg)}.draw[data-draw-rotation="180"]:is(.canvasWrapper svg){transform:rotate(180deg)}.draw[data-draw-rotation="270"]:is(.canvasWrapper svg){transform:rotate(270deg)}.highlight:is(.canvasWrapper svg){--blend-mode:multiply}@media screen and (forced-colors:active){.highlight:is(.canvasWrapper svg){--blend-mode:difference}}.highlight:is(.canvasWrapper svg){mix-blend-mode:var(--blend-mode);position:absolute}.highlight:is(.canvasWrapper svg):not(.free){fill-rule:evenodd}.highlightOutline:is(.canvasWrapper svg){fill-rule:evenodd;fill:none;mix-blend-mode:normal;position:absolute}.highlightOutline.hovered:is(.canvasWrapper svg):not(.free):not(.selected){stroke:var(--hover-outline-color);stroke-width:var(--outline-width)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc(var(--outline-width) + var(--outline-around-width)*2)}.highlightOutline.selected:is(.canvasWrapper svg):not(.free) .secondaryOutline{stroke:var(--outline-color);stroke-width:var(--outline-width)}.highlightOutline.free.hovered:is(.canvasWrapper svg):not(.selected){stroke:var(--hover-outline-color);stroke-width:calc(var(--outline-width)*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .mainOutline{stroke:var(--outline-around-color);stroke-width:calc((var(--outline-width) + var(--outline-around-width))*2)}.highlightOutline.free.selected:is(.canvasWrapper svg) .secondaryOutline{stroke:var(--outline-color);stroke-width:calc(var(--outline-width)*2)}.toggle-button{--button-background-color:#f0f0f4;--button-background-color-hover:#e0e0e6;--button-background-color-active:#cfcfd8;--color-accent-primary:#0060df;--color-accent-primary-hover:#0250bb;--color-accent-primary-active:#054096;--border-interactive-color:#8f8f9d;--border-radius-circle:9999px;--border-width:1px;--size-item-small:16px;--size-item-large:32px;--color-canvas:#fff}@media (prefers-color-scheme:dark){.toggle-button{--button-background-color:color-mix(in srgb,currentColor 7%,#0000);--button-background-color-hover:color-mix(in srgb,currentColor 14%,#0000);--button-background-color-active:color-mix(in srgb,currentColor 21%,#0000);--color-accent-primary:#0df;--color-accent-primary-hover:#80ebff;--color-accent-primary-active:#aaf2ff;--border-interactive-color:#bfbfc9;--color-canvas:#1c1b22}}@media (forced-colors:active){.toggle-button{--color-accent-primary:ButtonText;--color-accent-primary-hover:SelectedItem;--color-accent-primary-active:SelectedItem;--border-interactive-color:ButtonText;--button-background-color:ButtonFace;--border-interactive-color-hover:SelectedItem;--border-interactive-color-active:SelectedItem;--border-interactive-color-disabled:GrayText;--color-canvas:ButtonText}}.toggle-button{--toggle-background-color:var(--button-background-color);--toggle-background-color-hover:var(--button-background-color-hover);--toggle-background-color-active:var(--button-background-color-active);--toggle-background-color-pressed:var(--color-accent-primary);--toggle-background-color-pressed-hover:var(--color-accent-primary-hover);--toggle-background-color-pressed-active:var(--color-accent-primary-active);--toggle-border-color:var(--border-interactive-color);--toggle-border-color-hover:var(--toggle-border-color);--toggle-border-color-active:var(--toggle-border-color);--toggle-border-radius:var(--border-radius-circle);--toggle-border-width:var(--border-width);--toggle-height:var(--size-item-small);--toggle-width:var(--size-item-large);--toggle-dot-background-color:var(--toggle-border-color);--toggle-dot-background-color-hover:var(--toggle-dot-background-color);--toggle-dot-background-color-active:var(--toggle-dot-background-color);--toggle-dot-background-color-on-pressed:var(--color-canvas);--toggle-dot-margin:1px;--toggle-dot-height:calc(var(--toggle-height) - var(--toggle-dot-margin)*2 - var(--toggle-border-width)*2);--toggle-dot-width:var(--toggle-dot-height);--toggle-dot-transform-x:calc(var(--toggle-width) - var(--toggle-dot-margin)*4 - var(--toggle-dot-width));-webkit-appearance:none;-moz-appearance:none;appearance:none;background:var(--toggle-background-color);border:var(--toggle-border-width) solid var(--toggle-border-color);border-radius:var(--toggle-border-radius);box-sizing:border-box;flex-shrink:0;height:var(--toggle-height);margin:0;padding:0;width:var(--toggle-width)}.toggle-button:focus-visible{outline:var(--focus-outline);outline-offset:var(--focus-outline-offset)}.toggle-button:enabled:hover{background:var(--toggle-background-color-hover);border-color:var(--toggle-border-color)}.toggle-button:enabled:active{background:var(--toggle-background-color-active);border-color:var(--toggle-border-color)}.toggle-button[aria-pressed=true]{background:var(--toggle-background-color-pressed);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:hover{background:var(--toggle-background-color-pressed-hover);border-color:#0000}.toggle-button[aria-pressed=true]:enabled:active{background:var(--toggle-background-color-pressed-active);border-color:#0000}.toggle-button:before{background-color:var(--toggle-dot-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-dot-height);margin:var(--toggle-dot-margin);translate:0;width:var(--toggle-dot-width)}.toggle-button[aria-pressed=true]:before{translate:var(--toggle-dot-transform-x)}.toggle-button[aria-pressed=true]:before,.toggle-button[aria-pressed=true]:enabled:active:before,.toggle-button[aria-pressed=true]:enabled:hover:before{background-color:var(--toggle-dot-background-color-on-pressed)}[dir=rtl] .toggle-button[aria-pressed=true]:before{translate:calc(var(--toggle-dot-transform-x)*-1)}@media (prefers-reduced-motion:no-preference){.toggle-button:before{transition:translate .1s}}@media (prefers-contrast){.toggle-button:enabled:hover{border-color:var(--toggle-border-color-hover)}.toggle-button:enabled:active{border-color:var(--toggle-border-color-active)}.toggle-button[aria-pressed=true]:enabled{border-color:var(--toggle-border-color);position:relative}.toggle-button[aria-pressed=true]:enabled:hover,.toggle-button[aria-pressed=true]:enabled:hover:active{border-color:var(--toggle-border-color-hover)}.toggle-button[aria-pressed=true]:enabled:active{background-color:var(--toggle-dot-background-color-active);border-color:var(--toggle-dot-background-color-hover)}.toggle-button:active:before,.toggle-button:hover:before{background-color:var(--toggle-dot-background-color-hover)}}@media (forced-colors){.toggle-button{--toggle-dot-background-color:var(--color-accent-primary);--toggle-dot-background-color-hover:var(--color-accent-primary-hover);--toggle-dot-background-color-active:var(--color-accent-primary-active);--toggle-dot-background-color-on-pressed:var(--button-background-color);--toggle-background-color-disabled:var(--button-background-color-disabled);--toggle-border-color-hover:var(--border-interactive-color-hover);--toggle-border-color-active:var(--border-interactive-color-active);--toggle-border-color-disabled:var(--border-interactive-color-disabled)}.toggle-button[aria-pressed=true]:enabled:after{border:1px solid var(--button-background-color);border-radius:var(--toggle-border-radius);content:"";display:block;height:var(--toggle-height);inset:-2px;position:absolute;width:var(--toggle-width)}.toggle-button[aria-pressed=true]:enabled:active:after{border-color:var(--toggle-border-color-active)}}:root{--outline-width:2px;--outline-color:#0060df;--outline-around-width:1px;--outline-around-color:#f0f0f4;--hover-outline-around-color:var(--outline-around-color);--focus-outline:solid var(--outline-width) var(--outline-color);--unfocus-outline:solid var(--outline-width) #0000;--focus-outline-around:solid var(--outline-around-width) var(--outline-around-color);--hover-outline-color:#8f8f9d;--hover-outline:solid var(--outline-width) var(--hover-outline-color);--hover-outline-around:solid var(--outline-around-width) var(--hover-outline-around-color);--freetext-line-height:1.35;--freetext-padding:2px;--resizer-bg-color:var(--outline-color);--resizer-size:6px;--resizer-shift:calc(0px - (var(--outline-width) + var(--resizer-size))/2 - var(--outline-around-width));--editorFreeText-editing-cursor:text;--editorInk-editing-cursor:url(images/cursor-editorInk.svg) 0 16,pointer;--editorHighlight-editing-cursor:url(images/cursor-editorTextHighlight.svg) 24 24,text;--editorFreeHighlight-editing-cursor:url(images/cursor-editorFreeHighlight.svg) 1 18,pointer;--new-alt-text-warning-image:url(images/altText_warning.svg)}.visuallyHidden{border:0;font-size:0;height:0;left:0;margin:0;overflow:hidden;padding:0;position:absolute;top:0;white-space:nowrap;width:0}.textLayer.highlighting{cursor:var(--editorFreeHighlight-editing-cursor)}.textLayer.highlighting:not(.free) span{cursor:var(--editorHighlight-editing-cursor)}.textLayer.highlighting.free span,[role=img]:is(.textLayer.highlighting:not(.free) span){cursor:var(--editorFreeHighlight-editing-cursor)}:is(#viewerContainer.pdfPresentationMode:fullscreen,.annotationEditorLayer.disabled) .noAltTextBadge{display:none!important}@media (min-resolution:1.1dppx){:root{--editorFreeText-editing-cursor:url(images/cursor-editorFreeText.svg) 0 16,text}}@media screen and (forced-colors:active){:root{--outline-color:CanvasText;--outline-around-color:ButtonFace;--resizer-bg-color:ButtonText;--hover-outline-color:Highlight;--hover-outline-around-color:SelectedItemText}}[data-editor-rotation="90"]{transform:rotate(90deg)}[data-editor-rotation="180"]{transform:rotate(180deg)}[data-editor-rotation="270"]{transform:rotate(270deg)}.annotationEditorLayer{background:#0000;cursor:auto;font-size:calc(100px*var(--scale-factor));inset:0;position:absolute;transform-origin:0 0}.annotationEditorLayer .selectedEditor{z-index:100000!important}.annotationEditorLayer.drawing *{pointer-events:none!important}.annotationEditorLayer.waiting{content:"";cursor:wait;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer.disabled{pointer-events:none}.annotationEditorLayer.freetextEditing{cursor:var(--editorFreeText-editing-cursor)}.annotationEditorLayer.inkEditing{cursor:var(--editorInk-editing-cursor)}.annotationEditorLayer .draw{box-sizing:border-box}.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor){background:#0000;border:var(--unfocus-outline);cursor:auto;max-height:100%;max-width:100%;position:absolute;transform-origin:0 0;z-index:1}.draggable.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){cursor:move}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)){border:var(--focus-outline);outline:var(--focus-outline-around)}.selectedEditor:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):before{border:var(--focus-outline-around);content:"";inset:0;pointer-events:none;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor){border:var(--hover-outline);outline:var(--hover-outline-around)}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor)):hover:not(.selectedEditor):before{border:var(--focus-outline-around);content:"";inset:0;position:absolute}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-delete-image:url(images/editor-toolbar-delete.svg);--editor-toolbar-bg-color:#f0f0f4;--editor-toolbar-highlight-image:url(images/toolbarButton-editorHighlight.svg);--editor-toolbar-fg-color:#2e2e56;--editor-toolbar-border-color:#8f8f9d;--editor-toolbar-hover-border-color:var(--editor-toolbar-border-color);--editor-toolbar-hover-bg-color:#e0e0e6;--editor-toolbar-hover-fg-color:var(--editor-toolbar-fg-color);--editor-toolbar-hover-outline:none;--editor-toolbar-focus-outline-color:#0060df;--editor-toolbar-shadow:0 2px 6px 0 #3a394433;--editor-toolbar-vert-offset:6px;--editor-toolbar-height:28px;--editor-toolbar-padding:2px;--alt-text-done-color:#2ac3a2;--alt-text-warning-color:#0090ed;--alt-text-hover-done-color:var(--alt-text-done-color);--alt-text-hover-warning-color:var(--alt-text-warning-color)}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:#2b2a33;--editor-toolbar-fg-color:#fbfbfe;--editor-toolbar-hover-bg-color:#52525e;--editor-toolbar-focus-outline-color:#0df;--alt-text-done-color:#54ffbd;--alt-text-warning-color:#80ebff}}@media screen and (forced-colors:active){:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{--editor-toolbar-bg-color:ButtonFace;--editor-toolbar-fg-color:ButtonText;--editor-toolbar-border-color:ButtonText;--editor-toolbar-hover-border-color:AccentColor;--editor-toolbar-hover-bg-color:ButtonFace;--editor-toolbar-hover-fg-color:AccentColor;--editor-toolbar-hover-outline:2px solid var(--editor-toolbar-hover-border-color);--editor-toolbar-focus-outline-color:ButtonBorder;--editor-toolbar-shadow:none;--alt-text-done-color:var(--editor-toolbar-fg-color);--alt-text-warning-color:var(--editor-toolbar-fg-color);--alt-text-hover-done-color:var(--editor-toolbar-hover-fg-color);--alt-text-hover-warning-color:var(--editor-toolbar-hover-fg-color)}}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);box-sizing:initial;cursor:default;display:flex;flex-direction:column;height:var(--editor-toolbar-height);inset-block-start:calc(100% + var(--editor-toolbar-vert-offset));inset-inline-end:0;justify-content:center;padding:var(--editor-toolbar-padding);pointer-events:auto;position:absolute;width:-moz-fit-content;width:fit-content}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar):has(:focus-visible){border-color:#0000}[dir=ltr] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:100% 0}[dir=rtl] :is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar){transform-origin:0 0}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons{align-items:center;display:flex;gap:0;height:100%;justify-content:center}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) button{padding:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .divider{border-left:1px solid var(--editor-toolbar-border-color);border-right:none;display:inline-block;height:calc(var(--editor-toolbar-padding)*2 + var(--editor-toolbar-height));margin-inline:2px;width:0}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-highlight-image);mask-image:var(--editor-toolbar-highlight-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .highlightButton):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete{width:var(--editor-toolbar-height)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:100%;-webkit-mask-image:var(--editor-toolbar-delete-image);mask-image:var(--editor-toolbar-delete-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:100%}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .delete):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>*{height:var(--editor-toolbar-height)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider){background-color:initial;border:none;cursor:pointer}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover{background-color:var(--editor-toolbar-hover-bg-color);border-radius:2px;color:var(--editor-toolbar-hover-fg-color);outline:var(--editor-toolbar-hover-outline);outline-offset:1px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):hover:active{outline:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons)>:not(.divider)):focus-visible{border-radius:2px;outline:2px solid var(--editor-toolbar-focus-outline-color)}:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText{--alt-text-add-image:url(images/altText_add.svg);--alt-text-done-image:url(images/altText_done.svg);align-items:center;color:var(--editor-toolbar-fg-color);display:flex;font:menu;font-size:12px;font-weight:590;justify-content:center;padding-inline:8px;pointer-events:all;width:-moz-max-content;width:max-content}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):disabled{pointer-events:none}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:13px;margin-inline-end:4px;-webkit-mask-image:var(--alt-text-add-image);mask-image:var(--alt-text-add-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--editor-toolbar-hover-fg-color)}.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-warning-color);height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}.new:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-warning-color)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):before{background-color:var(--alt-text-done-color);-webkit-mask-image:var(--alt-text-done-image);mask-image:var(--alt-text-done-image)}.new.done:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText):hover:before{background-color:var(--alt-text-hover-done-color)}:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip{word-wrap:anywhere;display:none}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#f0f0f4;--alt-text-tooltip-fg:#15141a;--alt-text-tooltip-border:#8f8f9d;--alt-text-tooltip-shadow:0px 2px 6px 0px #3a394433}@media (prefers-color-scheme:dark){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:#1c1b22;--alt-text-tooltip-fg:#fbfbfe;--alt-text-tooltip-shadow:0px 2px 6px 0px #15141a}}@media screen and (forced-colors:active){.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){--alt-text-tooltip-bg:Canvas;--alt-text-tooltip-fg:CanvasText;--alt-text-tooltip-border:CanvasText;--alt-text-tooltip-shadow:none}}.show:is(:is(:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor,.highlightEditor),.textLayer) .editToolbar) .buttons) .altText) .tooltip){align-items:center;background:var(--alt-text-tooltip-bg);border:.5px solid var(--alt-text-tooltip-border);box-shadow:var(--alt-text-tooltip-shadow);color:var(--alt-text-tooltip-fg);display:inline-flex;flex-direction:column;font-size:12px;height:auto;inset-inline-start:0;justify-content:center;max-width:300px;padding-block:2px 3px;padding-inline:3px;pointer-events:none;position:absolute;top:calc(100% + 2px);width:-moz-max-content;width:max-content}.annotationEditorLayer .freeTextEditor{height:auto;padding:calc(var(--freetext-padding)*var(--scale-factor));touch-action:none;width:auto}.annotationEditorLayer .freeTextEditor .internal{background:#0000;border:none;font:10px sans-serif;inset:0;line-height:var(--freetext-line-height);overflow:visible;-webkit-user-select:none;-moz-user-select:none;user-select:none;white-space:nowrap}.annotationEditorLayer .freeTextEditor .overlay{background:#0000;display:none;height:100%;inset:0;position:absolute;width:100%}.annotationEditorLayer freeTextEditor .overlay.enabled{display:block}.annotationEditorLayer .freeTextEditor .internal:empty:before{color:gray;content:attr(default-content)}.annotationEditorLayer .freeTextEditor .internal:focus{outline:none;-webkit-user-select:auto;-moz-user-select:auto;user-select:auto}.annotationEditorLayer .inkEditor{height:100%;width:100%}.annotationEditorLayer .inkEditor.editing{cursor:inherit}.annotationEditorLayer .inkEditor .inkEditorCanvas{height:100%;inset:0;position:absolute;touch-action:none;width:100%}.annotationEditorLayer .stampEditor{height:auto;width:auto}:is(.annotationEditorLayer .stampEditor) canvas{height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#f0f0f4;--no-alt-text-badge-bg-color:#cfcfd8;--no-alt-text-badge-fg-color:#5b5b66}@media (prefers-color-scheme:dark){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:#52525e;--no-alt-text-badge-bg-color:#fbfbfe;--no-alt-text-badge-fg-color:#15141a}}@media screen and (forced-colors:active){:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{--no-alt-text-badge-border-color:ButtonText;--no-alt-text-badge-bg-color:ButtonFace;--no-alt-text-badge-fg-color:ButtonText}}:is(.annotationEditorLayer .stampEditor) .noAltTextBadge{align-items:center;background:var(--no-alt-text-badge-bg-color);border:1px solid var(--no-alt-text-badge-border-color);border-radius:2px;display:inline-flex;height:32px;inset-block-end:5px;inset-inline-end:5px;justify-content:center;padding:3px;pointer-events:none;position:absolute;width:32px;z-index:1}:is(:is(.annotationEditorLayer .stampEditor) .noAltTextBadge):before{background-color:var(--no-alt-text-badge-fg-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-warning-image);mask-image:var(--new-alt-text-warning-image);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers{inset:0;position:absolute}.hidden:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers){display:none}:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer{background:content-box var(--resizer-bg-color);border:var(--focus-outline-around);border-radius:2px;height:var(--resizer-size);position:absolute;width:var(--resizer-size)}.topLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:var(--resizer-shift)}.topMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:calc(50% + var(--resizer-shift));top:var(--resizer-shift)}.topRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:var(--resizer-shift)}.middleRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){right:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);right:var(--resizer-shift)}.bottomMiddle:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:calc(50% + var(--resizer-shift))}.bottomLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){bottom:var(--resizer-shift);left:var(--resizer-shift)}.middleLeft:is(:is(:is(.annotationEditorLayer :is(.freeTextEditor,.inkEditor,.stampEditor))>.resizers)>.resizer){left:var(--resizer-shift);top:calc(50% + var(--resizer-shift))}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nwse-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ns-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:nesw-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]))>.resizers>.resizer){cursor:ew-resize}.bottomRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nesw-resize}.bottomMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topMiddle:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ew-resize}.bottomLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.topRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:nwse-resize}.middleLeft:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer),.middleRight:is(:is(.annotationEditorLayer[data-main-rotation="0"] :is([data-editor-rotation="90"],[data-editor-rotation="270"]),.annotationEditorLayer[data-main-rotation="90"] :is([data-editor-rotation="0"],[data-editor-rotation="180"]),.annotationEditorLayer[data-main-rotation="180"] :is([data-editor-rotation="270"],[data-editor-rotation="90"]),.annotationEditorLayer[data-main-rotation="270"] :is([data-editor-rotation="180"],[data-editor-rotation="0"]))>.resizers>.resizer){cursor:ns-resize}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar{rotate:270deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(0px - var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="90"],[data-main-rotation="90"] [data-editor-rotation="0"],[data-main-rotation="180"] [data-editor-rotation="270"],[data-main-rotation="270"] [data-editor-rotation="180"])) .editToolbar){inset-block-start:0;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="180"],[data-main-rotation="90"] [data-editor-rotation="90"],[data-main-rotation="180"] [data-editor-rotation="0"],[data-main-rotation="270"] [data-editor-rotation="270"])) .editToolbar{inset-block-start:calc(0pc - var(--editor-toolbar-vert-offset));inset-inline-end:100%;rotate:180deg}:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar{rotate:90deg}[dir=ltr] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:100%;inset-inline-end:calc(100% + var(--editor-toolbar-vert-offset))}[dir=rtl] :is(:is(.annotationEditorLayer :is([data-main-rotation="0"] [data-editor-rotation="270"],[data-main-rotation="90"] [data-editor-rotation="180"],[data-main-rotation="180"] [data-editor-rotation="90"],[data-main-rotation="270"] [data-editor-rotation="0"])) .editToolbar){inset-block-start:0;inset-inline-start:calc(0px - var(--editor-toolbar-vert-offset))}.dialog.altText::backdrop{-webkit-mask:url(#alttext-manager-mask);mask:url(#alttext-manager-mask)}.dialog.altText.positioned{margin:0}.dialog.altText #altTextContainer{align-items:flex-start;display:inline-flex;flex-direction:column;gap:16px;height:-moz-fit-content;height:fit-content;width:300px}:is(.dialog.altText #altTextContainer) #overallDescription{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(:is(.dialog.altText #altTextContainer) #overallDescription) span{align-self:stretch}:is(:is(.dialog.altText #altTextContainer) #overallDescription) .title{font-size:13px;font-style:normal;font-weight:590}:is(.dialog.altText #altTextContainer) #addDescription{align-items:stretch;display:flex;flex-direction:column;gap:8px}:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea{flex:1;padding-inline:24px 10px}:is(:is(:is(.dialog.altText #altTextContainer) #addDescription) .descriptionArea) textarea{min-height:75px;width:100%}:is(.dialog.altText #altTextContainer) #buttons{align-items:flex-start;align-self:stretch;display:flex;gap:8px;justify-content:flex-end}.dialog.newAltText{--new-alt-text-ai-disclaimer-icon:url(images/altText_disclaimer.svg);--new-alt-text-spinner-icon:url(images/altText_spinner.svg);--preview-image-bg-color:#f0f0f4;--preview-image-border:none}@media (prefers-color-scheme:dark){.dialog.newAltText{--preview-image-bg-color:#2b2a33}}@media screen and (forced-colors:active){.dialog.newAltText{--preview-image-bg-color:ButtonFace;--preview-image-border:1px solid ButtonText}}.dialog.newAltText{max-width:570px;min-width:300px;padding:0;width:80%}.dialog.newAltText.aiInstalling #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextCreateAutomatically,.dialog.newAltText.noAi #newAltTextDisclaimer{display:none!important}.dialog.newAltText.aiInstalling #newAltTextDownloadModel{display:flex!important}.dialog.newAltText.error #newAltTextNotNow{display:none!important}.dialog.newAltText.error #newAltTextCancel{display:inline-block!important}.dialog.newAltText:not(.error) #newAltTextError{display:none!important}.dialog.newAltText #newAltTextContainer{align-items:flex-start;display:flex;flex:0 1 auto;flex-direction:column;gap:12px;justify-content:flex-end;line-height:normal;padding:16px;width:auto}:is(.dialog.newAltText #newAltTextContainer) #mainContent{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;gap:12px;justify-content:flex-end}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionAndSettings{align-items:flex-start;align-self:stretch;display:flex;flex:1 0 0;flex-direction:column;gap:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction{align-items:flex-start;align-self:stretch;display:flex;flex:1 1 auto;flex-direction:column;gap:8px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer{height:70px;position:relative;width:100%}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea{height:100%;padding:8px;width:100%}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::-moz-placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea)::placeholder{color:var(--text-secondary-color)}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{background-color:var(--text-secondary-color);display:none;height:16px;inset-block-start:8px;inset-inline-start:8px;-webkit-mask-size:cover;mask-size:cover;pointer-events:none;position:absolute;width:16px}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::-moz-placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) textarea::placeholder{color:#0000}.loading:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescriptionContainer) .altTextSpinner{display:inline-block;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon)}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDescription{font-size:11px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer{align-items:flex-start;display:flex;flex-direction:row;font-size:11px;gap:4px}:is(:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #descriptionInstruction) #newAltTextDisclaimer):before{background-color:var(--text-secondary-color);content:"";display:inline-block;flex:1 0 auto;height:16px;-webkit-mask-image:var(--new-alt-text-ai-disclaimer-icon);mask-image:var(--new-alt-text-ai-disclaimer-icon);-webkit-mask-size:cover;mask-size:cover;width:17px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel{align-items:center;align-self:stretch;display:flex;gap:4px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextDownloadModel):before{background-color:var(--text-secondary-color);content:"";display:inline-block;height:16px;-webkit-mask-image:var(--new-alt-text-spinner-icon);mask-image:var(--new-alt-text-spinner-icon);-webkit-mask-size:cover;mask-size:cover;width:16px}:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview{align-items:center;aspect-ratio:1;background-color:var(--preview-image-bg-color);border:var(--preview-image-border);display:flex;flex:0 0 auto;justify-content:center;width:180px}:is(:is(:is(.dialog.newAltText #newAltTextContainer) #mainContent) #newAltTextImagePreview)>canvas{max-height:100%;max-width:100%}.colorPicker{--hover-outline-color:#0250bb;--selected-outline-color:#0060df;--swatch-border-color:#cfcfd8}@media (prefers-color-scheme:dark){.colorPicker{--hover-outline-color:#80ebff;--selected-outline-color:#aaf2ff;--swatch-border-color:#52525e}}@media screen and (forced-colors:active){.colorPicker{--hover-outline-color:Highlight;--selected-outline-color:var(--hover-outline-color);--swatch-border-color:ButtonText}}.colorPicker .swatch{border:1px solid var(--swatch-border-color);border-radius:100%;box-sizing:border-box;forced-color-adjust:none;height:16px;outline-offset:2px;width:16px}.colorPicker button:is(:hover,.selected)>.swatch{border:none}.annotationEditorLayer[data-main-rotation="0"] .highlightEditor:not(.free)>.editToolbar{rotate:0deg}.annotationEditorLayer[data-main-rotation="90"] .highlightEditor:not(.free)>.editToolbar{rotate:270deg}.annotationEditorLayer[data-main-rotation="180"] .highlightEditor:not(.free)>.editToolbar{rotate:180deg}.annotationEditorLayer[data-main-rotation="270"] .highlightEditor:not(.free)>.editToolbar{rotate:90deg}.annotationEditorLayer .highlightEditor{background:#0000;border:none;cursor:auto;max-height:100%;max-width:100%;outline:none;pointer-events:none;position:absolute;transform-origin:0 0;z-index:1}:is(.annotationEditorLayer .highlightEditor):not(.free){transform:none}:is(.annotationEditorLayer .highlightEditor) .internal{height:100%;left:0;pointer-events:auto;position:absolute;top:0;width:100%}.disabled:is(.annotationEditorLayer .highlightEditor) .internal{pointer-events:none}.selectedEditor:is(.annotationEditorLayer .highlightEditor) .internal{cursor:pointer}:is(.annotationEditorLayer .highlightEditor) .editToolbar{--editor-toolbar-colorpicker-arrow-image:url(images/toolbarButton-menuArrow.svg);transform-origin:center!important}:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker{align-items:center;display:flex;gap:4px;justify-content:center;padding:4px;position:relative;width:auto}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):after{background-color:var(--editor-toolbar-fg-color);content:"";display:inline-block;height:12px;-webkit-mask-image:var(--editor-toolbar-colorpicker-arrow-image);mask-image:var(--editor-toolbar-colorpicker-arrow-image);-webkit-mask-position:center;mask-position:center;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat;width:12px}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):hover:after{background-color:var(--editor-toolbar-hover-fg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)){background-color:var(--editor-toolbar-hover-bg-color)}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker):has(.dropdown:not(.hidden)):after{scale:-1}:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown{align-items:center;background-color:var(--editor-toolbar-bg-color);border:1px solid var(--editor-toolbar-border-color);border-radius:6px;box-shadow:var(--editor-toolbar-shadow);display:flex;flex-direction:column;gap:11px;inset-block-start:calc(100% + 4px);justify-content:center;padding-block:8px;position:absolute;width:calc(100% + var(--editor-toolbar-padding)*2)}:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;height:auto;justify-content:center;width:100%}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline-offset:2px}[aria-selected=true]:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(:is(:is(:is(.annotationEditorLayer .highlightEditor) .editToolbar) .buttons) .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}.editorParamsToolbar:has(#highlightParamsToolbarContainer){padding:unset}#highlightParamsToolbarContainer{gap:16px;padding-block-end:12px;padding-inline:10px}#highlightParamsToolbarContainer .colorPicker{display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer .colorPicker) .dropdown{align-items:center;display:flex;flex-direction:row;height:auto;justify-content:space-between}:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button{align-items:center;background:none;border:none;cursor:pointer;display:flex;flex:0 0 auto;height:auto;justify-content:center;padding:0;width:auto}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button) .swatch{height:24px;width:24px}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:active,:focus-visible){outline:none}[aria-selected=true]:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button)>.swatch{outline:2px solid var(--selected-outline-color)}:is(:is(:is(#highlightParamsToolbarContainer .colorPicker) .dropdown) button):is(:hover,:active,:focus-visible)>.swatch{outline:2px solid var(--hover-outline-color)}#highlightParamsToolbarContainer #editorHighlightThickness{align-items:center;align-self:stretch;display:flex;flex-direction:column;gap:4px}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .editorParamsLabel{align-self:stretch;height:auto}:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#bfbfc9;align-items:center;align-self:stretch;display:flex;justify-content:space-between}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:#80808e}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker{--example-color:CanvasText}}:is(:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker)>.editorParamsSlider[disabled]){opacity:.4}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after,:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):before{aspect-ratio:1;background-color:var(--example-color);border-radius:100%;content:"";display:block;width:8px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker):after{width:24px}:is(:is(#highlightParamsToolbarContainer #editorHighlightThickness) .thicknessPicker) .editorParamsSlider{height:14px;width:unset}#highlightParamsToolbarContainer #editorHighlightVisibility{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:8px}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#d7d7db}@media (prefers-color-scheme:dark){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:#8f8f9d}}@media screen and (forced-colors:active){:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{--divider-color:CanvasText}}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .divider{background-color:var(--divider-color);height:1px;margin-block:4px;width:100%}:is(#highlightParamsToolbarContainer #editorHighlightVisibility) .toggler{align-items:center;align-self:stretch;display:flex;justify-content:space-between}#altTextSettingsDialog{padding:16px}#altTextSettingsDialog #altTextSettingsContainer{display:flex;flex-direction:column;gap:16px;width:573px}:is(#altTextSettingsDialog #altTextSettingsContainer) .mainContainer{gap:16px}:is(#altTextSettingsDialog #altTextSettingsContainer) .description{color:var(--text-secondary-color)}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings{display:flex;flex-direction:column;gap:12px}:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) button{width:-moz-fit-content;width:fit-content}.download:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings) #deleteModelButton,:is(:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings):not(.download) #downloadModelButton{display:none}:is(#altTextSettingsDialog #altTextSettingsContainer) #altTextEditor,:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticAltText{display:flex;flex-direction:column;gap:8px}:is(#altTextSettingsDialog #altTextSettingsContainer) #aiModelSettings,:is(#altTextSettingsDialog #altTextSettingsContainer) #createModelDescription,:is(#altTextSettingsDialog #altTextSettingsContainer) #showAltTextDialogDescription{padding-inline-start:40px}:is(#altTextSettingsDialog #altTextSettingsContainer) #automaticSettings{display:flex;flex-direction:column;gap:16px}:root{--viewer-container-height:0;--pdfViewer-padding-bottom:0;--page-margin:1px auto -8px;--page-border:9px solid #0000;--spreadHorizontalWrapped-margin-LR:-3.5px;--loading-icon-delay:400ms}@media screen and (forced-colors:active){:root{--pdfViewer-padding-bottom:9px;--page-margin:8px auto -1px;--page-border:1px solid CanvasText;--spreadHorizontalWrapped-margin-LR:3.5px}}[data-main-rotation="90"]{transform:rotate(90deg) translateY(-100%)}[data-main-rotation="180"]{transform:rotate(180deg) translate(-100%,-100%)}[data-main-rotation="270"]{transform:rotate(270deg) translateX(-100%)}#hiddenCopyElement,.hiddenCanvasElement{display:none;height:0;left:0;position:absolute;top:0;width:0}.pdfViewer{--scale-factor:1;--page-bg-color:unset;--hcm-highlight-filter:none;--hcm-highlight-selected-filter:none;padding-bottom:var(--pdfViewer-padding-bottom)}@media screen and (forced-colors:active){.pdfViewer{--hcm-highlight-filter:invert(100%)}}.pdfViewer.copyAll{cursor:wait}.pdfViewer .canvasWrapper{height:100%;overflow:hidden;width:100%}:is(.pdfViewer .canvasWrapper) canvas{contain:content;display:block;height:100%;left:0;margin:0;position:absolute;top:0;width:100%}:is(:is(.pdfViewer .canvasWrapper) canvas) .structTree{contain:strict}.pdfViewer .page{--scale-round-x:1px;--scale-round-y:1px;background-clip:content-box;background-color:var(--page-bg-color,#fff);border:var(--page-border);direction:ltr;height:1056px;margin:var(--page-margin);overflow:visible;position:relative;width:816px}.pdfViewer .dummyPage{height:var(--viewer-container-height);position:relative;width:0}.pdfViewer.noUserSelect{-webkit-user-select:none;-moz-user-select:none;user-select:none}.pdfViewer.removePageBorders .page{border:none;margin:0 auto 10px}.pdfViewer.singlePageView{display:inline-block}.pdfViewer.singlePageView .page{border:none;margin:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped),.spread{margin-inline:3.5px;text-align:center}.pdfViewer.scrollHorizontal,.spread{white-space:nowrap}.pdfViewer.removePageBorders,.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .spread{margin-inline:0}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) :is(.page,.spread),.spread :is(.page,.dummyPage){display:inline-block;vertical-align:middle}.pdfViewer:is(.scrollHorizontal,.scrollWrapped) .page,.spread .page{margin-inline:var(--spreadHorizontalWrapped-margin-LR)}.pdfViewer.removePageBorders .spread .page,.pdfViewer.removePageBorders:is(.scrollHorizontal,.scrollWrapped) .page{margin-inline:5px}.pdfViewer .page.loadingIcon:after{background:url(images/loading-icon.gif) 50% no-repeat;contain:strict;content:"";display:none;height:100%;left:0;position:absolute;top:0;transition-delay:var(--loading-icon-delay);transition-property:display;width:100%;z-index:5}.pdfViewer .page.loading:after{display:block}.pdfViewer .page:not(.loading):after{display:none;transition-property:none}.pdfPresentationMode .pdfViewer{padding-bottom:0}.pdfPresentationMode .spread{margin:0}.pdfPresentationMode .pdfViewer .page{border:2px solid #0000;margin:0 auto}');var xle=function(){function e(){}return e.generateUniqueId=function(){var e=Date.now().toString(36),t=Math.random().toString(36).substring(2,8);return"".concat(e,"-").concat(t)},e}(),Sle=Symbol.for("immer-nothing"),Tle=Symbol.for("immer-draftable"),Ole=Symbol.for("immer-state"),Ale="production"!==xt.env.NODE_ENV?[function(e){return`The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`},function(e){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`},"This object has been frozen and should not be mutated",function(e){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+e},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(e){return`'current' expects a draft, got: ${e}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(e){return`'original' expects a draft, got: ${e}`}]:[];function Rle(e,...t){if("production"!==xt.env.NODE_ENV){const n=Ale[e],r="function"==typeof n?n.apply(null,t):n;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Nle=Object.getPrototypeOf;function _le(e){return!!e&&!!e[Ole]}function Dle(e){return!!e&&(Fle(e)||Array.isArray(e)||!!e[Tle]||!!e.constructor?.[Tle]||Wle(e)||$le(e))}var Ple=Object.prototype.constructor.toString();function Fle(e){if(!e||"object"!=typeof e)return!1;const t=Nle(e);if(null===t)return!0;const n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object||"function"==typeof n&&Function.toString.call(n)===Ple}function Ile(e,t){0===Ble(e)?Reflect.ownKeys(e).forEach((n=>{t(n,e[n],e)})):e.forEach(((n,r)=>t(r,n,e)))}function Ble(e){const t=e[Ole];return t?t.type_:Array.isArray(e)?1:Wle(e)?2:$le(e)?3:0}function jle(e,t){return 2===Ble(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ule(e,t,n){const r=Ble(e);2===r?e.set(t,n):3===r?e.add(n):e[t]=n}function Wle(e){return e instanceof Map}function $le(e){return e instanceof Set}function qle(e){return e.copy_||e.base_}function Gle(e,t){if(Wle(e))return new Map(e);if($le(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);const n=Fle(e);if(!0===t||"class_only"===t&&!n){const t=Object.getOwnPropertyDescriptors(e);delete t[Ole];let n=Reflect.ownKeys(t);for(let r=0;r<n.length;r++){const a=n[r],o=t[a];!1===o.writable&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(t[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[a]})}return Object.create(Nle(e),t)}{const t=Nle(e);if(null!==t&&n)return{...e};const r=Object.create(t);return Object.assign(r,e)}}function Yle(e,t=!1){return Xle(e)||_le(e)||!Dle(e)||(Ble(e)>1&&(e.set=e.add=e.clear=e.delete=Kle),Object.freeze(e),t&&Object.entries(e).forEach((([e,t])=>Yle(t,!0)))),e}function Kle(){Rle(2)}function Xle(e){return Object.isFrozen(e)}var Qle,Jle={};function Zle(e){const t=Jle[e];return t||Rle(0,e),t}function ese(){return Qle}function tse(e,t){t&&(Zle("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function nse(e){rse(e),e.drafts_.forEach(ose),e.drafts_=null}function rse(e){e===Qle&&(Qle=e.parent_)}function ase(e){return Qle={drafts_:[],parent_:Qle,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ose(e){const t=e[Ole];0===t.type_||1===t.type_?t.revoke_():t.revoked_=!0}function cse(e,t){t.unfinalizedDrafts_=t.drafts_.length;const n=t.drafts_[0];return void 0!==e&&e!==n?(n[Ole].modified_&&(nse(t),Rle(4)),Dle(e)&&(e=ise(t,e),t.parent_||sse(t,e)),t.patches_&&Zle("Patches").generateReplacementPatches_(n[Ole].base_,e,t.patches_,t.inversePatches_)):e=ise(t,n,[]),nse(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Sle?e:void 0}function ise(e,t,n){if(Xle(t))return t;const r=t[Ole];if(!r)return Ile(t,((a,o)=>lse(e,r,t,a,o,n))),t;if(r.scope_!==e)return t;if(!r.modified_)return sse(e,r.base_,!0),r.base_;if(!r.finalized_){r.finalized_=!0,r.scope_.unfinalizedDrafts_--;const t=r.copy_;let a=t,o=!1;3===r.type_&&(a=new Set(t),t.clear(),o=!0),Ile(a,((a,c)=>lse(e,r,t,a,c,n,o))),sse(e,t,!1),n&&e.patches_&&Zle("Patches").generatePatches_(r,n,e.patches_,e.inversePatches_)}return r.copy_}function lse(e,t,n,r,a,o,c){if("production"!==xt.env.NODE_ENV&&a===n&&Rle(5),_le(a)){const c=ise(e,a,o&&t&&3!==t.type_&&!jle(t.assigned_,r)?o.concat(r):void 0);if(Ule(n,r,c),!_le(c))return;e.canAutoFreeze_=!1}else c&&n.add(a);if(Dle(a)&&!Xle(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ise(e,a),t&&t.scope_.parent_||"symbol"==typeof r||!Object.prototype.propertyIsEnumerable.call(n,r)||sse(e,a)}}function sse(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Yle(t,n)}var hse={get(e,t){if(t===Ole)return e;const n=qle(e);if(!jle(n,t))return function(e,t,n){const r=mse(t,n);return r?"value"in r?r.value:r.get?.call(e.draft_):void 0}(e,n,t);const r=n[t];return e.finalized_||!Dle(r)?r:r===use(e.base_,t)?(vse(e),e.copy_[t]=fse(r,e)):r},has:(e,t)=>t in qle(e),ownKeys:e=>Reflect.ownKeys(qle(e)),set(e,t,n){const r=mse(qle(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){const r=use(qle(e),t),c=r?.[Ole];if(c&&c.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(((a=n)===(o=r)?0!==a||1/a==1/o:a!=a&&o!=o)&&(void 0!==n||jle(e.base_,t)))return!0;vse(e),pse(e)}var a,o;return e.copy_[t]===n&&(void 0!==n||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty:(e,t)=>(void 0!==use(e.base_,t)||t in e.base_?(e.assigned_[t]=!1,vse(e),pse(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0),getOwnPropertyDescriptor(e,t){const n=qle(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r?{writable:!0,configurable:1!==e.type_||"length"!==t,enumerable:r.enumerable,value:n[t]}:r},defineProperty(){Rle(11)},getPrototypeOf:e=>Nle(e.base_),setPrototypeOf(){Rle(12)}},dse={};function use(e,t){const n=e[Ole];return(n?qle(n):e)[t]}function mse(e,t){if(!(t in e))return;let n=Nle(e);for(;n;){const e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=Nle(n)}}function pse(e){e.modified_||(e.modified_=!0,e.parent_&&pse(e.parent_))}function vse(e){e.copy_||(e.copy_=Gle(e.base_,e.scope_.immer_.useStrictShallowCopy_))}function fse(e,t){const n=Wle(e)?Zle("MapSet").proxyMap_(e,t):$le(e)?Zle("MapSet").proxySet_(e,t):function(e,t){const n=Array.isArray(e),r={type_:n?1:0,scope_:t?t.scope_:ese(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1};let a=r,o=hse;n&&(a=[r],o=dse);const{revoke:c,proxy:i}=Proxy.revocable(a,o);return r.draft_=i,r.revoke_=c,i}(e,t);return(t?t.scope_:ese()).drafts_.push(n),n}function zse(e){if(!Dle(e)||Xle(e))return e;const t=e[Ole];let n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Gle(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Gle(e,!0);return Ile(n,((e,t)=>{Ule(n,e,zse(t))})),t&&(t.finalized_=!1),n}Ile(hse,((e,t)=>{dse[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}})),dse.deleteProperty=function(e,t){return"production"!==xt.env.NODE_ENV&&isNaN(parseInt(t))&&Rle(13),dse.set.call(this,e,t,void 0)},dse.set=function(e,t,n){return"production"!==xt.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&Rle(14),hse.set.call(this,e[0],t,n,e[0])};var gse=new class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(e,t,n)=>{if("function"==typeof e&&"function"!=typeof t){const n=t;t=e;const r=this;return function(e=n,...a){return r.produce(e,(e=>t.call(this,e,...a)))}}let r;if("function"!=typeof t&&Rle(6),void 0!==n&&"function"!=typeof n&&Rle(7),Dle(e)){const a=ase(this),o=fse(e,void 0);let c=!0;try{r=t(o),c=!1}finally{c?nse(a):rse(a)}return tse(a,n),cse(r,a)}if(!e||"object"!=typeof e){if(r=t(e),void 0===r&&(r=e),r===Sle&&(r=void 0),this.autoFreeze_&&Yle(r,!0),n){const t=[],a=[];Zle("Patches").generateReplacementPatches_(e,r,t,a),n(t,a)}return r}Rle(1,e)},this.produceWithPatches=(e,t)=>{if("function"==typeof e)return(t,...n)=>this.produceWithPatches(t,(t=>e(t,...n)));let n,r;return[this.produce(e,t,((e,t)=>{n=e,r=t})),n,r]},"boolean"==typeof e?.autoFreeze&&this.setAutoFreeze(e.autoFreeze),"boolean"==typeof e?.useStrictShallowCopy&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Dle(e)||Rle(8),_le(e)&&(e=function(e){return _le(e)||Rle(10,e),zse(e)}(e));const t=ase(this),n=fse(e,void 0);return n[Ole].isManual_=!0,rse(t),n}finishDraft(e,t){const n=e&&e[Ole];n&&n.isManual_||Rle(9);const{scope_:r}=n;return tse(r,t),cse(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){const r=t[n];if(0===r.path.length&&"replace"===r.op){e=r.value;break}}n>-1&&(t=t.slice(n+1));const r=Zle("Patches").applyPatches_;return _le(e)?r(e,t):this.produce(e,(e=>r(e,t)))}},yse=gse.produce;gse.produceWithPatches.bind(gse);var Mse=gse.setAutoFreeze.bind(gse);gse.setUseStrictShallowCopy.bind(gse),gse.applyPatches.bind(gse),gse.createDraft.bind(gse),gse.finishDraft.bind(gse);var Ese={isScaleSaveHappening:!1,isAddNewScaleFormPopupOpen:!1,scaleName:"",paperDimension:{unitOfMeasurement:"inch",scalarQuantity:1},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:1},precision:.1,userCalibratingScaleOnPdfPageDetails:{isHappening:!1,coordinates:[]},isCalibrationScaleFormPopupOpen:!1,pdfPageId:""},bse={scaleId:"",popup:{isOpen:!1},paperDimension:{unitOfMeasurement:"inch",scalarQuantity:0},displayDimension:{unitOfMeasurement:"inch",scalarQuantity:0},scaleName:"",precision:.1,isScaleSaveHappening:!1},Hse=function(){function e(){}return e.getEnvValue=function(e){var t,n=null===(t=null===window||void 0===window?void 0:window._env_)||void 0===t?void 0:t[e];return n&&"default"!==n?n:""},e}(),Vse=function(){function e(){}return e.BACKEND_BASE_URL=Hse.getEnvValue("BACKEND_BASE_URL"),e.scalePrecisionOptions=[.1,.01,.001],e.annotationAvalaibleColors=[{color:"#E34234"},{color:"#FF8D02"},{color:"#FFCD44"},{color:"#5BC96D"},{color:"#26D2D2"},{color:"#587CE2"},{color:"#C544CE"},{color:"#7D2E25"},{color:"#A84F1C"},{color:"#E99E38"},{color:"#347842"},{color:"#167E7D"},{color:"#354A87"},{color:"#76287B"},{color:"#000"},{color:"#CDCDCD"},{color:"#9C9C9C"},{color:"#696969"},{color:"#272727"},{color:"#FFFFFF"}],e.pdfPagesElementId="pdf-pages-container",e}(),Cse={isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:Vse.annotationAvalaibleColors[0].color},coordinates:{collapsedStatus:"collapsed",shouldHighlightFirstCoordinate:!1,shouldHighlightSecondCoordinate:!1,x1:0,x2:0,y1:0,y2:0}}};Cle.workerSrc="https://unpkg.com/pdfjs-dist@4.10.38/build/pdf.worker.min.mjs",Mse(!1);var Lse={options:{showDividerBetweenToolSections:!0,alignmentOfFirstRowToolSections:"space-between"},sections:[[{name:"fullScreen"},{name:"zoomTool"}],[{name:"Annotation",children:[{name:"highlight"},{name:"callout"}]},{name:"Shapes",children:[{name:"rectangle"}]},{name:"Measure",children:[{name:"measureDistance"}]}],[{name:"toggleTextSelectionTool"},{name:"eyeTool"},{name:"comment"}]]};function wse(e){var t=this,r=c([]),a=r[0],o=r[1],d=c(""),u=d[0],m=d[1],p=c(""),v=p[0],f=p[1],z=c({pdfEditorToolsToShow:e.toolsToShow||Lse,toolsRelatedData:{},measureToolRelatedData:{scaleIdSelected:"",addNewScaleDetails:Ese,editScaleDetails:bse,distanceAnnotation:{configurationsDrawer:Cse,isFirstPointSelected:!1,isSecondPointSelected:!1}},textHighlightToolRelatedData:{isTextSelectionEnabled:!0,selectedTextToolBoxDetails:{pdfPageId:"",x:0,y:0}}}),g=z[0],y=z[1],M=c(e.currentUserId),E=M[0],b=M[1],H=c([]),V=H[0],C=H[1],L=c([]),w=L[0],k=L[1],x=c(!1),S=x[0],T=x[1],O=c(0),A=O[0],R=O[1],N=c(!1),_=N[0],D=N[1],P=c(!1),F=P[0],I=P[1],B=c(e.areAnnotationsVisibleByDefault),j=B[0],U=B[1],W=c(""),$=W[0],q=W[1],G=c(""),Y=G[0],K=G[1],X=e.rectangleAnnotationToolOptions,Q=e.backendBaseUrl,J=e.rlefEventServiceBaseUrl,Z=i(new pae({backendBaseUrl:Q})),ee=c(xle.generateUniqueId()),te=ee[0];ee[1];var ne=c([]),re=ne[0],ae=ne[1],oe=l((function(e){ae((function(t){return _ee(_ee([],t,!0),[e],!1)}))}),[ae]),ce=l((function(e,n){return Ree(t,void 0,void 0,(function(){var t,r;return Nee(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),T(!0),[4,Z.current.fetchUsersOfPdf({pdfId:n,userNameSearchKey:e,limit:10,offset:1})];case 1:return(t=a.sent())&&k(t),[3,4];case 2:return r=a.sent(),console.error("Error fetching suggested users: ",r),[3,4];case 3:return T(!1),[7];case 4:return[2]}}))}))}),[]),ie=l((function(e){ae((function(t){return _ee([],t.filter((function(t){return t!==e})),!0)}))}),[ae]),le=l((function(){return Ree(t,void 0,void 0,(function(){var t,n,r,o,c;return Nee(this,(function(i){switch(i.label){case 0:if(!(t=(null===(c=a[0])||void 0===c?void 0:c._id)||""))return[2];i.label=1;case 1:return i.trys.push([1,5,,6]),I(!0),[4,Z.current.fetchUsersOfPdf({pdfId:t})];case 2:return(n=i.sent())?-1!==n.findIndex((function(t){return t._id===e.currentUserId}))?[3,4]:[4,Z.current.fetchUsersOfPdf({pdfId:t,userIds:[e.currentUserId]})]:[2];case 3:(r=i.sent())&&r.length>0&&n.push(r[0]),i.label=4;case 4:return C(n),[3,6];case 5:return o=i.sent(),console.error("Error fetching users: ",o),[3,6];case 6:return[2]}}))}))}),[a]);s((function(){F||le()}),[le,F]);var se=c([]);se[0];var he=se[1],de=c({isEditingText:!1,annotationId:"",pdfId:"",pdfPageId:"",color:"",points:[],text:""}),ue=de[0],me=de[1],pe=l((function(e,n){return Ree(t,void 0,void 0,(function(){var t,r,a,c,i,l,s,h,d,u,m,p,v;return Nee(this,(function(f){switch(f.label){case 0:return t=(n||{}).pdfSourceUrl,e&&oe(e),r={},e&&(r.pdfId=e),t&&(r.pdfSourceUrl=t),a=Z.current.fetchOnlyPdfData(Aee(Aee({},r),{getPdfDownloadUrl:"true"})),c={pdfs:[]},t?[4,a]:[3,6];case 1:return(c=f.sent()).pdfs.length>0?(e=c.pdfs[0]._id,[3,5]):[3,2];case 2:return he((function(e){return _ee(_ee([],e,!0),[t],!1)})),[4,Z.current.insertPdfAndItsPagesInDb({pdfSourceUrl:t,pdfFileName:"sourceUrl.pdf"})];case 3:return i=f.sent(),e=i._id,[4,Z.current.fetchOnlyPdfData(Aee(Aee({},r),{getPdfDownloadUrl:"true"}))];case 4:c=f.sent(),he((function(e){return _ee([],e.filter((function(e){return e!==t})),!0)})),f.label=5;case 5:return[3,8];case 6:return[4,a];case 7:c=f.sent(),f.label=8;case 8:return l=Z.current.fetchOnlyPdfPagesData({pdfId:e,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"}),s=Z.current.fetchPdfScales({pdfId:e}),[4,l];case 9:return h=f.sent(),[4,s];case 10:return d=f.sent(),!g.measureToolRelatedData.scaleIdSelected&&d.scales.length>0&&y(yse((function(e){var t;e.measureToolRelatedData.scaleIdSelected=(null===(t=d.scales[0])||void 0===t?void 0:t._id)||""}))),(u=null===(v=null==c?void 0:c.pdfs[0])||void 0===v?void 0:v.pdfDownloadUrl)?[4,wle(u).promise]:[3,12];case 11:return p=f.sent(),[3,13];case 12:p=null,f.label=13;case 13:return(m=p)&&o((function(n){var r,a,o=_ee([],n,!0),i=o.length>0?o.findIndex((function(t){return t._id===e})):-1,l=-1!==i,s={_id:null===(a=null===(r=null==c?void 0:c.pdfs)||void 0===r?void 0:r[0])||void 0===a?void 0:a._id,sourcePdfUrl:t||"",pdfPagesImageGenerationStatus:c.pdfs[0].pdfPagesImageGenerationStatus,pdfDownloadUrl:c.pdfs[0].pdfDownloadUrl,pdfDocument:m,pages:h.pages.map((function(e){return{_id:null==e?void 0:e._id,pdfId:e.pdfId,annotations:[],commentThreads:[],pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pageNumber:e.pageNumber,pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints,pageAsImageDetails:e.pageAsImageDetails}})),scales:d.scales.map((function(e){return Aee({},e)}))};return l?o[i]=Aee({},s):o.push(s),o})),ie(e),[2]}}))}))}),[oe,Z,ie,o]),ve=l((function(e){y((function(t){var n=Aee({},t);return n.toolsRelatedData=Aee(Aee({},n.toolsRelatedData),{comment:Aee(Aee({},n.toolsRelatedData.comment),{selectedThreadId:e})}),n}))}),[y]),fe=g.measureToolRelatedData.addNewScaleDetails,ze=g.measureToolRelatedData.editScaleDetails,ge=l((function(){return Ree(t,void 0,void 0,(function(){return Nee(this,(function(e){return y((function(e){var t,n;return Aee(Aee({},e),{measureToolRelatedData:Aee(Aee({},e.measureToolRelatedData),{addNewScaleDetails:Aee(Aee({},e.measureToolRelatedData.addNewScaleDetails),{isAddNewScaleFormPopupOpen:!0,pdfPageId:null===(n=null===(t=null==a?void 0:a[0])||void 0===t?void 0:t.pages[0])||void 0===n?void 0:n._id})})})})),[2]}))}))}),[a]),ye=c([]),Me=ye[0],Ee=ye[1],be=l((function(e){return Ree(t,void 0,void 0,(function(){var t,n,r;return Nee(this,(function(c){switch(c.label){case 0:return(t=a.find((function(t){return t._id===e.pdfIdOfPage})))&&(n=t.pages.find((function(t){return t._id===e.pdfPageId})))?n.pageImageElement||Me.includes(n._id)?[2]:(Ee((function(e){return _ee(_ee([],e,!0),[n._id],!1)})),[4,vae.downloadImage(n.pageImageUrl)]):[2];case 1:return r=c.sent(),o((function(t){var n=t.map((function(e){return Aee(Aee({},e),{pages:e.pages.map((function(e){return Aee({},e)}))})})),a=n.findIndex((function(t){return t._id===e.pdfIdOfPage})),o=n[a].pages.findIndex((function(t){return t._id===e.pdfPageId}));return n[a].pages[o].pageImageElement=r,n})),Ee((function(e){return _ee([],e.filter((function(e){return e!==n._id})),!0)})),[2]}}))}))}),[Me,a]),He=l((function(e){return Ree(t,void 0,void 0,(function(){var t,n,r,c;return Nee(this,(function(i){switch(i.label){case 0:return t=e.pdfId,(n=a.find((function(e){return e._id===t})))?(r=n.pages.map((function(e){return e._id})),[4,Z.current.fetchOnlyPdfPagesData({excludePdfPageIds:r,pdfId:t,getPdfPageImageDownloadUrl:"true",pdfPageImageUploaded:"true"})]):[2];case 1:return c=i.sent(),o((function(e){var n=e.findIndex((function(e){return e._id===t}));return-1===n?e:(e[n].pages=_ee(_ee([],e[n].pages,!0),c.pages.map((function(e){return{_id:e._id,pdfId:e.pdfId,pageNumber:e.pageNumber,annotations:[],commentThreads:[],pageAsImageDetails:e.pageAsImageDetails,pageImageUrl:e.pageAsImageDetails.pageImageDownloadUrl||"",pdfPageWidthInPoints:e.pdfPageWidthInPoints,pdfPageHeightInPoints:e.pdfPageHeightInPoints}})),!0),_ee([],e,!0))})),[2]}}))}))}),[a,Z]),Ve=l((function(e){var n=e.pdfId,r=e.pdfPageId,a=e.annotationIds;return Ree(t,void 0,void 0,(function(){return Nee(this,(function(e){return o((function(e){return e.map((function(e){return e._id===n?Aee(Aee({},e),{pages:e.pages.map((function(e){return e._id===r?Aee(Aee({},e),{annotations:e.annotations.filter((function(e){return!a.includes(e._id)||(Z.current.deletePageAnnotation({annotationId:e._id}),!1)}))}):Aee({},e)}))}):Aee({},e)}))})),[2]}))}))}),[Z]),Ce=l((function(e){var t=e.pdfId,n=e.pdfPageId,r=e.annotations;o((function(e){return e.map((function(e){return e._id===t?Aee(Aee({},e),{pages:e.pages.map((function(e){return e._id===n?Aee(Aee({},e),{annotations:_ee(_ee([],e.annotations,!0),r,!0)}):Aee({pdfPageId:e._id},e)}))}):Aee({},e)}))}))}),[]),Le=c({rectangleAnnotationOptions:X,rectangleAnnotationData:{_id:"",color:"",height:0,width:0,pdfId:"",pdfPageId:"",rotationAngle:0,x:0,y:0},rectangleAnnotationConfigurationDrawer:{isOpen:!1,sections:{color:{collapsedStatus:"collapsed",currentlySelectedColor:""}}}}),we=Le[0],ke=Le[1],xe=h((function(){for(var e=null,t=0,n=a||[];t<n.length;t++)for(var r=0,o=n[t].pages||[];r<o.length;r++)for(var c=0,i=o[r].annotations||[];c<i.length;c++){var l=i[c];if(l._id===u)return l}return e}),[u]);s((function(){(null==xe?void 0:xe.rectangleAnnotation)?ke(yse((function(e){var t;e.rectangleAnnotationConfigurationDrawer.sections.color.currentlySelectedColor=(null===(t=xe.rectangleAnnotation)||void 0===t?void 0:t.color)||""}))):(y(yse((function(e){e.measureToolRelatedData.distanceAnnotation.configurationsDrawer.isOpen=!1}))),ke(yse((function(e){e.rectangleAnnotationConfigurationDrawer.isOpen=!1}))))}),[xe]);var Se=h((function(){return{pdfs:a,setPdfs:o,annotationSelectedId:u,setAnnotationSelectedId:m,toolSelected:v,setToolSelected:f,tools:g,setTools:y,currentUserId:E,setCurrentUserId:b,users:V,setUsers:C,isLeftBarOpen:_,setIsLeftBarOpen:D,isAnnotationsVisible:j,setIsAnnotationsVisible:U,backendBaseUrl:Q,fetchPdfRelatedData:pe,removeAnnotationsFromPdfPageAndDb:Ve,addAnnotationsToPdfPage:Ce,addPdfPageImageElementIfNotPresentAlready:be,setSelectedCommentThreadId:ve,pageZoomPercentage:A,setPageZoomPercentage:R,rlefEventServiceBaseUrl:J,addNewScaleDetails:fe,addScaleButtonClickedFromToolbar:ge,pdfEditorServiceRef:Z,fetchAndSetPdfPagesInPdfWhichAreCreatedInDB:He,pdfPageIdsForWhichPageImageElementIsBeingFetched:Me,callOutToolRelatedDataWhenSelected:ue,setCallOutToolRelatedDataWhenSelected:me,pdfEditorElementId:te,selectedToolGroup:$,setSelectedToolGroup:q,pdfIdsWhoseDataBeingFetched:re,annotationSelected:xe,editScaleDetails:ze,suggestedUsersForMention:w,fetchAndSetSuggestedUsersForMention:ce,isFetchingSuggestedUsersForMention:S,customCursorToShow:Y,setCustomCursorToShow:K,rectangleRelatedData:we,setRectangleRelatedData:ke}}),[a,u,v,g,E,V,_,j,Q,pe,be,ve,A,R,J,fe,ge,He,Me,ue,te,$,re,xe,ze,w,ce,S,Y,we]);return n(kse.Provider,Aee({value:Se},{children:e.children}))}var kse=a.createContext({}),xse=function(){var e=a.useContext(kse);if(!e)throw new Error("usePdfAnnotationContext must be used within a PdfEditorContextProvider");return e};kle(".ContentArea-module_content-area-container__otXm-{align-items:center;background-color:#e3e6e8;display:flex;flex:1;justify-content:center;overflow:auto;position:relative}");kle(".PdfPage-module_pageContainer__-Q0sD{display:flex;flex-grow:1;height:100%;width:100%}.PdfPage-module_pageContainerWhenHorizontallyOverflowingAndIsVisibleInViewport__8onR1{align-self:flex-start}.PdfPage-module_justifyContentCenter__-7ATB{justify-content:center}.PdfPage-module_selectedText__m7jFl span::selection{background-color:#ffff0045!important}.PdfPage-module_selectedText__m7jFl span::-moz-selection{background-color:#ffff0045!important}.PdfPage-module_displayNone__cHRJo{display:none}.PdfPage-module_handCursor__vsE7b{cursor:grab!important}.PdfPage-module_handCursor__vsE7b:active{cursor:grabbing!important}");var Sse=Math.PI/180;const Tse=void 0!==Dee?Dee:"undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:{},Ose={_global:Tse,version:"8.4.3",isBrowser:"undefined"!=typeof window&&("[object Window]"==={}.toString.call(window)||"[object global]"==={}.toString.call(window)),isUnminified:/param/.test(function(e){}.toString()),dblClickWindow:400,getAngle:e=>Ose.angleDeg?e*Sse:e,enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:"undefined"!=typeof window&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging:()=>Ose.DD.isDragging,isDragReady:()=>!!Ose.DD.node,releaseCanvasOnDestroy:!0,document:Tse.document,_injectGlobal(e){Tse.Konva=e}},Ase=e=>{Ose[e.prototype.getClassName()]=e};Ose._injectGlobal(Ose);class Rse{constructor(e=[1,0,0,1,0,0]){this.dirty=!1,this.m=e&&e.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new Rse(this.m)}copyInto(e){e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5]}point(e){var t=this.m;return{x:t[0]*e.x+t[2]*e.y+t[4],y:t[1]*e.x+t[3]*e.y+t[5]}}translate(e,t){return this.m[4]+=this.m[0]*e+this.m[2]*t,this.m[5]+=this.m[1]*e+this.m[3]*t,this}scale(e,t){return this.m[0]*=e,this.m[1]*=e,this.m[2]*=t,this.m[3]*=t,this}rotate(e){var t=Math.cos(e),n=Math.sin(e),r=this.m[0]*t+this.m[2]*n,a=this.m[1]*t+this.m[3]*n,o=this.m[0]*-n+this.m[2]*t,c=this.m[1]*-n+this.m[3]*t;return this.m[0]=r,this.m[1]=a,this.m[2]=o,this.m[3]=c,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(e,t){var n=this.m[0]+this.m[2]*t,r=this.m[1]+this.m[3]*t,a=this.m[2]+this.m[0]*e,o=this.m[3]+this.m[1]*e;return this.m[0]=n,this.m[1]=r,this.m[2]=a,this.m[3]=o,this}multiply(e){var t=this.m[0]*e.m[0]+this.m[2]*e.m[1],n=this.m[1]*e.m[0]+this.m[3]*e.m[1],r=this.m[0]*e.m[2]+this.m[2]*e.m[3],a=this.m[1]*e.m[2]+this.m[3]*e.m[3],o=this.m[0]*e.m[4]+this.m[2]*e.m[5]+this.m[4],c=this.m[1]*e.m[4]+this.m[3]*e.m[5]+this.m[5];return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=a,this.m[4]=o,this.m[5]=c,this}invert(){var e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),t=this.m[3]*e,n=-this.m[1]*e,r=-this.m[2]*e,a=this.m[0]*e,o=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),c=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=t,this.m[1]=n,this.m[2]=r,this.m[3]=a,this.m[4]=o,this.m[5]=c,this}getMatrix(){return this.m}decompose(){var e=this.m[0],t=this.m[1],n=this.m[2],r=this.m[3],a=e*r-t*n;let o={x:this.m[4],y:this.m[5],rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(0!=e||0!=t){var c=Math.sqrt(e*e+t*t);o.rotation=t>0?Math.acos(e/c):-Math.acos(e/c),o.scaleX=c,o.scaleY=a/c,o.skewX=(e*n+t*r)/a,o.skewY=0}else if(0!=n||0!=r){var i=Math.sqrt(n*n+r*r);o.rotation=Math.PI/2-(r>0?Math.acos(-n/i):-Math.acos(n/i)),o.scaleX=a/i,o.scaleY=i,o.skewX=0,o.skewY=(e*n+t*r)/a}return o.rotation=jse._getRotation(o.rotation),o}}var Nse=Math.PI/180,_se=180/Math.PI,Dse="Konva error: ",Pse={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},Fse=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,Ise=[];const Bse="undefined"!=typeof requestAnimationFrame&&requestAnimationFrame||function(e){setTimeout(e,60)},jse={_isElement:e=>!(!e||1!=e.nodeType),_isFunction:e=>!!(e&&e.constructor&&e.call&&e.apply),_isPlainObject:e=>!!e&&e.constructor===Object,_isArray:e=>"[object Array]"===Object.prototype.toString.call(e),_isNumber:e=>"[object Number]"===Object.prototype.toString.call(e)&&!isNaN(e)&&isFinite(e),_isString:e=>"[object String]"===Object.prototype.toString.call(e),_isBoolean:e=>"[object Boolean]"===Object.prototype.toString.call(e),isObject:e=>e instanceof Object,isValidSelector(e){if("string"!=typeof e)return!1;var t=e[0];return"#"===t||"."===t||t===t.toUpperCase()},_sign:e=>0===e||e>0?1:-1,requestAnimFrame(e){Ise.push(e),1===Ise.length&&Bse((function(){const e=Ise;Ise=[],e.forEach((function(e){e()}))}))},createCanvasElement(){var e=document.createElement("canvas");try{e.style=e.style||{}}catch(e){}return e},createImageElement:()=>document.createElement("img"),_isInDocument(e){for(;e=e.parentNode;)if(e==document)return!0;return!1},_urlToImage(e,t){var n=jse.createImageElement();n.onload=function(){t(n)},n.src=e},_rgbToHex:(e,t,n)=>((1<<24)+(e<<16)+(t<<8)+n).toString(16).slice(1),_hexToRgb(e){e=e.replace("#","");var t=parseInt(e,16);return{r:t>>16&255,g:t>>8&255,b:255&t}},getRandomColor(){for(var e=(16777215*Math.random()|0).toString(16);e.length<6;)e="0"+e;return"#"+e},getRGB(e){var t;return e in Pse?{r:(t=Pse[e])[0],g:t[1],b:t[2]}:"#"===e[0]?this._hexToRgb(e.substring(1)):"rgb("===e.substr(0,4)?(t=Fse.exec(e.replace(/ /g,"")),{r:parseInt(t[1],10),g:parseInt(t[2],10),b:parseInt(t[3],10)}):{r:0,g:0,b:0}},colorToRGBA:e=>(e=e||"black",jse._namedColorToRBA(e)||jse._hex3ColorToRGBA(e)||jse._hex4ColorToRGBA(e)||jse._hex6ColorToRGBA(e)||jse._hex8ColorToRGBA(e)||jse._rgbColorToRGBA(e)||jse._rgbaColorToRGBA(e)||jse._hslColorToRGBA(e)),_namedColorToRBA(e){var t=Pse[e.toLowerCase()];return t?{r:t[0],g:t[1],b:t[2],a:1}:null},_rgbColorToRGBA(e){if(0===e.indexOf("rgb(")){var t=(e=e.match(/rgb\(([^)]+)\)/)[1]).split(/ *, */).map(Number);return{r:t[0],g:t[1],b:t[2],a:1}}},_rgbaColorToRGBA(e){if(0===e.indexOf("rgba(")){var t=(e=e.match(/rgba\(([^)]+)\)/)[1]).split(/ *, */).map(((e,t)=>"%"===e.slice(-1)?3===t?parseInt(e)/100:parseInt(e)/100*255:Number(e)));return{r:t[0],g:t[1],b:t[2],a:t[3]}}},_hex8ColorToRGBA(e){if("#"===e[0]&&9===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:parseInt(e.slice(7,9),16)/255}},_hex6ColorToRGBA(e){if("#"===e[0]&&7===e.length)return{r:parseInt(e.slice(1,3),16),g:parseInt(e.slice(3,5),16),b:parseInt(e.slice(5,7),16),a:1}},_hex4ColorToRGBA(e){if("#"===e[0]&&5===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:parseInt(e[4]+e[4],16)/255}},_hex3ColorToRGBA(e){if("#"===e[0]&&4===e.length)return{r:parseInt(e[1]+e[1],16),g:parseInt(e[2]+e[2],16),b:parseInt(e[3]+e[3],16),a:1}},_hslColorToRGBA(e){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(e)){const[t,...n]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e),r=Number(n[0])/360,a=Number(n[1])/100,o=Number(n[2])/100;let c,i,l;if(0===a)return l=255*o,{r:Math.round(l),g:Math.round(l),b:Math.round(l),a:1};c=o<.5?o*(1+a):o+a-o*a;const s=2*o-c,h=[0,0,0];for(let e=0;e<3;e++)i=r+1/3*-(e-1),i<0&&i++,i>1&&i--,l=6*i<1?s+6*(c-s)*i:2*i<1?c:3*i<2?s+(c-s)*(2/3-i)*6:s,h[e]=255*l;return{r:Math.round(h[0]),g:Math.round(h[1]),b:Math.round(h[2]),a:1}}},haveIntersection:(e,t)=>!(t.x>e.x+e.width||t.x+t.width<e.x||t.y>e.y+e.height||t.y+t.height<e.y),cloneObject(e){var t={};for(var n in e)this._isPlainObject(e[n])?t[n]=this.cloneObject(e[n]):this._isArray(e[n])?t[n]=this.cloneArray(e[n]):t[n]=e[n];return t},cloneArray:e=>e.slice(0),degToRad:e=>e*Nse,radToDeg:e=>e*_se,_degToRad:e=>(jse.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),jse.degToRad(e)),_radToDeg:e=>(jse.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),jse.radToDeg(e)),_getRotation:e=>Ose.angleDeg?jse.radToDeg(e):e,_capitalize:e=>e.charAt(0).toUpperCase()+e.slice(1),throw(e){throw new Error(Dse+e)},error(e){console.error(Dse+e)},warn(e){Ose.showWarnings&&console.warn("Konva warning: "+e)},each(e,t){for(var n in e)t(n,e[n])},_inRange:(e,t,n)=>t<=e&&e<n,_getProjectionToSegment(e,t,n,r,a,o){var c,i,l,s=(e-n)*(e-n)+(t-r)*(t-r);if(0==s)c=e,i=t,l=(a-n)*(a-n)+(o-r)*(o-r);else{var h=((a-e)*(n-e)+(o-t)*(r-t))/s;h<0?(c=e,i=t,l=(e-a)*(e-a)+(t-o)*(t-o)):h>1?(c=n,i=r,l=(n-a)*(n-a)+(r-o)*(r-o)):l=((c=e+h*(n-e))-a)*(c-a)+((i=t+h*(r-t))-o)*(i-o)}return[c,i,l]},_getProjectionToLine(e,t,n){var r=jse.cloneObject(e),a=Number.MAX_VALUE;return t.forEach((function(o,c){if(n||c!==t.length-1){var i=t[(c+1)%t.length],l=jse._getProjectionToSegment(o.x,o.y,i.x,i.y,e.x,e.y),s=l[0],h=l[1],d=l[2];d<a&&(r.x=s,r.y=h,a=d)}})),r},_prepareArrayForTween(e,t,n){var r,a=[],o=[];if(e.length>t.length){var c=t;t=e,e=c}for(r=0;r<e.length;r+=2)a.push({x:e[r],y:e[r+1]});for(r=0;r<t.length;r+=2)o.push({x:t[r],y:t[r+1]});var i=[];return o.forEach((function(e){var t=jse._getProjectionToLine(e,a,n);i.push(t.x),i.push(t.y)})),i},_prepareToStringify(e){var t;for(var n in e.visitedByCircularReferenceRemoval=!0,e)if(e.hasOwnProperty(n)&&e[n]&&"object"==typeof e[n])if(t=Object.getOwnPropertyDescriptor(e,n),e[n].visitedByCircularReferenceRemoval||jse._isElement(e[n])){if(!t.configurable)return null;delete e[n]}else if(null===jse._prepareToStringify(e[n])){if(!t.configurable)return null;delete e[n]}return delete e.visitedByCircularReferenceRemoval,e},_assign(e,t){for(var n in t)e[n]=t[n];return e},_getFirstPointerId:e=>e.touches?e.changedTouches[0].identifier:e.pointerId||999,releaseCanvas(...e){Ose.releaseCanvasOnDestroy&&e.forEach((e=>{e.width=0,e.height=0}))},drawRoundedRectPath(e,t,n,r){let a=0,o=0,c=0,i=0;"number"==typeof r?a=o=c=i=Math.min(r,t/2,n/2):(a=Math.min(r[0]||0,t/2,n/2),o=Math.min(r[1]||0,t/2,n/2),i=Math.min(r[2]||0,t/2,n/2),c=Math.min(r[3]||0,t/2,n/2)),e.moveTo(a,0),e.lineTo(t-o,0),e.arc(t-o,o,o,3*Math.PI/2,0,!1),e.lineTo(t,n-i),e.arc(t-i,n-i,i,0,Math.PI/2,!1),e.lineTo(c,n),e.arc(c,n-c,c,Math.PI/2,Math.PI,!1),e.lineTo(0,a),e.arc(a,a,a,Math.PI,3*Math.PI/2,!1)}};function Use(e){return jse._isString(e)?'"'+e+'"':"[object Number]"===Object.prototype.toString.call(e)||jse._isBoolean(e)?e:Object.prototype.toString.call(e)}function Wse(e){return e>255?255:e<0?0:Math.round(e)}function $se(){if(Ose.isUnminified)return function(e,t){return jse._isNumber(e)||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a number.'),e}}function qse(e){if(Ose.isUnminified)return function(t,n){let r=jse._isNumber(t),a=jse._isArray(t)&&t.length==e;return r||a||jse.warn(Use(t)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+e+")"),t}}function Gse(){if(Ose.isUnminified)return function(e,t){return jse._isNumber(e)||"auto"===e||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a number or "auto".'),e}}function Yse(){if(Ose.isUnminified)return function(e,t){return jse._isString(e)||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a string.'),e}}function Kse(){if(Ose.isUnminified)return function(e,t){const n=jse._isString(e),r="[object CanvasGradient]"===Object.prototype.toString.call(e)||e&&e.addColorStop;return n||r||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a string or a native gradient.'),e}}function Xse(){if(Ose.isUnminified)return function(e,t){return!0===e||!1===e||jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a boolean.'),e}}var Qse="get",Jse="set";const Zse={addGetterSetter(e,t,n,r,a){Zse.addGetter(e,t,n),Zse.addSetter(e,t,r,a),Zse.addOverloadedGetterSetter(e,t)},addGetter(e,t,n){var r=Qse+jse._capitalize(t);e.prototype[r]=e.prototype[r]||function(){var e=this.attrs[t];return void 0===e?n:e}},addSetter(e,t,n,r){var a=Jse+jse._capitalize(t);e.prototype[a]||Zse.overWriteSetter(e,t,n,r)},overWriteSetter(e,t,n,r){var a=Jse+jse._capitalize(t);e.prototype[a]=function(e){return n&&null!=e&&(e=n.call(this,e,t)),this._setAttr(t,e),r&&r.call(this),this}},addComponentsGetterSetter(e,t,n,r,a){var o,c,i=n.length,l=jse._capitalize,s=Qse+l(t),h=Jse+l(t);e.prototype[s]=function(){var e={};for(o=0;o<i;o++)e[c=n[o]]=this.getAttr(t+l(c));return e};var d=function(e){if(Ose.isUnminified)return function(t,n){return null==t||jse.isObject(t)||jse.warn(Use(t)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+e),t}}(n);e.prototype[h]=function(e){var o,c=this.attrs[t];for(o in r&&(e=r.call(this,e)),d&&d.call(this,e,t),e)e.hasOwnProperty(o)&&this._setAttr(t+l(o),e[o]);return e||n.forEach((e=>{this._setAttr(t+l(e),void 0)})),this._fireChangeEvent(t,c,e),a&&a.call(this),this},Zse.addOverloadedGetterSetter(e,t)},addOverloadedGetterSetter(e,t){var n=jse._capitalize(t),r=Jse+n,a=Qse+n;e.prototype[t]=function(){return arguments.length?(this[r](arguments[0]),this):this[a]()}},addDeprecatedGetterSetter(e,t,n,r){jse.error("Adding deprecated "+t);var a=Qse+jse._capitalize(t),o=t+" property is deprecated and will be removed soon. Look at Konva change log for more information.";e.prototype[a]=function(){jse.error(o);var e=this.attrs[t];return void 0===e?n:e},Zse.addSetter(e,t,r,(function(){jse.error(o)})),Zse.addOverloadedGetterSetter(e,t)},backCompat(e,t){jse.each(t,(function(t,n){var r=e.prototype[n],a=Qse+jse._capitalize(t),o=Jse+jse._capitalize(t);function c(){r.apply(this,arguments),jse.error('"'+t+'" method is deprecated and will be removed soon. Use ""'+n+'" instead.')}e.prototype[t]=c,e.prototype[a]=c,e.prototype[o]=c}))},afterSetFilter(){this._filterUpToDate=!1}};var ehe,the=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"];class nhe{constructor(e){this.canvas=e,Ose.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,t){var n,r,a,o,c=this.traceArr,i=c.length,l="";for(n=0;n<i;n++)(a=(r=c[n]).method)?(o=r.args,l+=a,e?l+="()":jse._isArray(o[0])?l+="(["+o.join(",")+"])":(t&&(o=o.map((e=>"number"==typeof e?Math.floor(e):e))),l+="("+o.join(",")+")")):(l+=r.property,e||(l+="="+r.val)),l+=";";return l}clearTrace(){this.traceArr=[]}_trace(e){var t=this.traceArr;t.push(e),t.length>=100&&t.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var t=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,t.getWidth()/t.pixelRatio,t.getHeight()/t.pixelRatio)}_applyLineCap(e){const t=e.attrs.lineCap;t&&this.setAttr("lineCap",t)}_applyOpacity(e){var t=e.getAbsoluteOpacity();1!==t&&this.setAttr("globalAlpha",t)}_applyLineJoin(e){const t=e.attrs.lineJoin;t&&this.setAttr("lineJoin",t)}setAttr(e,t){this._context[e]=t}arc(e,t,n,r,a,o){this._context.arc(e,t,n,r,a,o)}arcTo(e,t,n,r,a){this._context.arcTo(e,t,n,r,a)}beginPath(){this._context.beginPath()}bezierCurveTo(e,t,n,r,a,o){this._context.bezierCurveTo(e,t,n,r,a,o)}clearRect(e,t,n,r){this._context.clearRect(e,t,n,r)}clip(){this._context.clip()}closePath(){this._context.closePath()}createImageData(e,t){var n=arguments;return 2===n.length?this._context.createImageData(e,t):1===n.length?this._context.createImageData(e):void 0}createLinearGradient(e,t,n,r){return this._context.createLinearGradient(e,t,n,r)}createPattern(e,t){return this._context.createPattern(e,t)}createRadialGradient(e,t,n,r,a,o){return this._context.createRadialGradient(e,t,n,r,a,o)}drawImage(e,t,n,r,a,o,c,i,l){var s=arguments,h=this._context;3===s.length?h.drawImage(e,t,n):5===s.length?h.drawImage(e,t,n,r,a):9===s.length&&h.drawImage(e,t,n,r,a,o,c,i,l)}ellipse(e,t,n,r,a,o,c,i){this._context.ellipse(e,t,n,r,a,o,c,i)}isPointInPath(e,t,n,r){return n?this._context.isPointInPath(n,e,t,r):this._context.isPointInPath(e,t,r)}fill(e){e?this._context.fill(e):this._context.fill()}fillRect(e,t,n,r){this._context.fillRect(e,t,n,r)}strokeRect(e,t,n,r){this._context.strokeRect(e,t,n,r)}fillText(e,t,n,r){r?this._context.fillText(e,t,n,r):this._context.fillText(e,t,n)}measureText(e){return this._context.measureText(e)}getImageData(e,t,n,r){return this._context.getImageData(e,t,n,r)}lineTo(e,t){this._context.lineTo(e,t)}moveTo(e,t){this._context.moveTo(e,t)}rect(e,t,n,r){this._context.rect(e,t,n,r)}putImageData(e,t,n){this._context.putImageData(e,t,n)}quadraticCurveTo(e,t,n,r){this._context.quadraticCurveTo(e,t,n,r)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,t){this._context.scale(e,t)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,t,n,r,a,o){this._context.setTransform(e,t,n,r,a,o)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,t,n,r){this._context.strokeText(e,t,n,r)}transform(e,t,n,r,a,o){this._context.transform(e,t,n,r,a,o)}translate(e,t){this._context.translate(e,t)}_enableTrace(){var e,t,n=this,r=the.length,a=this.setAttr,o=function(e){var r,a=n[e];n[e]=function(){return t=function(e){var t,n,r=[],a=e.length,o=jse;for(t=0;t<a;t++)n=e[t],o._isNumber(n)?n=Math.round(1e3*n)/1e3:o._isString(n)||(n+=""),r.push(n);return r}(Array.prototype.slice.call(arguments,0)),r=a.apply(n,arguments),n._trace({method:e,args:t}),r}};for(e=0;e<r;e++)o(the[e]);n.setAttr=function(){a.apply(n,arguments);var e=arguments[0],t=arguments[1];"shadowOffsetX"!==e&&"shadowOffsetY"!==e&&"shadowBlur"!==e||(t/=this.canvas.getPixelRatio()),n._trace({property:e,val:t})}}_applyGlobalCompositeOperation(e){const t=e.attrs.globalCompositeOperation;!t||"source-over"===t||this.setAttr("globalCompositeOperation",t)}}["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"].forEach((function(e){Object.defineProperty(nhe.prototype,e,{get(){return this._context[e]},set(t){this._context[e]=t}})}));class rhe extends nhe{constructor(e){super(e),this._context=e._canvas.getContext("2d")}_fillColor(e){var t=e.fill();this.setAttr("fillStyle",t),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var t=e._getLinearGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fillRadialGradient(e){const t=e._getRadialGradient();t&&(this.setAttr("fillStyle",t),e._fillFunc(this))}_fill(e){const t=e.fill(),n=e.getFillPriority();if(t&&"color"===n)return void this._fillColor(e);const r=e.getFillPatternImage();if(r&&"pattern"===n)return void this._fillPattern(e);const a=e.getFillLinearGradientColorStops();if(a&&"linear-gradient"===n)return void this._fillLinearGradient(e);const o=e.getFillRadialGradientColorStops();o&&"radial-gradient"===n?this._fillRadialGradient(e):t?this._fillColor(e):r?this._fillPattern(e):a?this._fillLinearGradient(e):o&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const t=e.getStrokeLinearGradientStartPoint(),n=e.getStrokeLinearGradientEndPoint(),r=e.getStrokeLinearGradientColorStops(),a=this.createLinearGradient(t.x,t.y,n.x,n.y);if(r){for(var o=0;o<r.length;o+=2)a.addColorStop(r[o],r[o+1]);this.setAttr("strokeStyle",a)}}_stroke(e){var t=e.dash(),n=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!n){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e),t&&e.dashEnabled()&&(this.setLineDash(t),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)"),e.getStrokeLinearGradientColorStops()?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),n||this.restore()}}_applyShadow(e){var t,n,r,a=null!==(t=e.getShadowRGBA())&&void 0!==t?t:"black",o=null!==(n=e.getShadowBlur())&&void 0!==n?n:5,c=null!==(r=e.getShadowOffset())&&void 0!==r?r:{x:0,y:0},i=e.getAbsoluteScale(),l=this.canvas.getPixelRatio(),s=i.x*l,h=i.y*l;this.setAttr("shadowColor",a),this.setAttr("shadowBlur",o*Math.min(Math.abs(s),Math.abs(h))),this.setAttr("shadowOffsetX",c.x*s),this.setAttr("shadowOffsetY",c.y*h)}}class ahe extends nhe{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const a=e.getStrokeScaleEnabled();if(!a){this.save();var t=this.getCanvas().getPixelRatio();this.setTransform(t,0,0,t,0,0)}this._applyLineCap(e);var n=e.hitStrokeWidth(),r="auto"===n?e.strokeWidth():n;this.setAttr("lineWidth",r),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),a||this.restore()}}}class ohe{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var t=(e||{}).pixelRatio||Ose.pixelRatio||function(){if(ehe)return ehe;var e=jse.createCanvasElement(),t=e.getContext("2d");return ehe=(Ose._global.devicePixelRatio||1)/(t.webkitBackingStorePixelRatio||t.mozBackingStorePixelRatio||t.msBackingStorePixelRatio||t.oBackingStorePixelRatio||t.backingStorePixelRatio||1),jse.releaseCanvas(e),ehe}();this.pixelRatio=t,this._canvas=jse.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var t=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/t,this.getHeight()/t)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var t=this.pixelRatio;this.getContext()._context.scale(t,t)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,t){this.setWidth(e||0),this.setHeight(t||0)}toDataURL(e,t){try{return this._canvas.toDataURL(e,t)}catch(e){try{return this._canvas.toDataURL()}catch(e){return jse.error("Unable to get data URL. "+e.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Zse.addGetterSetter(ohe,"pixelRatio",void 0,$se());class che extends ohe{constructor(e={width:0,height:0}){super(e),this.context=new rhe(this),this.setSize(e.width,e.height)}}class ihe extends ohe{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new ahe(this),this.setSize(e.width,e.height)}}const lhe={get isDragging(){var e=!1;return lhe._dragElements.forEach((t=>{"dragging"===t.dragStatus&&(e=!0)})),e},justDragged:!1,get node(){var e;return lhe._dragElements.forEach((t=>{e=t.node})),e},_dragElements:new Map,_drag(e){const t=[];lhe._dragElements.forEach(((n,r)=>{const{node:a}=n,o=a.getStage();o.setPointersPositions(e),void 0===n.pointerId&&(n.pointerId=jse._getFirstPointerId(e));const c=o._changedPointerPositions.find((e=>e.id===n.pointerId));if(c){if("dragging"!==n.dragStatus){var i=a.dragDistance();if(Math.max(Math.abs(c.x-n.startPointerPos.x),Math.abs(c.y-n.startPointerPos.y))<i)return;if(a.startDrag({evt:e}),!a.isDragging())return}a._setDragPosition(e,n),t.push(a)}})),t.forEach((t=>{t.fire("dragmove",{type:"dragmove",target:t,evt:e},!0)}))},_endDragBefore(e){const t=[];lhe._dragElements.forEach((n=>{const{node:r}=n,a=r.getStage();if(e&&a.setPointersPositions(e),!a._changedPointerPositions.find((e=>e.id===n.pointerId)))return;"dragging"!==n.dragStatus&&"stopped"!==n.dragStatus||(lhe.justDragged=!0,Ose._mouseListenClick=!1,Ose._touchListenClick=!1,Ose._pointerListenClick=!1,n.dragStatus="stopped");const o=n.node.getLayer()||n.node instanceof Ose.Stage&&n.node;o&&-1===t.indexOf(o)&&t.push(o)})),t.forEach((e=>{e.draw()}))},_endDragAfter(e){lhe._dragElements.forEach(((t,n)=>{"stopped"===t.dragStatus&&t.node.fire("dragend",{type:"dragend",target:t.node,evt:e},!0),"dragging"!==t.dragStatus&&lhe._dragElements.delete(n)}))}};Ose.isBrowser&&(window.addEventListener("mouseup",lhe._endDragBefore,!0),window.addEventListener("touchend",lhe._endDragBefore,!0),window.addEventListener("mousemove",lhe._drag),window.addEventListener("touchmove",lhe._drag),window.addEventListener("mouseup",lhe._endDragAfter,!1),window.addEventListener("touchend",lhe._endDragAfter,!1));var she="absoluteOpacity",hhe="allEventListeners",dhe="absoluteTransform",uhe="absoluteScale",mhe="canvas",phe="listening",vhe="mouseenter",fhe="mouseleave",zhe="Shape",ghe=" ",yhe="stage",Mhe="transform",Ehe="visible",bhe=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(ghe);let Hhe=1;class Vhe{constructor(e){this._id=Hhe++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){e!==Mhe&&e!==dhe||!this._cache.get(e)?e?this._cache.delete(e):this._cache.clear():this._cache.get(e).dirty=!0}_getCache(e,t){var n=this._cache.get(e);return(void 0===n||(e===Mhe||e===dhe)&&!0===n.dirty)&&(n=t.call(this),this._cache.set(e,n)),n}_calculate(e,t,n){if(!this._attachedDepsListeners.get(e)){const n=t.map((e=>e+"Change.konva")).join(ghe);this.on(n,(()=>{this._clearCache(e)})),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,n)}_getCanvasCache(){return this._cache.get(mhe)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===dhe&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(mhe)){const{scene:e,filter:t,hit:n}=this._cache.get(mhe);jse.releaseCanvas(e,t,n),this._cache.delete(mhe)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var t=e||{},n={};void 0!==t.x&&void 0!==t.y&&void 0!==t.width&&void 0!==t.height||(n=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()}));var r=Math.ceil(t.width||n.width),a=Math.ceil(t.height||n.height),o=t.pixelRatio,c=void 0===t.x?Math.floor(n.x):t.x,i=void 0===t.y?Math.floor(n.y):t.y,l=t.offset||0,s=t.drawBorder||!1,h=t.hitCanvasPixelRatio||1;if(r&&a){c-=l,i-=l;var d=new che({pixelRatio:o,width:r+=2*l+1,height:a+=2*l+1}),u=new che({pixelRatio:o,width:0,height:0}),m=new ihe({pixelRatio:h,width:r,height:a}),p=d.getContext(),v=m.getContext();return m.isCache=!0,d.isCache=!0,this._cache.delete(mhe),this._filterUpToDate=!1,!1===t.imageSmoothingEnabled&&(d.getContext()._context.imageSmoothingEnabled=!1,u.getContext()._context.imageSmoothingEnabled=!1),p.save(),v.save(),p.translate(-c,-i),v.translate(-c,-i),this._isUnderCache=!0,this._clearSelfAndDescendantCache(she),this._clearSelfAndDescendantCache(uhe),this.drawScene(d,this),this.drawHit(m,this),this._isUnderCache=!1,p.restore(),v.restore(),s&&(p.save(),p.beginPath(),p.rect(0,0,r,a),p.closePath(),p.setAttr("strokeStyle","red"),p.setAttr("lineWidth",5),p.stroke(),p.restore()),this._cache.set(mhe,{scene:d,filter:u,hit:m,x:c,y:i}),this._requestDraw(),this}jse.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.")}isCached(){return this._cache.has(mhe)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,t){var n,r,a,o,c=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],i=this.getAbsoluteTransform(t);return c.forEach((function(e){var t=i.point(e);void 0===n&&(n=a=t.x,r=o=t.y),n=Math.min(n,t.x),r=Math.min(r,t.y),a=Math.max(a,t.x),o=Math.max(o,t.y)})),{x:n,y:r,width:a-n,height:o-r}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const t=this._getCanvasCache();e.translate(t.x,t.y);var n=this._getCachedSceneCanvas(),r=n.pixelRatio;e.drawImage(n._canvas,0,0,n.width/r,n.height/r),e.restore()}_drawCachedHitCanvas(e){var t=this._getCanvasCache(),n=t.hit;e.save(),e.translate(t.x,t.y),e.drawImage(n._canvas,0,0,n.width/n.pixelRatio,n.height/n.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e,t,n,r,a=this.filters(),o=this._getCanvasCache(),c=o.scene,i=o.filter,l=i.getContext();if(a){if(!this._filterUpToDate){var s=c.pixelRatio;i.setSize(c.width/c.pixelRatio,c.height/c.pixelRatio);try{for(e=a.length,l.clear(),l.drawImage(c._canvas,0,0,c.getWidth()/s,c.getHeight()/s),t=l.getImageData(0,0,i.getWidth(),i.getHeight()),n=0;n<e;n++)"function"==typeof(r=a[n])?(r.call(this,t),l.putImageData(t,0,0)):jse.error("Filter should be type of function, but got "+typeof r+" instead. Please check correct filters")}catch(e){jse.error("Unable to apply filter. "+e.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return i}return c}on(e,t){if(this._cache&&this._cache.delete(hhe),3===arguments.length)return this._delegate.apply(this,arguments);var n,r,a,o,c=e.split(ghe),i=c.length;for(n=0;n<i;n++)a=(r=c[n].split("."))[0],o=r[1]||"",this.eventListeners[a]||(this.eventListeners[a]=[]),this.eventListeners[a].push({name:o,handler:t});return this}off(e,t){var n,r,a,o,c,i=(e||"").split(ghe),l=i.length;if(this._cache&&this._cache.delete(hhe),!e)for(r in this.eventListeners)this._off(r);for(n=0;n<l;n++)if(o=(a=i[n].split("."))[0],c=a[1],o)this.eventListeners[o]&&this._off(o,c,t);else for(r in this.eventListeners)this._off(r,c,t);return this}dispatchEvent(e){var t={target:this,type:e.type,evt:e};return this.fire(e.type,t),this}addEventListener(e,t){return this.on(e,(function(e){t.call(this,e.evt)})),this}removeEventListener(e){return this.off(e),this}_delegate(e,t,n){var r=this;this.on(e,(function(e){for(var a=e.target.findAncestors(t,!0,r),o=0;o<a.length;o++)(e=jse.cloneObject(e)).currentTarget=a[o],n.call(a[o],e)}))}remove(){return this.isDragging()&&this.stopDrag(),lhe._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(dhe),this._clearSelfAndDescendantCache(she),this._clearSelfAndDescendantCache(uhe),this._clearSelfAndDescendantCache(yhe),this._clearSelfAndDescendantCache(Ehe),this._clearSelfAndDescendantCache(phe)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var t="get"+jse._capitalize(e);return jse._isFunction(this[t])?this[t]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),t=[];e;)t.push(e),e=e.getParent();return t}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges((()=>{var t,n;if(!e)return this;for(t in e)"children"!==t&&(n="set"+jse._capitalize(t),jse._isFunction(this[n])?this[n](e[t]):this._setAttr(t,e[t]))})),this}isListening(){return this._getCache(phe,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return!t||t===e||this===e||t._isListening(e)}isVisible(){return this._getCache(Ehe,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return!t||t===e||this===e||t._isVisible(e)}shouldDrawHit(e,t=!1){if(e)return this._isVisible(e)&&this._isListening(e);var n=this.getLayer(),r=!1;lhe._dragElements.forEach((e=>{"dragging"===e.dragStatus&&("Stage"===e.node.nodeType||e.node.getLayer()===n)&&(r=!0)}));var a=!t&&!Ose.hitOnDragEnabled&&r;return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e,t,n,r,a=this.getDepth(),o=this,c=0;return"Stage"!==o.nodeType&&function i(l){for(e=[],t=l.length,n=0;n<t;n++)r=l[n],c++,r.nodeType!==zhe&&(e=e.concat(r.getChildren().slice())),r._id===o._id&&(n=t);e.length>0&&e[0].getDepth()<=a&&i(e)}(o.getStage().getChildren()),c}getDepth(){for(var e=0,t=this.parent;t;)e++,t=t.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(Mhe),this._clearSelfAndDescendantCache(dhe)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges((()=>{this.x(e.x),this.y(e.y)})),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){if(!this.getStage())return null;var e=this.getStage().getPointerPosition();if(!e)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(e)}getAbsolutePosition(e){let t=!1,n=this.parent;for(;n;){if(n.isCached()){t=!0;break}n=n.parent}t&&!e&&(e=!0);var r=this.getAbsoluteTransform(e).getMatrix(),a=new Rse,o=this.offset();return a.m=r.slice(),a.translate(o.x,o.y),a.getTranslation()}setAbsolutePosition(e){var t=this._clearTransform();this.attrs.x=t.x,this.attrs.y=t.y,delete t.x,delete t.y,this._clearCache(Mhe);var n=this._getAbsoluteTransform().copy();return n.invert(),n.translate(e.x,e.y),e={x:this.attrs.x+n.getTranslation().x,y:this.attrs.y+n.getTranslation().y},this._setTransform(t),this.setPosition({x:e.x,y:e.y}),this._clearCache(Mhe),this._clearSelfAndDescendantCache(dhe),this}_setTransform(e){var t;for(t in e)this.attrs[t]=e[t]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var t=e.x,n=e.y,r=this.x(),a=this.y();return void 0!==t&&(r+=t),void 0!==n&&(a+=n),this.setPosition({x:r,y:a}),this}_eachAncestorReverse(e,t){var n,r,a=[],o=this.getParent();if(!t||t._id!==this._id){for(a.unshift(this);o&&(!t||o._id!==t._id);)a.unshift(o),o=o.parent;for(n=a.length,r=0;r<n;r++)e(a[r])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return jse.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0)}moveUp(){if(!this.parent)return jse.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index;return e<this.parent.getChildren().length-1&&(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0)}moveDown(){if(!this.parent)return jse.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0)}moveToBottom(){if(!this.parent)return jse.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0&&(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0)}setZIndex(e){if(!this.parent)return jse.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&jse.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var t=this.index;return this.parent.children.splice(t,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(she,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),t=this.getParent();return t&&!t._isUnderCache&&(e*=t.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e,t,n,r,a={},o=this.getAttrs();for(e in a.attrs={},o)t=o[e],jse.isObject(t)&&!jse._isPlainObject(t)&&!jse._isArray(t)||(n="function"==typeof this[e]&&this[e],delete o[e],r=n?n.call(this):null,o[e]=t,r!==t&&(a.attrs[e]=t));return a.className=this.getClassName(),jse._prepareToStringify(a)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,t,n){var r=[];t&&this._isMatch(e)&&r.push(this);for(var a=this.parent;a;){if(a===n)return r;a._isMatch(e)&&r.push(a),a=a.parent}return r}isAncestorOf(e){return!1}findAncestor(e,t,n){return this.findAncestors(e,t,n)[0]}_isMatch(e){if(!e)return!1;if("function"==typeof e)return e(this);var t,n,r=e.replace(/ /g,"").split(","),a=r.length;for(t=0;t<a;t++)if(n=r[t],jse.isValidSelector(n)||(jse.warn('Selector "'+n+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),jse.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),jse.warn("Konva is awesome, right?")),"#"===n.charAt(0)){if(this.id()===n.slice(1))return!0}else if("."===n.charAt(0)){if(this.hasName(n.slice(1)))return!0}else if(this.className===n||this.nodeType===n)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(yhe,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():void 0}fire(e,t={},n){return t.target=t.target||this,n?this._fireAndBubble(e,t):this._fire(e,t),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(dhe,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var t;if(e)return t=new Rse,this._eachAncestorReverse((function(e){var n=e.transformsEnabled();"all"===n?t.multiply(e.getTransform()):"position"===n&&t.translate(e.x()-e.offsetX(),e.y()-e.offsetY())}),e),t;t=this._cache.get(dhe)||new Rse,this.parent?this.parent.getAbsoluteTransform().copyInto(t):t.reset();var n=this.transformsEnabled();if("all"===n)t.multiply(this.getTransform());else if("position"===n){const e=this.attrs.x||0,n=this.attrs.y||0,r=this.attrs.offsetX||0,a=this.attrs.offsetY||0;t.translate(e-r,n-a)}return t.dirty=!1,t}getAbsoluteScale(e){for(var t=this;t;)t._isUnderCache&&(e=t),t=t.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(Mhe,this._getTransform)}_getTransform(){var e,t,n=this._cache.get(Mhe)||new Rse;n.reset();var r=this.x(),a=this.y(),o=Ose.getAngle(this.rotation()),c=null!==(e=this.attrs.scaleX)&&void 0!==e?e:1,i=null!==(t=this.attrs.scaleY)&&void 0!==t?t:1,l=this.attrs.skewX||0,s=this.attrs.skewY||0,h=this.attrs.offsetX||0,d=this.attrs.offsetY||0;return 0===r&&0===a||n.translate(r,a),0!==o&&n.rotate(o),0===l&&0===s||n.skew(l,s),1===c&&1===i||n.scale(c,i),0===h&&0===d||n.translate(-1*h,-1*d),n.dirty=!1,n}clone(e){var t,n,r,a,o,c=jse.cloneObject(this.attrs);for(t in e)c[t]=e[t];var i=new this.constructor(c);for(t in this.eventListeners)for(r=(n=this.eventListeners[t]).length,a=0;a<r;a++)(o=n[a]).name.indexOf("konva")<0&&(i.eventListeners[t]||(i.eventListeners[t]=[]),i.eventListeners[t].push(o));return i}_toKonvaCanvas(e){e=e||{};var t=this.getClientRect(),n=this.getStage(),r=void 0!==e.x?e.x:Math.floor(t.x),a=void 0!==e.y?e.y:Math.floor(t.y),o=e.pixelRatio||1,c=new che({width:e.width||Math.ceil(t.width)||(n?n.width():0),height:e.height||Math.ceil(t.height)||(n?n.height():0),pixelRatio:o}),i=c.getContext();return!1===e.imageSmoothingEnabled&&(i._context.imageSmoothingEnabled=!1),i.save(),(r||a)&&i.translate(-1*r,-1*a),this.drawScene(c),i.restore(),c}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){var t=(e=e||{}).mimeType||null,n=e.quality||null,r=this._toKonvaCanvas(e).toDataURL(t,n);return e.callback&&e.callback(r),r}toImage(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,jse._urlToImage(this.toDataURL(e),(function(e){t(e),null==n||n(e)}))}catch(e){n(e)}}))}toBlob(e){return new Promise(((t,n)=>{try{const n=null==e?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob((e=>{t(e),null==n||n(e)}))}catch(e){n(e)}}))}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return void 0!==this.attrs.dragDistance?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Ose.dragDistance}_off(e,t,n){var r,a,o,c=this.eventListeners[e];for(r=0;r<c.length;r++)if(a=c[r].name,o=c[r].handler,!("konva"===a&&"konva"!==t||t&&a!==t||n&&n!==o)){if(c.splice(r,1),0===c.length){delete this.eventListeners[e];break}r--}}_fireChangeEvent(e,t,n){this._fire(e+"Change",{oldVal:t,newVal:n})}addName(e){if(!this.hasName(e)){var t=this.name(),n=t?t+" "+e:e;this.name(n)}return this}hasName(e){if(!e)return!1;const t=this.name();return!!t&&-1!==(t||"").split(/\s/g).indexOf(e)}removeName(e){var t=(this.name()||"").split(/\s/g),n=t.indexOf(e);return-1!==n&&(t.splice(n,1),this.name(t.join(" "))),this}setAttr(e,t){var n=this["set"+jse._capitalize(e)];return jse._isFunction(n)?n.call(this,t):this._setAttr(e,t),this}_requestDraw(){if(Ose.autoDrawEnabled){const e=this.getLayer()||this.getStage();null==e||e.batchDraw()}}_setAttr(e,t){var n=this.attrs[e];(n!==t||jse.isObject(t))&&(null==t?delete this.attrs[e]:this.attrs[e]=t,this._shouldFireChangeEvents&&this._fireChangeEvent(e,n,t),this._requestDraw())}_setComponentAttr(e,t,n){var r;void 0!==n&&((r=this.attrs[e])||(this.attrs[e]=this.getAttr(e)),this.attrs[e][t]=n,this._fireChangeEvent(e,r,n))}_fireAndBubble(e,t,n){if(t&&this.nodeType===zhe&&(t.target=this),e!==vhe&&e!==fhe||!(n&&(this===n||this.isAncestorOf&&this.isAncestorOf(n))||"Stage"===this.nodeType&&!n)){this._fire(e,t);var r=(e===vhe||e===fhe)&&n&&n.isAncestorOf&&n.isAncestorOf(this)&&!n.isAncestorOf(this.parent);(t&&!t.cancelBubble||!t)&&this.parent&&this.parent.isListening()&&!r&&(n&&n.parent?this._fireAndBubble.call(this.parent,e,t,n):this._fireAndBubble.call(this.parent,e,t))}}_getProtoListeners(e){let t=this._cache.get(hhe);if(!t){t={};let e=Object.getPrototypeOf(this);for(;e;)if(e.eventListeners){for(var n in e.eventListeners){const r=e.eventListeners[n],a=t[n]||[];t[n]=r.concat(a)}e=Object.getPrototypeOf(e)}else e=Object.getPrototypeOf(e);this._cache.set(hhe,t)}return t[e]}_fire(e,t){(t=t||{}).currentTarget=this,t.type=e;const n=this._getProtoListeners(e);if(n)for(var r=0;r<n.length;r++)n[r].handler.call(this,t);const a=this.eventListeners[e];if(a)for(r=0;r<a.length;r++)a[r].handler.call(this,t)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var t=e?e.pointerId:void 0,n=this.getStage(),r=this.getAbsolutePosition(),a=n._getPointerById(t)||n._changedPointerPositions[0]||r;lhe._dragElements.set(this._id,{node:this,startPointerPos:a,offset:{x:a.x-r.x,y:a.y-r.y},dragStatus:"ready",pointerId:t})}startDrag(e,t=!0){lhe._dragElements.has(this._id)||this._createDragElement(e),lhe._dragElements.get(this._id).dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},t)}_setDragPosition(e,t){const n=this.getStage()._getPointerById(t.pointerId);if(n){var r={x:n.x-t.offset.x,y:n.y-t.offset.y},a=this.dragBoundFunc();if(void 0!==a){const t=a.call(this,r,e);t?r=t:jse.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}this._lastPos&&this._lastPos.x===r.x&&this._lastPos.y===r.y||(this.setAbsolutePosition(r),this._requestDraw()),this._lastPos=r}}stopDrag(e){const t=lhe._dragElements.get(this._id);t&&(t.dragStatus="stopped"),lhe._endDragBefore(e),lhe._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=lhe._dragElements.get(this._id);return!!e&&"dragging"===e.dragStatus}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",(function(e){if((void 0===e.evt.button||Ose.dragButtons.indexOf(e.evt.button)>=0)&&!this.isDragging()){var t=!1;lhe._dragElements.forEach((e=>{this.isAncestorOf(e.node)&&(t=!0)})),t||this._createDragElement(e)}}))}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{if(this._dragCleanup(),!this.getStage())return;const e=lhe._dragElements.get(this._id),t=e&&"dragging"===e.dragStatus,n=e&&"ready"===e.dragStatus;t?this.stopDrag():n&&lhe._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const t=this.getStage();if(!t)return!1;const n={x:-e.x,y:-e.y,width:t.width()+2*e.x,height:t.height()+2*e.y};return jse.haveIntersection(n,this.getClientRect())}static create(e,t){return jse._isString(e)&&(e=JSON.parse(e)),this._createNode(e,t)}static _createNode(e,t){var n,r,a,o=Vhe.prototype.getClassName.call(e),c=e.children;if(t&&(e.attrs.container=t),Ose[o]||(jse.warn('Can not find a node with class name "'+o+'". Fallback to "Shape".'),o="Shape"),n=new Ose[o](e.attrs),c)for(r=c.length,a=0;a<r;a++)n.add(Vhe._createNode(c[a]));return n}}Vhe.prototype.nodeType="Node",Vhe.prototype._attrsAffectingSize=[],Vhe.prototype.eventListeners={},Vhe.prototype.on.call(Vhe.prototype,bhe,(function(){this._batchingTransformChange?this._needClearTransformCache=!0:(this._clearCache(Mhe),this._clearSelfAndDescendantCache(dhe))})),Vhe.prototype.on.call(Vhe.prototype,"visibleChange.konva",(function(){this._clearSelfAndDescendantCache(Ehe)})),Vhe.prototype.on.call(Vhe.prototype,"listeningChange.konva",(function(){this._clearSelfAndDescendantCache(phe)})),Vhe.prototype.on.call(Vhe.prototype,"opacityChange.konva",(function(){this._clearSelfAndDescendantCache(she)}));const Che=Zse.addGetterSetter;Che(Vhe,"zIndex"),Che(Vhe,"absolutePosition"),Che(Vhe,"position"),Che(Vhe,"x",0,$se()),Che(Vhe,"y",0,$se()),Che(Vhe,"globalCompositeOperation","source-over",Yse()),Che(Vhe,"opacity",1,$se()),Che(Vhe,"name","",Yse()),Che(Vhe,"id","",Yse()),Che(Vhe,"rotation",0,$se()),Zse.addComponentsGetterSetter(Vhe,"scale",["x","y"]),Che(Vhe,"scaleX",1,$se()),Che(Vhe,"scaleY",1,$se()),Zse.addComponentsGetterSetter(Vhe,"skew",["x","y"]),Che(Vhe,"skewX",0,$se()),Che(Vhe,"skewY",0,$se()),Zse.addComponentsGetterSetter(Vhe,"offset",["x","y"]),Che(Vhe,"offsetX",0,$se()),Che(Vhe,"offsetY",0,$se()),Che(Vhe,"dragDistance",null,$se()),Che(Vhe,"width",0,$se()),Che(Vhe,"height",0,$se()),Che(Vhe,"listening",!0,Xse()),Che(Vhe,"preventDefault",!0,Xse()),Che(Vhe,"filters",null,(function(e){return this._filterUpToDate=!1,e})),Che(Vhe,"visible",!0,Xse()),Che(Vhe,"transformsEnabled","all",Yse()),Che(Vhe,"size"),Che(Vhe,"dragBoundFunc"),Che(Vhe,"draggable",!1,Xse()),Zse.backCompat(Vhe,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});class Lhe extends Vhe{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const t=this.children||[];var n=[];return t.forEach((function(t){e(t)&&n.push(t)})),n}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.remove()})),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach((e=>{e.parent=null,e.index=0,e.destroy()})),this.children=[],this._requestDraw(),this}add(...e){if(0===e.length)return this;if(e.length>1){for(var t=0;t<e.length;t++)this.add(e[t]);return this}const n=e[0];return n.getParent()?(n.moveTo(this),this):(this._validateAdd(n),n.index=this.getChildren().length,n.parent=this,n._clearCaches(),this.getChildren().push(n),this._fire("add",{child:n}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var t=this._generalFind(e,!0);return t.length>0?t[0]:void 0}_generalFind(e,t){var n=[];return this._descendants((r=>{const a=r._isMatch(e);return a&&n.push(r),!(!a||!t)})),n}_descendants(e){let t=!1;const n=this.getChildren();for(const r of n){if(t=e(r),t)return!0;if(r.hasChildren()&&(t=r._descendants(e),t))return!0}return!1}toObject(){var e=Vhe.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach((t=>{e.children.push(t.toObject())})),e}isAncestorOf(e){for(var t=e.getParent();t;){if(t._id===this._id)return!0;t=t.getParent()}return!1}clone(e){var t=Vhe.prototype.clone.call(this,e);return this.getChildren().forEach((function(e){t.add(e.clone())})),t}getAllIntersections(e){var t=[];return this.find("Shape").forEach((function(n){n.isVisible()&&n.intersects(e)&&t.push(n)})),t}_clearSelfAndDescendantCache(e){var t;super._clearSelfAndDescendantCache(e),this.isCached()||null===(t=this.children)||void 0===t||t.forEach((function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;null===(e=this.children)||void 0===e||e.forEach((function(e,t){e.index=t})),this._requestDraw()}drawScene(e,t){var n=this.getLayer(),r=e||n&&n.getCanvas(),a=r&&r.getContext(),o=this._getCanvasCache(),c=o&&o.scene,i=r&&r.isCache;if(!this.isVisible()&&!i)return this;if(c){a.save();var l=this.getAbsoluteTransform(t).getMatrix();a.transform(l[0],l[1],l[2],l[3],l[4],l[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",r,t);return this}drawHit(e,t){if(!this.shouldDrawHit(t))return this;var n=this.getLayer(),r=e||n&&n.hitCanvas,a=r&&r.getContext(),o=this._getCanvasCache();if(o&&o.hit){a.save();var c=this.getAbsoluteTransform(t).getMatrix();a.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedHitCanvas(a),a.restore()}else this._drawChildren("drawHit",r,t);return this}_drawChildren(e,t,n){var r,a=t&&t.getContext(),o=this.clipWidth(),c=this.clipHeight(),i=this.clipFunc(),l=o&&c||i;const s=n===this;if(l){a.save();var h=this.getAbsoluteTransform(n),d=h.getMatrix();if(a.transform(d[0],d[1],d[2],d[3],d[4],d[5]),a.beginPath(),i)i.call(this,a,this);else{var u=this.clipX(),m=this.clipY();a.rect(u,m,o,c)}a.clip(),d=h.copy().invert().getMatrix(),a.transform(d[0],d[1],d[2],d[3],d[4],d[5])}var p=!s&&"source-over"!==this.globalCompositeOperation()&&"drawScene"===e;p&&(a.save(),a._applyGlobalCompositeOperation(this)),null===(r=this.children)||void 0===r||r.forEach((function(r){r[e](t,n)})),p&&a.restore(),l&&a.restore()}getClientRect(e){var t,n,r,a,o,c,i=(e=e||{}).skipTransform,l=e.relativeTo,s=this;null===(t=this.children)||void 0===t||t.forEach((function(t){if(t.visible()){var c=t.getClientRect({relativeTo:s,skipShadow:e.skipShadow,skipStroke:e.skipStroke});0===c.width&&0===c.height||(void 0===n?(n=c.x,r=c.y,a=c.x+c.width,o=c.y+c.height):(n=Math.min(n,c.x),r=Math.min(r,c.y),a=Math.max(a,c.x+c.width),o=Math.max(o,c.y+c.height)))}}));for(var h=this.find("Shape"),d=!1,u=0;u<h.length;u++)if(h[u]._isVisible(this)){d=!0;break}return c=d&&void 0!==n?{x:n,y:r,width:a-n,height:o-r}:{x:0,y:0,width:0,height:0},i?c:this._transformedRect(c,l)}}Zse.addComponentsGetterSetter(Lhe,"clip",["x","y","width","height"]),Zse.addGetterSetter(Lhe,"clipX",void 0,$se()),Zse.addGetterSetter(Lhe,"clipY",void 0,$se()),Zse.addGetterSetter(Lhe,"clipWidth",void 0,$se()),Zse.addGetterSetter(Lhe,"clipHeight",void 0,$se()),Zse.addGetterSetter(Lhe,"clipFunc");const whe=new Map,khe=void 0!==Ose._global.PointerEvent;function xhe(e){return whe.get(e)}function She(e){return{evt:e,pointerId:e.pointerId}}function The(e,t){return whe.get(e)===t}function Ohe(e,t){Ahe(e),t.getStage()&&(whe.set(e,t),khe&&t._fire("gotpointercapture",She(new PointerEvent("gotpointercapture"))))}function Ahe(e,t){const n=whe.get(e);if(!n)return;const r=n.getStage();r&&r.content,whe.delete(e),khe&&n._fire("lostpointercapture",She(new PointerEvent("lostpointercapture")))}var Rhe="mouseleave",Nhe="mouseover",_he="mouseenter",Dhe="mousemove",Phe="mousedown",Fhe="mouseup",Ihe="pointermove",Bhe="pointerdown",jhe="pointerup",Uhe="pointercancel",Whe="pointerout",$he="pointerleave",qhe="pointerover",Ghe="pointerenter",Yhe="contextmenu",Khe="touchstart",Xhe="touchend",Qhe="touchmove",Jhe="touchcancel",Zhe="wheel",ede=[[_he,"_pointerenter"],[Phe,"_pointerdown"],[Dhe,"_pointermove"],[Fhe,"_pointerup"],[Rhe,"_pointerleave"],[Khe,"_pointerdown"],[Qhe,"_pointermove"],[Xhe,"_pointerup"],[Jhe,"_pointercancel"],[Nhe,"_pointerover"],[Zhe,"_wheel"],[Yhe,"_contextmenu"],[Bhe,"_pointerdown"],[Ihe,"_pointermove"],[jhe,"_pointerup"],[Uhe,"_pointercancel"],["lostpointercapture","_lostpointercapture"]];const tde={mouse:{[Whe]:"mouseout",[$he]:Rhe,[qhe]:Nhe,[Ghe]:_he,[Ihe]:Dhe,[Bhe]:Phe,[jhe]:Fhe,[Uhe]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[Whe]:"touchout",[$he]:"touchleave",[qhe]:"touchover",[Ghe]:"touchenter",[Ihe]:Qhe,[Bhe]:Khe,[jhe]:Xhe,[Uhe]:Jhe,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[Whe]:Whe,[$he]:$he,[qhe]:qhe,[Ghe]:Ghe,[Ihe]:Ihe,[Bhe]:Bhe,[jhe]:jhe,[Uhe]:Uhe,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},nde=e=>e.indexOf("pointer")>=0?"pointer":e.indexOf("touch")>=0?"touch":"mouse",rde=e=>{const t=nde(e);return"pointer"===t?Ose.pointerEventsEnabled&&tde.pointer:"touch"===t?tde.touch:"mouse"===t?tde.mouse:void 0};function ade(e={}){return(e.clipFunc||e.clipWidth||e.clipHeight)&&jse.warn("Stage does not support clipping. Please use clip for Layers or Groups."),e}const ode=[];class cde extends Lhe{constructor(e){super(ade(e)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),ode.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",(()=>{ade(this.attrs)})),this._checkVisibility()}_validateAdd(e){const t="Layer"===e.getType(),n="FastLayer"===e.getType();t||n||jse.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const e=this.visible()?"":"none";this.content.style.display=e}setContainer(e){if("string"==typeof e){if("."===e.charAt(0)){var t=e.slice(1);e=document.getElementsByClassName(t)[0]}else{var n;n="#"!==e.charAt(0)?e:e.slice(1),e=document.getElementById(n)}if(!e)throw"Can not find container in document with id "+n}return this._setAttr("container",e),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),e.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var e,t=this.children,n=t.length;for(e=0;e<n;e++)t[e].clear();return this}clone(e){return e||(e={}),e.container="undefined"!=typeof document&&document.createElement("div"),Lhe.prototype.clone.call(this,e)}destroy(){super.destroy();var e=this.content;e&&jse._isInDocument(e)&&this.container().removeChild(e);var t=ode.indexOf(this);return t>-1&&ode.splice(t,1),jse.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const e=this._pointerPositions[0]||this._changedPointerPositions[0];return e?{x:e.x,y:e.y}:(jse.warn("Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);"),null)}_getPointerById(e){return this._pointerPositions.find((t=>t.id===e))}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(e){(e=e||{}).x=e.x||0,e.y=e.y||0,e.width=e.width||this.width(),e.height=e.height||this.height();var t=new che({width:e.width,height:e.height,pixelRatio:e.pixelRatio||1}),n=t.getContext()._context,r=this.children;return(e.x||e.y)&&n.translate(-1*e.x,-1*e.y),r.forEach((function(t){if(t.isVisible()){var r=t._toKonvaCanvas(e);n.drawImage(r._canvas,e.x,e.y,r.getWidth()/r.getPixelRatio(),r.getHeight()/r.getPixelRatio())}})),t}getIntersection(e){if(!e)return null;var t,n=this.children;for(t=n.length-1;t>=0;t--){const r=n[t].getIntersection(e);if(r)return r}return null}_resizeDOM(){var e=this.width(),t=this.height();this.content&&(this.content.style.width=e+"px",this.content.style.height=t+"px"),this.bufferCanvas.setSize(e,t),this.bufferHitCanvas.setSize(e,t),this.children.forEach((n=>{n.setSize({width:e,height:t}),n.draw()}))}add(e,...t){if(arguments.length>1){for(var n=0;n<arguments.length;n++)this.add(arguments[n]);return this}super.add(e);var r=this.children.length;return r>5&&jse.warn("The stage has "+r+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),e.setSize({width:this.width(),height:this.height()}),e.draw(),Ose.isBrowser&&this.content.appendChild(e.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(e){return The(e,this)}setPointerCapture(e){Ohe(e,this)}releaseCapture(e){Ahe(e)}getLayers(){return this.children}_bindContentEvents(){Ose.isBrowser&&ede.forEach((([e,t])=>{this.content.addEventListener(e,(e=>{this[t](e)}),{passive:!1})}))}_pointerenter(e){this.setPointersPositions(e);const t=rde(e.type);this._fire(t.pointerenter,{evt:e,target:this,currentTarget:this})}_pointerover(e){this.setPointersPositions(e);const t=rde(e.type);this._fire(t.pointerover,{evt:e,target:this,currentTarget:this})}_getTargetShape(e){let t=this[e+"targetShape"];return t&&!t.getStage()&&(t=null),t}_pointerleave(e){const t=rde(e.type),n=nde(e.type);if(t){this.setPointersPositions(e);var r=this._getTargetShape(n),a=!lhe.isDragging||Ose.hitOnDragEnabled;r&&a?(r._fireAndBubble(t.pointerout,{evt:e}),r._fireAndBubble(t.pointerleave,{evt:e}),this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this[n+"targetShape"]=null):a&&(this._fire(t.pointerleave,{evt:e,target:this,currentTarget:this}),this._fire(t.pointerout,{evt:e,target:this,currentTarget:this})),this.pointerPos=void 0,this._pointerPositions=[]}}_pointerdown(e){const t=rde(e.type),n=nde(e.type);if(t){this.setPointersPositions(e);var r=!1;this._changedPointerPositions.forEach((a=>{var o=this.getIntersection(a);if(lhe.justDragged=!1,Ose["_"+n+"ListenClick"]=!0,!o||!o.isListening())return;Ose.capturePointerEventsEnabled&&o.setPointerCapture(a.id),this[n+"ClickStartShape"]=o,o._fireAndBubble(t.pointerdown,{evt:e,pointerId:a.id}),r=!0;const c=e.type.indexOf("touch")>=0;o.preventDefault()&&e.cancelable&&c&&e.preventDefault()})),r||this._fire(t.pointerdown,{evt:e,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(e){const t=rde(e.type),n=nde(e.type);if(!t)return;if(lhe.isDragging&&lhe.node.preventDefault()&&e.cancelable&&e.preventDefault(),this.setPointersPositions(e),lhe.isDragging&&!Ose.hitOnDragEnabled)return;var r={};let a=!1;var o=this._getTargetShape(n);this._changedPointerPositions.forEach((c=>{const i=xhe(c.id)||this.getIntersection(c),l=c.id,s={evt:e,pointerId:l};var h=o!==i;if(h&&o&&(o._fireAndBubble(t.pointerout,Object.assign({},s),i),o._fireAndBubble(t.pointerleave,Object.assign({},s),i)),i){if(r[i._id])return;r[i._id]=!0}i&&i.isListening()?(a=!0,h&&(i._fireAndBubble(t.pointerover,Object.assign({},s),o),i._fireAndBubble(t.pointerenter,Object.assign({},s),o),this[n+"targetShape"]=i),i._fireAndBubble(t.pointermove,Object.assign({},s))):o&&(this._fire(t.pointerover,{evt:e,target:this,currentTarget:this,pointerId:l}),this[n+"targetShape"]=null)})),a||this._fire(t.pointermove,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(e){const t=rde(e.type),n=nde(e.type);if(!t)return;this.setPointersPositions(e);const r=this[n+"ClickStartShape"],a=this[n+"ClickEndShape"];var o={};let c=!1;this._changedPointerPositions.forEach((i=>{const l=xhe(i.id)||this.getIntersection(i);if(l){if(l.releaseCapture(i.id),o[l._id])return;o[l._id]=!0}const s=i.id,h={evt:e,pointerId:s};let d=!1;Ose["_"+n+"InDblClickWindow"]?(d=!0,clearTimeout(this[n+"DblTimeout"])):lhe.justDragged||(Ose["_"+n+"InDblClickWindow"]=!0,clearTimeout(this[n+"DblTimeout"])),this[n+"DblTimeout"]=setTimeout((function(){Ose["_"+n+"InDblClickWindow"]=!1}),Ose.dblClickWindow),l&&l.isListening()?(c=!0,this[n+"ClickEndShape"]=l,l._fireAndBubble(t.pointerup,Object.assign({},h)),Ose["_"+n+"ListenClick"]&&r&&r===l&&(l._fireAndBubble(t.pointerclick,Object.assign({},h)),d&&a&&a===l&&l._fireAndBubble(t.pointerdblclick,Object.assign({},h)))):(this[n+"ClickEndShape"]=null,Ose["_"+n+"ListenClick"]&&this._fire(t.pointerclick,{evt:e,target:this,currentTarget:this,pointerId:s}),d&&this._fire(t.pointerdblclick,{evt:e,target:this,currentTarget:this,pointerId:s}))})),c||this._fire(t.pointerup,{evt:e,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),Ose["_"+n+"ListenClick"]=!1,e.cancelable&&"touch"!==n&&e.preventDefault()}_contextmenu(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Yhe,{evt:e}):this._fire(Yhe,{evt:e,target:this,currentTarget:this})}_wheel(e){this.setPointersPositions(e);var t=this.getIntersection(this.getPointerPosition());t&&t.isListening()?t._fireAndBubble(Zhe,{evt:e}):this._fire(Zhe,{evt:e,target:this,currentTarget:this})}_pointercancel(e){this.setPointersPositions(e);const t=xhe(e.pointerId)||this.getIntersection(this.getPointerPosition());t&&t._fireAndBubble(jhe,She(e)),Ahe(e.pointerId)}_lostpointercapture(e){Ahe(e.pointerId)}setPointersPositions(e){var t=this._getContentPosition(),n=null,r=null;void 0!==(e=e||window.event).touches?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(e.touches,(e=>{this._pointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})})),Array.prototype.forEach.call(e.changedTouches||e.touches,(e=>{this._changedPointerPositions.push({id:e.identifier,x:(e.clientX-t.left)/t.scaleX,y:(e.clientY-t.top)/t.scaleY})}))):(n=(e.clientX-t.left)/t.scaleX,r=(e.clientY-t.top)/t.scaleY,this.pointerPos={x:n,y:r},this._pointerPositions=[{x:n,y:r,id:jse._getFirstPointerId(e)}],this._changedPointerPositions=[{x:n,y:r,id:jse._getFirstPointerId(e)}])}_setPointerPosition(e){jse.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(e)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var e=this.content.getBoundingClientRect();return{top:e.top,left:e.left,scaleX:e.width/this.content.clientWidth||1,scaleY:e.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new che({width:this.width(),height:this.height()}),this.bufferHitCanvas=new ihe({pixelRatio:1,width:this.width(),height:this.height()}),Ose.isBrowser){var e=this.container();if(!e)throw"Stage has no container. A container is required.";e.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),e.appendChild(this.content),this._resizeDOM()}}cache(){return jse.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach((function(e){e.batchDraw()})),this}}cde.prototype.nodeType="Stage",Ase(cde),Zse.addGetterSetter(cde,"container");var ide="hasShadow",lde="shadowRGBA",sde="patternImage",hde="linearGradient",dde="radialGradient";let ude;function mde(){return ude||(ude=jse.createCanvasElement().getContext("2d"),ude)}const pde={};class vde extends Vhe{constructor(e){let t;for(super(e);t=jse.getRandomColor(),!t||t in pde;);this.colorKey=t,pde[t]=this}getContext(){return jse.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return jse.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(ide,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&0!==this.shadowOpacity()&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(sde,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){const e=mde().createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(e&&e.setTransform){const t=new Rse;t.translate(this.fillPatternX(),this.fillPatternY()),t.rotate(Ose.getAngle(this.fillPatternRotation())),t.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),t.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const n=t.getMatrix(),r="undefined"==typeof DOMMatrix?{a:n[0],b:n[1],c:n[2],d:n[3],e:n[4],f:n[5]}:new DOMMatrix(n);e.setTransform(r)}return e}}_getLinearGradient(){return this._getCache(hde,this.__getLinearGradient)}__getLinearGradient(){var e=this.fillLinearGradientColorStops();if(e){for(var t=mde(),n=this.fillLinearGradientStartPoint(),r=this.fillLinearGradientEndPoint(),a=t.createLinearGradient(n.x,n.y,r.x,r.y),o=0;o<e.length;o+=2)a.addColorStop(e[o],e[o+1]);return a}}_getRadialGradient(){return this._getCache(dde,this.__getRadialGradient)}__getRadialGradient(){var e=this.fillRadialGradientColorStops();if(e){for(var t=mde(),n=this.fillRadialGradientStartPoint(),r=this.fillRadialGradientEndPoint(),a=t.createRadialGradient(n.x,n.y,this.fillRadialGradientStartRadius(),r.x,r.y,this.fillRadialGradientEndRadius()),o=0;o<e.length;o+=2)a.addColorStop(e[o],e[o+1]);return a}}getShadowRGBA(){return this._getCache(lde,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var e=jse.colorToRGBA(this.shadowColor());return e?"rgba("+e.r+","+e.g+","+e.b+","+e.a*(this.shadowOpacity()||1)+")":void 0}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],(()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops())))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],(()=>this.strokeEnabled()&&this.strokeWidth()&&!(!this.stroke()&&!this.strokeLinearGradientColorStops())))}hasHitStroke(){const e=this.hitStrokeWidth();return"auto"===e?this.hasStroke():this.strokeEnabled()&&!!e}intersects(e){var t=this.getStage().bufferHitCanvas;return t.getContext().clear(),this.drawHit(t,null,!0),t.context.getImageData(Math.round(e.x),Math.round(e.y),1,1).data[3]>0}destroy(){return Vhe.prototype.destroy.call(this),delete pde[this.colorKey],delete this.colorKey,this}_useBufferCanvas(e){var t;if(!this.getStage())return!1;if(null!==(t=this.attrs.perfectDrawEnabled)&&void 0!==t&&!t)return!1;const n=e||this.hasFill(),r=this.hasStroke(),a=1!==this.getAbsoluteOpacity();if(n&&r&&a)return!0;const o=this.hasShadow(),c=this.shadowForStrokeEnabled();return!!(n&&r&&o&&c)}setStrokeHitEnabled(e){jse.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),e?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return 0!==this.hitStrokeWidth()}getSelfRect(){var e=this.size();return{x:this._centroid?-e.width/2:0,y:this._centroid?-e.height/2:0,width:e.width,height:e.height}}getClientRect(e={}){const t=e.skipTransform,n=e.relativeTo,r=this.getSelfRect(),a=!e.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,o=r.width+a,c=r.height+a,i=!e.skipShadow&&this.hasShadow(),l=i?this.shadowOffsetX():0,s=i?this.shadowOffsetY():0,h=o+Math.abs(l),d=c+Math.abs(s),u=i&&this.shadowBlur()||0,m={width:h+2*u,height:d+2*u,x:-(a/2+u)+Math.min(l,0)+r.x,y:-(a/2+u)+Math.min(s,0)+r.y};return t?m:this._transformedRect(m,n)}drawScene(e,t){var n,r,a=this.getLayer(),o=e||a.getCanvas(),c=o.getContext(),i=this._getCanvasCache(),l=this.getSceneFunc(),s=this.hasShadow(),h=o.isCache,d=t===this;if(!this.isVisible()&&!d)return this;if(i){c.save();var u=this.getAbsoluteTransform(t).getMatrix();return c.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(c),c.restore(),this}if(!l)return this;if(c.save(),this._useBufferCanvas()&&!h){(r=(n=this.getStage().bufferCanvas).getContext()).clear(),r.save(),r._applyLineJoin(this);var m=this.getAbsoluteTransform(t).getMatrix();r.transform(m[0],m[1],m[2],m[3],m[4],m[5]),l.call(this,r,this),r.restore();var p=n.pixelRatio;s&&c._applyShadow(this),c._applyOpacity(this),c._applyGlobalCompositeOperation(this),c.drawImage(n._canvas,0,0,n.width/p,n.height/p)}else c._applyLineJoin(this),d||(m=this.getAbsoluteTransform(t).getMatrix(),c.transform(m[0],m[1],m[2],m[3],m[4],m[5]),c._applyOpacity(this),c._applyGlobalCompositeOperation(this)),s&&c._applyShadow(this),l.call(this,c,this);return c.restore(),this}drawHit(e,t,n=!1){if(!this.shouldDrawHit(t,n))return this;var r=this.getLayer(),a=e||r.hitCanvas,o=a&&a.getContext(),c=this.hitFunc()||this.sceneFunc(),i=this._getCanvasCache(),l=i&&i.hit;if(this.colorKey||jse.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),l){o.save();var s=this.getAbsoluteTransform(t).getMatrix();return o.transform(s[0],s[1],s[2],s[3],s[4],s[5]),this._drawCachedHitCanvas(o),o.restore(),this}if(!c)return this;if(o.save(),o._applyLineJoin(this),this!==t){var h=this.getAbsoluteTransform(t).getMatrix();o.transform(h[0],h[1],h[2],h[3],h[4],h[5])}return c.call(this,o,this),o.restore(),this}drawHitFromCache(e=0){var t,n,r,a,o,c=this._getCanvasCache(),i=this._getCachedSceneCanvas(),l=c.hit,s=l.getContext(),h=l.getWidth(),d=l.getHeight();s.clear(),s.drawImage(i._canvas,0,0,h,d);try{for(r=(n=(t=s.getImageData(0,0,h,d)).data).length,a=jse._hexToRgb(this.colorKey),o=0;o<r;o+=4)n[o+3]>e?(n[o]=a.r,n[o+1]=a.g,n[o+2]=a.b,n[o+3]=255):n[o+3]=0;s.putImageData(t,0,0)}catch(e){jse.error("Unable to draw hit graph from cached scene canvas. "+e.message)}return this}hasPointerCapture(e){return The(e,this)}setPointerCapture(e){Ohe(e,this)}releaseCapture(e){Ahe(e)}}vde.prototype._fillFunc=function(e){e.fill()},vde.prototype._strokeFunc=function(e){e.stroke()},vde.prototype._fillFuncHit=function(e){e.fill()},vde.prototype._strokeFuncHit=function(e){e.stroke()},vde.prototype._centroid=!1,vde.prototype.nodeType="Shape",Ase(vde),vde.prototype.eventListeners={},vde.prototype.on.call(vde.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(ide)})),vde.prototype.on.call(vde.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",(function(){this._clearCache(lde)})),vde.prototype.on.call(vde.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",(function(){this._clearCache(sde)})),vde.prototype.on.call(vde.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",(function(){this._clearCache(hde)})),vde.prototype.on.call(vde.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",(function(){this._clearCache(dde)})),Zse.addGetterSetter(vde,"stroke",void 0,Kse()),Zse.addGetterSetter(vde,"strokeWidth",2,$se()),Zse.addGetterSetter(vde,"fillAfterStrokeEnabled",!1),Zse.addGetterSetter(vde,"hitStrokeWidth","auto",Gse()),Zse.addGetterSetter(vde,"strokeHitEnabled",!0,Xse()),Zse.addGetterSetter(vde,"perfectDrawEnabled",!0,Xse()),Zse.addGetterSetter(vde,"shadowForStrokeEnabled",!0,Xse()),Zse.addGetterSetter(vde,"lineJoin"),Zse.addGetterSetter(vde,"lineCap"),Zse.addGetterSetter(vde,"sceneFunc"),Zse.addGetterSetter(vde,"hitFunc"),Zse.addGetterSetter(vde,"dash"),Zse.addGetterSetter(vde,"dashOffset",0,$se()),Zse.addGetterSetter(vde,"shadowColor",void 0,Yse()),Zse.addGetterSetter(vde,"shadowBlur",0,$se()),Zse.addGetterSetter(vde,"shadowOpacity",1,$se()),Zse.addComponentsGetterSetter(vde,"shadowOffset",["x","y"]),Zse.addGetterSetter(vde,"shadowOffsetX",0,$se()),Zse.addGetterSetter(vde,"shadowOffsetY",0,$se()),Zse.addGetterSetter(vde,"fillPatternImage"),Zse.addGetterSetter(vde,"fill",void 0,Kse()),Zse.addGetterSetter(vde,"fillPatternX",0,$se()),Zse.addGetterSetter(vde,"fillPatternY",0,$se()),Zse.addGetterSetter(vde,"fillLinearGradientColorStops"),Zse.addGetterSetter(vde,"strokeLinearGradientColorStops"),Zse.addGetterSetter(vde,"fillRadialGradientStartRadius",0),Zse.addGetterSetter(vde,"fillRadialGradientEndRadius",0),Zse.addGetterSetter(vde,"fillRadialGradientColorStops"),Zse.addGetterSetter(vde,"fillPatternRepeat","repeat"),Zse.addGetterSetter(vde,"fillEnabled",!0),Zse.addGetterSetter(vde,"strokeEnabled",!0),Zse.addGetterSetter(vde,"shadowEnabled",!0),Zse.addGetterSetter(vde,"dashEnabled",!0),Zse.addGetterSetter(vde,"strokeScaleEnabled",!0),Zse.addGetterSetter(vde,"fillPriority","color"),Zse.addComponentsGetterSetter(vde,"fillPatternOffset",["x","y"]),Zse.addGetterSetter(vde,"fillPatternOffsetX",0,$se()),Zse.addGetterSetter(vde,"fillPatternOffsetY",0,$se()),Zse.addComponentsGetterSetter(vde,"fillPatternScale",["x","y"]),Zse.addGetterSetter(vde,"fillPatternScaleX",1,$se()),Zse.addGetterSetter(vde,"fillPatternScaleY",1,$se()),Zse.addComponentsGetterSetter(vde,"fillLinearGradientStartPoint",["x","y"]),Zse.addComponentsGetterSetter(vde,"strokeLinearGradientStartPoint",["x","y"]),Zse.addGetterSetter(vde,"fillLinearGradientStartPointX",0),Zse.addGetterSetter(vde,"strokeLinearGradientStartPointX",0),Zse.addGetterSetter(vde,"fillLinearGradientStartPointY",0),Zse.addGetterSetter(vde,"strokeLinearGradientStartPointY",0),Zse.addComponentsGetterSetter(vde,"fillLinearGradientEndPoint",["x","y"]),Zse.addComponentsGetterSetter(vde,"strokeLinearGradientEndPoint",["x","y"]),Zse.addGetterSetter(vde,"fillLinearGradientEndPointX",0),Zse.addGetterSetter(vde,"strokeLinearGradientEndPointX",0),Zse.addGetterSetter(vde,"fillLinearGradientEndPointY",0),Zse.addGetterSetter(vde,"strokeLinearGradientEndPointY",0),Zse.addComponentsGetterSetter(vde,"fillRadialGradientStartPoint",["x","y"]),Zse.addGetterSetter(vde,"fillRadialGradientStartPointX",0),Zse.addGetterSetter(vde,"fillRadialGradientStartPointY",0),Zse.addComponentsGetterSetter(vde,"fillRadialGradientEndPoint",["x","y"]),Zse.addGetterSetter(vde,"fillRadialGradientEndPointX",0),Zse.addGetterSetter(vde,"fillRadialGradientEndPointY",0),Zse.addGetterSetter(vde,"fillPatternRotation",0),Zse.backCompat(vde,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"});var fde=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],zde=fde.length;class gde extends Lhe{constructor(e){super(e),this.canvas=new che,this.hitCanvas=new ihe({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var t=this.getStage();return t&&t.content&&(t.content.removeChild(this.getNativeCanvasElement()),e<t.children.length-1?t.content.insertBefore(this.getNativeCanvasElement(),t.children[e+1].getCanvas()._canvas):t.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Vhe.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){if(!Vhe.prototype.moveUp.call(this))return!1;var e=this.getStage();return!(!e||!e.content||(e.content.removeChild(this.getNativeCanvasElement()),this.index<e.children.length-1?e.content.insertBefore(this.getNativeCanvasElement(),e.children[this.index+1].getCanvas()._canvas):e.content.appendChild(this.getNativeCanvasElement()),0))}moveDown(){if(Vhe.prototype.moveDown.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Vhe.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var t=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),t[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Vhe.prototype.remove.call(this),e&&e.parentNode&&jse._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:t}){return this.canvas.setSize(e,t),this.hitCanvas.setSize(e,t),this._setSmoothEnabled(),this}_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&jse.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return(e=e||{}).width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=void 0!==e.x?e.x:this.x(),e.y=void 0!==e.y?e.y:this.y(),Vhe.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){const e=this.visible();this.canvas._canvas.style.display=e?"block":"none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){jse.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){jse.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,jse.requestAnimFrame((()=>{this.draw(),this._waitingForDraw=!1}))),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var t=1,n=!1;;){for(let r=0;r<zde;r++){const a=fde[r],o=this._getIntersection({x:e.x+a.x*t,y:e.y+a.y*t}),c=o.shape;if(c)return c;if(n=!!o.antialiased,!o.antialiased)break}if(!n)return null;t+=1}}_getIntersection(e){const t=this.hitCanvas.pixelRatio,n=this.hitCanvas.context.getImageData(Math.round(e.x*t),Math.round(e.y*t),1,1).data,r=n[3];if(255===r){const e=jse._rgbToHex(n[0],n[1],n[2]),t=pde["#"+e];return t?{shape:t}:{antialiased:!0}}return r>0?{antialiased:!0}:{}}drawScene(e,t){var n=this.getLayer(),r=e||n&&n.getCanvas();return this._fire("beforeDraw",{node:this}),this.clearBeforeDraw()&&r.getContext().clear(),Lhe.prototype.drawScene.call(this,r,t),this._fire("draw",{node:this}),this}drawHit(e,t){var n=this.getLayer(),r=e||n&&n.hitCanvas;return n&&n.clearBeforeDraw()&&n.getHitCanvas().getContext().clear(),Lhe.prototype.drawHit.call(this,r,t),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){jse.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return jse.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(this.parent&&this.parent.content){var e=this.parent;this.hitCanvas._canvas.parentNode?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return jse.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}}gde.prototype.nodeType="Layer",Ase(gde),Zse.addGetterSetter(gde,"imageSmoothingEnabled",!0),Zse.addGetterSetter(gde,"clearBeforeDraw",!0),Zse.addGetterSetter(gde,"hitGraphEnabled",!0,Xse());class yde extends gde{constructor(e){super(e),this.listening(!1),jse.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}yde.prototype.nodeType="FastLayer",Ase(yde);class Mde extends Lhe{_validateAdd(e){var t=e.getType();"Group"!==t&&"Shape"!==t&&jse.throw("You may only add groups and shapes to groups.")}}Mde.prototype.nodeType="Group",Ase(Mde);var Ede=Tse.performance&&Tse.performance.now?function(){return Tse.performance.now()}:function(){return(new Date).getTime()};class bde{constructor(e,t){this.id=bde.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:Ede(),frameRate:0},this.func=e,this.setLayers(t)}setLayers(e){var t;return t=e?e.length>0?e:[e]:[],this.layers=t,this}getLayers(){return this.layers}addLayer(e){var t,n=this.layers,r=n.length;for(t=0;t<r;t++)if(n[t]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){var e,t=bde.animations,n=t.length;for(e=0;e<n;e++)if(t[e].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=Ede(),bde._addAnimation(this),this}stop(){return bde._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){var t,n=e.id,r=this.animations,a=r.length;for(t=0;t<a;t++)if(r[t].id===n){this.animations.splice(t,1);break}}static _runFrames(){var e,t,n,r,a,o,c,i,l={},s=this.animations;for(r=0;r<s.length;r++)if(t=(e=s[r]).layers,n=e.func,e._updateFrameObject(Ede()),o=t.length,!n||!1!==n.call(e,e.frame))for(a=0;a<o;a++)void 0!==(c=t[a])._id&&(l[c._id]=c);for(i in l)l.hasOwnProperty(i)&&l[i].batchDraw()}static _animationLoop(){var e=bde;e.animations.length?(e._runFrames(),jse.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,jse.requestAnimFrame(this._animationLoop))}}bde.animations=[],bde.animIdCounter=0,bde.animRunning=!1;var Hde={node:1,duration:1,easing:1,onFinish:1,yoyo:1},Vde=0,Cde=["fill","stroke","shadowColor"];class Lde{constructor(e,t,n,r,a,o,c){this.prop=e,this.propFunc=t,this.begin=r,this._pos=r,this.duration=o,this._change=0,this.prevPos=0,this.yoyo=c,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=n,this._change=a-this.begin,this.pause()}fire(e){var t=this[e];t&&t()}setTime(e){e>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():e<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=e,this.update())}getTime(){return this._time}setPosition(e){this.prevPos=this._pos,this.propFunc(e),this._pos=e}getPosition(e){return void 0===e&&(e=this._time),this.func(e,this.begin,this._change,this.duration)}play(){this.state=2,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=3,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(e){this.pause(),this._time=e,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var e=this.getTimer()-this._startTime;2===this.state?this.setTime(e):3===this.state&&this.setTime(this.duration-e)}pause(){this.state=1,this.fire("onPause")}getTimer(){return(new Date).getTime()}}class wde{constructor(e){var t,n,r=this,a=e.node,o=a._id,c=e.easing||kde.Linear,i=!!e.yoyo;t=void 0===e.duration?.3:0===e.duration?.001:e.duration,this.node=a,this._id=Vde++;var l=a.getLayer()||(a instanceof Ose.Stage?a.getLayers():null);for(n in l||jse.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new bde((function(){r.tween.onEnterFrame()}),l),this.tween=new Lde(n,(function(e){r._tweenFunc(e)}),c,0,1,1e3*t,i),this._addListeners(),wde.attrs[o]||(wde.attrs[o]={}),wde.attrs[o][this._id]||(wde.attrs[o][this._id]={}),wde.tweens[o]||(wde.tweens[o]={}),e)void 0===Hde[n]&&this._addAttr(n,e[n]);this.reset(),this.onFinish=e.onFinish,this.onReset=e.onReset,this.onUpdate=e.onUpdate}_addAttr(e,t){var n,r,a,o,c,i,l,s,h=this.node,d=h._id;if((a=wde.tweens[d][e])&&delete wde.attrs[d][a][e],n=h.getAttr(e),jse._isArray(t))if(r=[],c=Math.max(t.length,n.length),"points"===e&&t.length!==n.length&&(t.length>n.length?(l=n,n=jse._prepareArrayForTween(n,t,h.closed())):(i=t,t=jse._prepareArrayForTween(t,n,h.closed()))),0===e.indexOf("fill"))for(o=0;o<c;o++)if(o%2==0)r.push(t[o]-n[o]);else{var u=jse.colorToRGBA(n[o]);s=jse.colorToRGBA(t[o]),n[o]=u,r.push({r:s.r-u.r,g:s.g-u.g,b:s.b-u.b,a:s.a-u.a})}else for(o=0;o<c;o++)r.push(t[o]-n[o]);else-1!==Cde.indexOf(e)?(n=jse.colorToRGBA(n),r={r:(s=jse.colorToRGBA(t)).r-n.r,g:s.g-n.g,b:s.b-n.b,a:s.a-n.a}):r=t-n;wde.attrs[d][this._id][e]={start:n,diff:r,end:t,trueEnd:i,trueStart:l},wde.tweens[d][e]=this._id}_tweenFunc(e){var t,n,r,a,o,c,i,l,s=this.node,h=wde.attrs[s._id][this._id];for(t in h){if(r=(n=h[t]).start,a=n.diff,l=n.end,jse._isArray(r))if(o=[],i=Math.max(r.length,l.length),0===t.indexOf("fill"))for(c=0;c<i;c++)c%2==0?o.push((r[c]||0)+a[c]*e):o.push("rgba("+Math.round(r[c].r+a[c].r*e)+","+Math.round(r[c].g+a[c].g*e)+","+Math.round(r[c].b+a[c].b*e)+","+(r[c].a+a[c].a*e)+")");else for(c=0;c<i;c++)o.push((r[c]||0)+a[c]*e);else o=-1!==Cde.indexOf(t)?"rgba("+Math.round(r.r+a.r*e)+","+Math.round(r.g+a.g*e)+","+Math.round(r.b+a.b*e)+","+(r.a+a.a*e)+")":r+a*e;s.setAttr(t,o)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var e=this.node,t=wde.attrs[e._id][this._id];t.points&&t.points.trueEnd&&e.setAttr("points",t.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var e=this.node,t=wde.attrs[e._id][this._id];t.points&&t.points.trueStart&&e.points(t.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(e){return this.tween.seek(1e3*e),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var e,t=this.node._id,n=this._id,r=wde.tweens[t];for(e in this.pause(),r)delete wde.tweens[t][e];delete wde.attrs[t][n]}}wde.attrs={},wde.tweens={},Vhe.prototype.to=function(e){var t=e.onFinish;e.node=this,e.onFinish=function(){this.destroy(),t&&t()},new wde(e).play()};const kde={BackEaseIn(e,t,n,r){var a=1.70158;return n*(e/=r)*e*((a+1)*e-a)+t},BackEaseOut(e,t,n,r){var a=1.70158;return n*((e=e/r-1)*e*((a+1)*e+a)+1)+t},BackEaseInOut(e,t,n,r){var a=1.70158;return(e/=r/2)<1?n/2*(e*e*((1+(a*=1.525))*e-a))+t:n/2*((e-=2)*e*((1+(a*=1.525))*e+a)+2)+t},ElasticEaseIn(e,t,n,r,a,o){var c=0;return 0===e?t:1==(e/=r)?t+n:(o||(o=.3*r),!a||a<Math.abs(n)?(a=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/a),-a*Math.pow(2,10*(e-=1))*Math.sin((e*r-c)*(2*Math.PI)/o)+t)},ElasticEaseOut(e,t,n,r,a,o){var c=0;return 0===e?t:1==(e/=r)?t+n:(o||(o=.3*r),!a||a<Math.abs(n)?(a=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/a),a*Math.pow(2,-10*e)*Math.sin((e*r-c)*(2*Math.PI)/o)+n+t)},ElasticEaseInOut(e,t,n,r,a,o){var c=0;return 0===e?t:2==(e/=r/2)?t+n:(o||(o=r*(.3*1.5)),!a||a<Math.abs(n)?(a=n,c=o/4):c=o/(2*Math.PI)*Math.asin(n/a),e<1?a*Math.pow(2,10*(e-=1))*Math.sin((e*r-c)*(2*Math.PI)/o)*-.5+t:a*Math.pow(2,-10*(e-=1))*Math.sin((e*r-c)*(2*Math.PI)/o)*.5+n+t)},BounceEaseOut:(e,t,n,r)=>(e/=r)<1/2.75?n*(7.5625*e*e)+t:e<2/2.75?n*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?n*(7.5625*(e-=2.25/2.75)*e+.9375)+t:n*(7.5625*(e-=2.625/2.75)*e+.984375)+t,BounceEaseIn:(e,t,n,r)=>n-kde.BounceEaseOut(r-e,0,n,r)+t,BounceEaseInOut:(e,t,n,r)=>e<r/2?.5*kde.BounceEaseIn(2*e,0,n,r)+t:.5*kde.BounceEaseOut(2*e-r,0,n,r)+.5*n+t,EaseIn:(e,t,n,r)=>n*(e/=r)*e+t,EaseOut:(e,t,n,r)=>-n*(e/=r)*(e-2)+t,EaseInOut:(e,t,n,r)=>(e/=r/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t,StrongEaseIn:(e,t,n,r)=>n*(e/=r)*e*e*e*e+t,StrongEaseOut:(e,t,n,r)=>n*((e=e/r-1)*e*e*e*e+1)+t,StrongEaseInOut:(e,t,n,r)=>(e/=r/2)<1?n/2*e*e*e*e*e+t:n/2*((e-=2)*e*e*e*e+2)+t,Linear:(e,t,n,r)=>n*e/r+t},xde=jse._assign(Ose,{Util:jse,Transform:Rse,Node:Vhe,Container:Lhe,Stage:cde,stages:ode,Layer:gde,FastLayer:yde,Group:Mde,DD:lhe,Shape:vde,shapes:pde,Animation:bde,Tween:wde,Easings:kde,Context:nhe,Canvas:ohe});class Sde extends vde{_sceneFunc(e){var t=Ose.getAngle(this.angle()),n=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,t,n),e.arc(0,0,this.innerRadius(),t,0,!n),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),t=this.outerRadius(),n=this.clockwise(),r=Ose.getAngle(n?360-this.angle():this.angle()),a=Math.cos(Math.min(r,Math.PI)),o=Math.sin(Math.min(Math.max(Math.PI,r),3*Math.PI/2)),c=Math.sin(Math.min(r,Math.PI/2)),i=a*(a>0?e:t),l=o*(o>0?e:t),s=c*(c>0?t:e);return{x:i,y:n?-1*s:l,width:1*t-i,height:s-l}}}function Tde(e,t,n,r,a,o,c){var i=Math.sqrt(Math.pow(n-e,2)+Math.pow(r-t,2)),l=Math.sqrt(Math.pow(a-n,2)+Math.pow(o-r,2)),s=c*i/(i+l),h=c*l/(i+l);return[n-s*(a-e),r-s*(o-t),n+h*(a-e),r+h*(o-t)]}function Ode(e,t){var n,r,a=e.length,o=[];for(n=2;n<a-2;n+=2)r=Tde(e[n-2],e[n-1],e[n],e[n+1],e[n+2],e[n+3],t),isNaN(r[0])||(o.push(r[0]),o.push(r[1]),o.push(e[n]),o.push(e[n+1]),o.push(r[2]),o.push(r[3]));return o}Sde.prototype._centroid=!0,Sde.prototype.className="Arc",Sde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ase(Sde),Zse.addGetterSetter(Sde,"innerRadius",0,$se()),Zse.addGetterSetter(Sde,"outerRadius",0,$se()),Zse.addGetterSetter(Sde,"angle",0,$se()),Zse.addGetterSetter(Sde,"clockwise",!1,Xse());class Ade extends vde{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",(function(){this._clearCache("tensionPoints")}))}_sceneFunc(e){var t,n,r,a=this.points(),o=a.length,c=this.tension(),i=this.closed(),l=this.bezier();if(o){if(e.beginPath(),e.moveTo(a[0],a[1]),0!==c&&o>4){for(n=(t=this.getTensionPoints()).length,r=i?0:4,i||e.quadraticCurveTo(t[0],t[1],t[2],t[3]);r<n-2;)e.bezierCurveTo(t[r++],t[r++],t[r++],t[r++],t[r++],t[r++]);i||e.quadraticCurveTo(t[n-2],t[n-1],a[o-2],a[o-1])}else if(l)for(r=2;r<o;)e.bezierCurveTo(a[r++],a[r++],a[r++],a[r++],a[r++],a[r++]);else for(r=2;r<o;r+=2)e.lineTo(a[r],a[r+1]);i?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():Ode(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),t=e.length,n=this.tension(),r=Tde(e[t-2],e[t-1],e[0],e[1],e[2],e[3],n),a=Tde(e[t-4],e[t-3],e[t-2],e[t-1],e[0],e[1],n),o=Ode(e,n);return[r[2],r[3]].concat(o).concat([a[0],a[1],e[t-2],e[t-1],a[2],a[3],r[0],r[1],e[0],e[1]])}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};for(var t,n,r=(e=0!==this.tension()?[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:this.points())[0],a=e[0],o=e[1],c=e[1],i=0;i<e.length/2;i++)t=e[2*i],n=e[2*i+1],r=Math.min(r,t),a=Math.max(a,t),o=Math.min(o,n),c=Math.max(c,n);return{x:r,y:o,width:a-r,height:c-o}}}Ade.prototype.className="Line",Ade.prototype._attrsAffectingSize=["points","bezier","tension"],Ase(Ade),Zse.addGetterSetter(Ade,"closed",!1),Zse.addGetterSetter(Ade,"bezier",!1),Zse.addGetterSetter(Ade,"tension",0,$se()),Zse.addGetterSetter(Ade,"points",[],function(){if(Ose.isUnminified)return function(e,t){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&e instanceof n||(jse._isArray(e)?e.forEach((function(e){jse._isNumber(e)||jse.warn('"'+t+'" attribute has non numeric element '+e+". Make sure that all elements are numbers.")})):jse.warn(Use(e)+' is a not valid value for "'+t+'" attribute. The value should be a array of numbers.')),e}}());class Rde extends vde{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this.dataArray=Rde.parsePathData(this.data()),this.pathLength=0;for(var t=0;t<this.dataArray.length;++t)this.pathLength+=this.dataArray[t].pathLength;this.on("dataChange.konva",(function(){this.dataArray=Rde.parsePathData(this.data()),this.pathLength=0;for(var e=0;e<this.dataArray.length;++e)this.pathLength+=this.dataArray[e].pathLength}))}_sceneFunc(e){var t=this.dataArray;e.beginPath();for(var n=!1,r=0;r<t.length;r++){var a=t[r].command,o=t[r].points;switch(a){case"L":e.lineTo(o[0],o[1]);break;case"M":e.moveTo(o[0],o[1]);break;case"C":e.bezierCurveTo(o[0],o[1],o[2],o[3],o[4],o[5]);break;case"Q":e.quadraticCurveTo(o[0],o[1],o[2],o[3]);break;case"A":var c=o[0],i=o[1],l=o[2],s=o[3],h=o[4],d=o[5],u=o[6],m=o[7],p=l>s?l:s,v=l>s?1:l/s,f=l>s?s/l:1;e.translate(c,i),e.rotate(u),e.scale(v,f),e.arc(0,0,p,h,h+d,1-m),e.scale(1/v,1/f),e.rotate(-u),e.translate(-c,-i);break;case"z":n=!0,e.closePath()}}n||this.hasFill()?e.fillStrokeShape(this):e.strokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach((function(t){if("A"===t.command){var n=t.points[4],r=t.points[5],a=t.points[4]+r,o=Math.PI/180;if(Math.abs(n-a)<o&&(o=Math.abs(n-a)),r<0)for(let r=n-o;r>a;r-=o){const n=Rde.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],r,0);e.push(n.x,n.y)}else for(let r=n+o;r<a;r+=o){const n=Rde.getPointOnEllipticalArc(t.points[0],t.points[1],t.points[2],t.points[3],r,0);e.push(n.x,n.y)}}else if("C"===t.command)for(let n=0;n<=1;n+=.01){const r=Rde.getPointOnCubicBezier(n,t.start.x,t.start.y,t.points[0],t.points[1],t.points[2],t.points[3],t.points[4],t.points[5]);e.push(r.x,r.y)}else e=e.concat(t.points)}));for(var t,n,r=e[0],a=e[0],o=e[1],c=e[1],i=0;i<e.length/2;i++)t=e[2*i],n=e[2*i+1],isNaN(t)||(r=Math.min(r,t),a=Math.max(a,t)),isNaN(n)||(o=Math.min(o,n),c=Math.max(c,n));return{x:r,y:o,width:a-r,height:c-o}}getLength(){return this.pathLength}getPointAtLength(e){var t,n=0,r=this.dataArray.length;if(!r)return null;for(;n<r&&e>this.dataArray[n].pathLength;)e-=this.dataArray[n].pathLength,++n;if(n===r)return{x:(t=this.dataArray[n-1].points.slice(-2))[0],y:t[1]};if(e<.01)return{x:(t=this.dataArray[n].points.slice(0,2))[0],y:t[1]};var a=this.dataArray[n],o=a.points;switch(a.command){case"L":return Rde.getPointOnLine(e,a.start.x,a.start.y,o[0],o[1]);case"C":return Rde.getPointOnCubicBezier(e/a.pathLength,a.start.x,a.start.y,o[0],o[1],o[2],o[3],o[4],o[5]);case"Q":return Rde.getPointOnQuadraticBezier(e/a.pathLength,a.start.x,a.start.y,o[0],o[1],o[2],o[3]);case"A":var c=o[0],i=o[1],l=o[2],s=o[3],h=o[4],d=o[5],u=o[6];return h+=d*e/a.pathLength,Rde.getPointOnEllipticalArc(c,i,l,s,h,u)}return null}static getLineLength(e,t,n,r){return Math.sqrt((n-e)*(n-e)+(r-t)*(r-t))}static getPointOnLine(e,t,n,r,a,o,c){void 0===o&&(o=t),void 0===c&&(c=n);var i=(a-n)/(r-t+1e-8),l=Math.sqrt(e*e/(1+i*i));r<t&&(l*=-1);var s,h=i*l;if(r===t)s={x:o,y:c+h};else if((c-n)/(o-t+1e-8)===i)s={x:o+l,y:c+h};else{var d,u,m=this.getLineLength(t,n,r,a),p=(o-t)*(r-t)+(c-n)*(a-n);d=t+(p/=m*m)*(r-t),u=n+p*(a-n);var v=this.getLineLength(o,c,d,u),f=Math.sqrt(e*e-v*v);l=Math.sqrt(f*f/(1+i*i)),r<t&&(l*=-1),s={x:d+l,y:u+(h=i*l)}}return s}static getPointOnCubicBezier(e,t,n,r,a,o,c,i,l){function s(e){return e*e*e}function h(e){return 3*e*e*(1-e)}function d(e){return 3*e*(1-e)*(1-e)}function u(e){return(1-e)*(1-e)*(1-e)}return{x:i*s(e)+o*h(e)+r*d(e)+t*u(e),y:l*s(e)+c*h(e)+a*d(e)+n*u(e)}}static getPointOnQuadraticBezier(e,t,n,r,a,o,c){function i(e){return e*e}function l(e){return 2*e*(1-e)}function s(e){return(1-e)*(1-e)}return{x:o*i(e)+r*l(e)+t*s(e),y:c*i(e)+a*l(e)+n*s(e)}}static getPointOnEllipticalArc(e,t,n,r,a,o){var c=Math.cos(o),i=Math.sin(o),l=n*Math.cos(a),s=r*Math.sin(a);return{x:e+(l*c-s*i),y:t+(l*i+s*c)}}static parsePathData(e){if(!e)return[];var t=e,n=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];t=t.replace(new RegExp(" ","g"),",");for(var r=0;r<n.length;r++)t=t.replace(new RegExp(n[r],"g"),"|"+n[r]);var a,o=t.split("|"),c=[],i=[],l=0,s=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi;for(r=1;r<o.length;r++){var d=o[r],u=d.charAt(0);for(d=d.slice(1),i.length=0;a=h.exec(d);)i.push(a[0]);for(var m=[],p=0,v=i.length;p<v;p++)if("00"!==i[p]){var f=parseFloat(i[p]);isNaN(f)?m.push(0):m.push(f)}else m.push(0,0);for(;m.length>0&&!isNaN(m[0]);){var z,g,y,M,E,b,H,V,C,L,w=null,k=[],x=l,S=s;switch(u){case"l":l+=m.shift(),s+=m.shift(),w="L",k.push(l,s);break;case"L":l=m.shift(),s=m.shift(),k.push(l,s);break;case"m":var T=m.shift(),O=m.shift();if(l+=T,s+=O,w="M",c.length>2&&"z"===c[c.length-1].command)for(var A=c.length-2;A>=0;A--)if("M"===c[A].command){l=c[A].points[0]+T,s=c[A].points[1]+O;break}k.push(l,s),u="l";break;case"M":l=m.shift(),s=m.shift(),w="M",k.push(l,s),u="L";break;case"h":l+=m.shift(),w="L",k.push(l,s);break;case"H":l=m.shift(),w="L",k.push(l,s);break;case"v":s+=m.shift(),w="L",k.push(l,s);break;case"V":s=m.shift(),w="L",k.push(l,s);break;case"C":k.push(m.shift(),m.shift(),m.shift(),m.shift()),l=m.shift(),s=m.shift(),k.push(l,s);break;case"c":k.push(l+m.shift(),s+m.shift(),l+m.shift(),s+m.shift()),l+=m.shift(),s+=m.shift(),w="C",k.push(l,s);break;case"S":g=l,y=s,"C"===(z=c[c.length-1]).command&&(g=l+(l-z.points[2]),y=s+(s-z.points[3])),k.push(g,y,m.shift(),m.shift()),l=m.shift(),s=m.shift(),w="C",k.push(l,s);break;case"s":g=l,y=s,"C"===(z=c[c.length-1]).command&&(g=l+(l-z.points[2]),y=s+(s-z.points[3])),k.push(g,y,l+m.shift(),s+m.shift()),l+=m.shift(),s+=m.shift(),w="C",k.push(l,s);break;case"Q":k.push(m.shift(),m.shift()),l=m.shift(),s=m.shift(),k.push(l,s);break;case"q":k.push(l+m.shift(),s+m.shift()),l+=m.shift(),s+=m.shift(),w="Q",k.push(l,s);break;case"T":g=l,y=s,"Q"===(z=c[c.length-1]).command&&(g=l+(l-z.points[0]),y=s+(s-z.points[1])),l=m.shift(),s=m.shift(),w="Q",k.push(g,y,l,s);break;case"t":g=l,y=s,"Q"===(z=c[c.length-1]).command&&(g=l+(l-z.points[0]),y=s+(s-z.points[1])),l+=m.shift(),s+=m.shift(),w="Q",k.push(g,y,l,s);break;case"A":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=l,L=s,l=m.shift(),s=m.shift(),w="A",k=this.convertEndpointToCenterParameterization(C,L,l,s,H,V,M,E,b);break;case"a":M=m.shift(),E=m.shift(),b=m.shift(),H=m.shift(),V=m.shift(),C=l,L=s,l+=m.shift(),s+=m.shift(),w="A",k=this.convertEndpointToCenterParameterization(C,L,l,s,H,V,M,E,b)}c.push({command:w||u,points:k,start:{x:x,y:S},pathLength:this.calcLength(x,S,w||u,k)})}"z"!==u&&"Z"!==u||c.push({command:"z",points:[],start:void 0,pathLength:0})}return c}static calcLength(e,t,n,r){var a,o,c,i,l=Rde;switch(n){case"L":return l.getLineLength(e,t,r[0],r[1]);case"C":for(a=0,o=l.getPointOnCubicBezier(0,e,t,r[0],r[1],r[2],r[3],r[4],r[5]),i=.01;i<=1;i+=.01)c=l.getPointOnCubicBezier(i,e,t,r[0],r[1],r[2],r[3],r[4],r[5]),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;return a;case"Q":for(a=0,o=l.getPointOnQuadraticBezier(0,e,t,r[0],r[1],r[2],r[3]),i=.01;i<=1;i+=.01)c=l.getPointOnQuadraticBezier(i,e,t,r[0],r[1],r[2],r[3]),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;return a;case"A":a=0;var s=r[4],h=r[5],d=r[4]+h,u=Math.PI/180;if(Math.abs(s-d)<u&&(u=Math.abs(s-d)),o=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],s,0),h<0)for(i=s-u;i>d;i-=u)c=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],i,0),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;else for(i=s+u;i<d;i+=u)c=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],i,0),a+=l.getLineLength(o.x,o.y,c.x,c.y),o=c;return c=l.getPointOnEllipticalArc(r[0],r[1],r[2],r[3],d,0),a+l.getLineLength(o.x,o.y,c.x,c.y)}return 0}static convertEndpointToCenterParameterization(e,t,n,r,a,o,c,i,l){var s=l*(Math.PI/180),h=Math.cos(s)*(e-n)/2+Math.sin(s)*(t-r)/2,d=-1*Math.sin(s)*(e-n)/2+Math.cos(s)*(t-r)/2,u=h*h/(c*c)+d*d/(i*i);u>1&&(c*=Math.sqrt(u),i*=Math.sqrt(u));var m=Math.sqrt((c*c*(i*i)-c*c*(d*d)-i*i*(h*h))/(c*c*(d*d)+i*i*(h*h)));a===o&&(m*=-1),isNaN(m)&&(m=0);var p=m*c*d/i,v=m*-i*h/c,f=(e+n)/2+Math.cos(s)*p-Math.sin(s)*v,z=(t+r)/2+Math.sin(s)*p+Math.cos(s)*v,g=function(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])},y=function(e,t){return(e[0]*t[0]+e[1]*t[1])/(g(e)*g(t))},M=function(e,t){return(e[0]*t[1]<e[1]*t[0]?-1:1)*Math.acos(y(e,t))},E=M([1,0],[(h-p)/c,(d-v)/i]),b=[(h-p)/c,(d-v)/i],H=[(-1*h-p)/c,(-1*d-v)/i],V=M(b,H);return y(b,H)<=-1&&(V=Math.PI),y(b,H)>=1&&(V=0),0===o&&V>0&&(V-=2*Math.PI),1===o&&V<0&&(V+=2*Math.PI),[f,z,c,i,E,V,s,o]}}Rde.prototype.className="Path",Rde.prototype._attrsAffectingSize=["data"],Ase(Rde),Zse.addGetterSetter(Rde,"data");class Nde extends Ade{_sceneFunc(e){super._sceneFunc(e);var t=2*Math.PI,n=this.points(),r=n,a=0!==this.tension()&&n.length>4;a&&(r=this.getTensionPoints());var o,c,i=this.pointerLength(),l=n.length;if(a){const e=[r[r.length-4],r[r.length-3],r[r.length-2],r[r.length-1],n[l-2],n[l-1]],t=Rde.calcLength(r[r.length-4],r[r.length-3],"C",e),a=Rde.getPointOnQuadraticBezier(Math.min(1,1-i/t),e[0],e[1],e[2],e[3],e[4],e[5]);o=n[l-2]-a.x,c=n[l-1]-a.y}else o=n[l-2]-n[l-4],c=n[l-1]-n[l-3];var s=(Math.atan2(c,o)+t)%t,h=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(n[l-2],n[l-1]),e.rotate(s),e.moveTo(0,0),e.lineTo(-i,h/2),e.lineTo(-i,-h/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(n[0],n[1]),a?(o=(r[0]+r[2])/2-n[0],c=(r[1]+r[3])/2-n[1]):(o=n[2]-n[0],c=n[3]-n[1]),e.rotate((Math.atan2(-c,-o)+t)%t),e.moveTo(0,0),e.lineTo(-i,h/2),e.lineTo(-i,-h/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var t=this.dashEnabled();t&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),t&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),t=this.pointerWidth()/2;return{x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}}}Nde.prototype.className="Arrow",Ase(Nde),Zse.addGetterSetter(Nde,"pointerLength",10,$se()),Zse.addGetterSetter(Nde,"pointerWidth",10,$se()),Zse.addGetterSetter(Nde,"pointerAtBeginning",!1),Zse.addGetterSetter(Nde,"pointerAtEnding",!0);class _de extends vde{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,2*Math.PI,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}_de.prototype._centroid=!0,_de.prototype.className="Circle",_de.prototype._attrsAffectingSize=["radius"],Ase(_de),Zse.addGetterSetter(_de,"radius",0,$se());class Dde extends vde{_sceneFunc(e){var t=this.radiusX(),n=this.radiusY();e.beginPath(),e.save(),t!==n&&e.scale(1,n/t),e.arc(0,0,t,0,2*Math.PI,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radiusX()}getHeight(){return 2*this.radiusY()}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Dde.prototype.className="Ellipse",Dde.prototype._centroid=!0,Dde.prototype._attrsAffectingSize=["radiusX","radiusY"],Ase(Dde),Zse.addComponentsGetterSetter(Dde,"radius",["x","y"]),Zse.addGetterSetter(Dde,"radiusX",0,$se()),Zse.addGetterSetter(Dde,"radiusY",0,$se());class Pde extends vde{constructor(e){super(e),this.on("imageChange.konva",(()=>{this._setImageLoad()})),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&4===e.readyState||e&&e.addEventListener&&e.addEventListener("load",(()=>{this._requestDraw()}))}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const t=this.getWidth(),n=this.getHeight(),r=this.cornerRadius(),a=this.attrs.image;let o;if(a){const e=this.attrs.cropWidth,r=this.attrs.cropHeight;o=e&&r?[a,this.cropX(),this.cropY(),e,r,0,0,t,n]:[a,0,0,t,n]}(this.hasFill()||this.hasStroke()||r)&&(e.beginPath(),r?jse.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)),a&&(r&&e.clip(),e.drawImage.apply(e,o))}_hitFunc(e){var t=this.width(),n=this.height(),r=this.cornerRadius();e.beginPath(),r?jse.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,t;return null!==(e=this.attrs.width)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.width}getHeight(){var e,t;return null!==(e=this.attrs.height)&&void 0!==e?e:null===(t=this.image())||void 0===t?void 0:t.height}static fromURL(e,t,n=null){var r=jse.createImageElement();r.onload=function(){var e=new Pde({image:r});t(e)},r.onerror=n,r.crossOrigin="Anonymous",r.src=e}}Pde.prototype.className="Image",Ase(Pde),Zse.addGetterSetter(Pde,"cornerRadius",0,qse(4)),Zse.addGetterSetter(Pde,"image"),Zse.addComponentsGetterSetter(Pde,"crop",["x","y","width","height"]),Zse.addGetterSetter(Pde,"cropX",0,$se()),Zse.addGetterSetter(Pde,"cropY",0,$se()),Zse.addGetterSetter(Pde,"cropWidth",0,$se()),Zse.addGetterSetter(Pde,"cropHeight",0,$se());var Fde=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],Ide="up",Bde="right",jde="down",Ude="left",Wde=Fde.length;class $de extends Mde{constructor(e){super(e),this.on("add.konva",(function(e){this._addListeners(e.child),this._sync()}))}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var t,n=this,r=function(){n._sync()};for(t=0;t<Wde;t++)e.on(Fde[t]+"Change.konva",r)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e,t,n,r,a,o,c,i=this.getText(),l=this.getTag();if(i&&l){switch(e=i.width(),t=i.height(),n=l.pointerDirection(),r=l.pointerWidth(),c=l.pointerHeight(),a=0,o=0,n){case Ide:a=e/2,o=-1*c;break;case Bde:a=e+r,o=t/2;break;case jde:a=e/2,o=t+c;break;case Ude:a=-1*r,o=t/2}l.setAttrs({x:-1*a,y:-1*o,width:e,height:t}),i.setAttrs({x:-1*a,y:-1*o})}}}$de.prototype.className="Label",Ase($de);class qde extends vde{_sceneFunc(e){var t=this.width(),n=this.height(),r=this.pointerDirection(),a=this.pointerWidth(),o=this.pointerHeight(),c=this.cornerRadius();let i=0,l=0,s=0,h=0;"number"==typeof c?i=l=s=h=Math.min(c,t/2,n/2):(i=Math.min(c[0]||0,t/2,n/2),l=Math.min(c[1]||0,t/2,n/2),h=Math.min(c[2]||0,t/2,n/2),s=Math.min(c[3]||0,t/2,n/2)),e.beginPath(),e.moveTo(i,0),r===Ide&&(e.lineTo((t-a)/2,0),e.lineTo(t/2,-1*o),e.lineTo((t+a)/2,0)),e.lineTo(t-l,0),e.arc(t-l,l,l,3*Math.PI/2,0,!1),r===Bde&&(e.lineTo(t,(n-o)/2),e.lineTo(t+a,n/2),e.lineTo(t,(n+o)/2)),e.lineTo(t,n-h),e.arc(t-h,n-h,h,0,Math.PI/2,!1),r===jde&&(e.lineTo((t+a)/2,n),e.lineTo(t/2,n+o),e.lineTo((t-a)/2,n)),e.lineTo(s,n),e.arc(s,n-s,s,Math.PI/2,Math.PI,!1),r===Ude&&(e.lineTo(0,(n+o)/2),e.lineTo(-1*a,n/2),e.lineTo(0,(n-o)/2)),e.lineTo(0,i),e.arc(i,i,i,Math.PI,3*Math.PI/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,t=0,n=this.pointerWidth(),r=this.pointerHeight(),a=this.pointerDirection(),o=this.width(),c=this.height();return a===Ide?(t-=r,c+=r):a===jde?c+=r:a===Ude?(e-=1.5*n,o+=n):a===Bde&&(o+=1.5*n),{x:e,y:t,width:o,height:c}}}qde.prototype.className="Tag",Ase(qde),Zse.addGetterSetter(qde,"pointerDirection","none"),Zse.addGetterSetter(qde,"pointerWidth",0,$se()),Zse.addGetterSetter(qde,"pointerHeight",0,$se()),Zse.addGetterSetter(qde,"cornerRadius",0,qse(4));class Gde extends vde{_sceneFunc(e){var t=this.cornerRadius(),n=this.width(),r=this.height();e.beginPath(),t?jse.drawRoundedRectPath(e,n,r,t):e.rect(0,0,n,r),e.closePath(),e.fillStrokeShape(this)}}Gde.prototype.className="Rect",Ase(Gde),Zse.addGetterSetter(Gde,"cornerRadius",0,qse(4));class Yde extends vde{_sceneFunc(e){const t=this._getPoints();e.beginPath(),e.moveTo(t[0].x,t[0].y);for(var n=1;n<t.length;n++)e.lineTo(t[n].x,t[n].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,t=this.attrs.radius||0,n=[];for(var r=0;r<e;r++)n.push({x:t*Math.sin(2*r*Math.PI/e),y:-1*t*Math.cos(2*r*Math.PI/e)});return n}getSelfRect(){const e=this._getPoints();var t=e[0].x,n=e[0].y,r=e[0].x,a=e[0].y;return e.forEach((e=>{t=Math.min(t,e.x),n=Math.max(n,e.x),r=Math.min(r,e.y),a=Math.max(a,e.y)})),{x:t,y:r,width:n-t,height:a-r}}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Yde.prototype.className="RegularPolygon",Yde.prototype._centroid=!0,Yde.prototype._attrsAffectingSize=["radius"],Ase(Yde),Zse.addGetterSetter(Yde,"radius",0,$se()),Zse.addGetterSetter(Yde,"sides",0,$se());var Kde=2*Math.PI;class Xde extends vde{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,Kde,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),Kde,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Xde.prototype.className="Ring",Xde.prototype._centroid=!0,Xde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ase(Xde),Zse.addGetterSetter(Xde,"innerRadius",0,$se()),Zse.addGetterSetter(Xde,"outerRadius",0,$se());class Qde extends vde{constructor(e){super(e),this._updated=!0,this.anim=new bde((()=>{var e=this._updated;return this._updated=!1,e})),this.on("animationChange.konva",(function(){this.frameIndex(0)})),this.on("frameIndexChange.konva",(function(){this._updated=!0})),this.on("frameRateChange.konva",(function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())}))}_sceneFunc(e){var t=this.animation(),n=this.frameIndex(),r=4*n,a=this.animations()[t],o=this.frameOffsets(),c=a[r+0],i=a[r+1],l=a[r+2],s=a[r+3],h=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,l,s),e.closePath(),e.fillStrokeShape(this)),h)if(o){var d=o[t],u=2*n;e.drawImage(h,c,i,l,s,d[u+0],d[u+1],l,s)}else e.drawImage(h,c,i,l,s,0,0,l,s)}_hitFunc(e){var t=this.animation(),n=this.frameIndex(),r=4*n,a=this.animations()[t],o=this.frameOffsets(),c=a[r+2],i=a[r+3];if(e.beginPath(),o){var l=o[t],s=2*n;e.rect(l[s+0],l[s+1],c,i)}else e.rect(0,0,c,i);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval((function(){e._updateIndex()}),1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),t=this.animation();e<this.animations()[t].length/4-1?this.frameIndex(e+1):this.frameIndex(0)}}Qde.prototype.className="Sprite",Ase(Qde),Zse.addGetterSetter(Qde,"animation"),Zse.addGetterSetter(Qde,"animations"),Zse.addGetterSetter(Qde,"frameOffsets"),Zse.addGetterSetter(Qde,"image"),Zse.addGetterSetter(Qde,"frameIndex",0,$se()),Zse.addGetterSetter(Qde,"frameRate",17,$se()),Zse.backCompat(Qde,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});class Jde extends vde{_sceneFunc(e){var t=this.innerRadius(),n=this.outerRadius(),r=this.numPoints();e.beginPath(),e.moveTo(0,0-n);for(var a=1;a<2*r;a++){var o=a%2==0?n:t,c=o*Math.sin(a*Math.PI/r),i=-1*o*Math.cos(a*Math.PI/r);e.lineTo(c,i)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.outerRadius()}getHeight(){return 2*this.outerRadius()}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}function Zde(e){return Array.from(e)}Jde.prototype.className="Star",Jde.prototype._centroid=!0,Jde.prototype._attrsAffectingSize=["innerRadius","outerRadius"],Ase(Jde),Zse.addGetterSetter(Jde,"numPoints",5,$se()),Zse.addGetterSetter(Jde,"innerRadius",0,$se()),Zse.addGetterSetter(Jde,"outerRadius",0,$se());var eue,tue="auto",nue="justify",rue="left",aue="middle",oue="normal",cue=" ",iue="none",lue=["fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],sue=lue.length;function hue(){return eue||(eue=jse.createCanvasElement().getContext("2d"))}class due extends vde{constructor(e){super(function(e){return(e=e||{}).fillLinearGradientColorStops||e.fillRadialGradientColorStops||e.fillPatternImage||(e.fill=e.fill||"black"),e}(e)),this._partialTextX=0,this._partialTextY=0;for(var t=0;t<sue;t++)this.on(lue[t]+"Change.konva",this._setTextData);this._setTextData()}_sceneFunc(e){var t=this.textArr,n=t.length;if(this.text()){var r,a=this.padding(),o=this.fontSize(),c=this.lineHeight()*o,i=this.verticalAlign(),l=0,s=this.align(),h=this.getWidth(),d=this.letterSpacing(),u=this.fill(),m=this.textDecoration(),p=-1!==m.indexOf("underline"),v=-1!==m.indexOf("line-through"),f=0,z=(f=c/2,0),g=0;for(e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",aue),e.setAttr("textAlign",rue),i===aue?l=(this.getHeight()-n*c-2*a)/2:"bottom"===i&&(l=this.getHeight()-n*c-2*a),e.translate(a,l+a),r=0;r<n;r++){z=0,g=0;var y,M,E,b=t[r],H=b.text,V=b.width,C=b.lastInParagraph;if(e.save(),"right"===s?z+=h-V-2*a:"center"===s&&(z+=(h-V-2*a)/2),p){e.save(),e.beginPath(),e.moveTo(z,f+g+Math.round(o/2)),M=0==(y=H.split(" ").length-1),E=s!==nue||C?V:h-2*a,e.lineTo(z+Math.round(E),f+g+Math.round(o/2)),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(z,f+g),M=0==(y=H.split(" ").length-1),E=s===nue&&C&&!M?h-2*a:V,e.lineTo(z+Math.round(E),f+g),e.lineWidth=o/15;const t=this._getLinearGradient();e.strokeStyle=t||u,e.stroke(),e.restore()}if(0!==d||s===nue){y=H.split(" ").length-1;for(var L=Zde(H),w=0;w<L.length;w++){var k=L[w];" "!==k||C||s!==nue||(z+=(h-2*a-V)/y),this._partialTextX=z,this._partialTextY=f+g,this._partialText=k,e.fillStrokeShape(this),z+=this.measureSize(k).width+d}}else this._partialTextX=z,this._partialTextY=f+g,this._partialText=H,e.fillStrokeShape(this);e.restore(),n>1&&(f+=c)}}}_hitFunc(e){var t=this.getWidth(),n=this.getHeight();e.beginPath(),e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}setText(e){var t=jse._isString(e)?e:null==e?"":e+"";return this._setAttr("text",t),this}getWidth(){return this.attrs.width===tue||void 0===this.attrs.width?this.getTextWidth()+2*this.padding():this.attrs.width}getHeight(){return this.attrs.height===tue||void 0===this.attrs.height?this.fontSize()*this.textArr.length*this.lineHeight()+2*this.padding():this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return jse.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var t,n=hue(),r=this.fontSize();return n.save(),n.font=this._getContextFont(),t=n.measureText(e),n.restore(),{width:t.width,height:r}}_getContextFont(){return this.fontStyle()+cue+this.fontVariant()+cue+(this.fontSize()+"px ")+function(e){return e.split(",").map((e=>{const t=(e=e.trim()).indexOf(" ")>=0,n=e.indexOf('"')>=0||e.indexOf("'")>=0;return t&&!n&&(e=`"${e}"`),e})).join(", ")}(this.fontFamily())}_addTextLine(e){this.align()===nue&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var t=this.letterSpacing(),n=e.length;return hue().measureText(e).width+(n?t*(n-1):0)}_setTextData(){var e=this.text().split("\n"),t=+this.fontSize(),n=0,r=this.lineHeight()*t,a=this.attrs.width,o=this.attrs.height,c=a!==tue&&void 0!==a,i=o!==tue&&void 0!==o,l=this.padding(),s=a-2*l,h=o-2*l,d=0,u=this.wrap(),m="char"!==u&&u!==iue,p=this.ellipsis();this.textArr=[],hue().font=this._getContextFont();for(var v=p?this._getTextWidth("…"):0,f=0,z=e.length;f<z;++f){var g=e[f],y=this._getTextWidth(g);if(c&&y>s)for(;g.length>0;){for(var M=0,E=g.length,b="",H=0;M<E;){var V=M+E>>>1,C=g.slice(0,V+1),L=this._getTextWidth(C)+v;L<=s?(M=V+1,b=C,H=L):E=V}if(!b)break;if(m){var w,k=g[b.length];(w=(k===cue||"-"===k)&&H<=s?b.length:Math.max(b.lastIndexOf(cue),b.lastIndexOf("-"))+1)>0&&(M=w,b=b.slice(0,M),H=this._getTextWidth(b))}if(b=b.trimRight(),this._addTextLine(b),n=Math.max(n,H),d+=r,this._shouldHandleEllipsis(d)){this._tryToAddEllipsisToLastLine();break}if((g=(g=g.slice(M)).trimLeft()).length>0&&(y=this._getTextWidth(g))<=s){this._addTextLine(g),d+=r,n=Math.max(n,y);break}}else this._addTextLine(g),d+=r,n=Math.max(n,y),this._shouldHandleEllipsis(d)&&f<z-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),i&&d+r>h)break}this.textHeight=t,this.textWidth=n}_shouldHandleEllipsis(e){var t=+this.fontSize(),n=this.lineHeight()*t,r=this.attrs.height,a=r!==tue&&void 0!==r,o=r-2*this.padding();return!(this.wrap()!==iue)||a&&e+n>o}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,t=e!==tue&&void 0!==e,n=e-2*this.padding(),r=this.ellipsis(),a=this.textArr[this.textArr.length-1];a&&r&&(t&&(this._getTextWidth(a.text+"…")<n||(a.text=a.text.slice(0,a.text.length-3))),this.textArr.splice(this.textArr.length-1,1),this._addTextLine(a.text+"…"))}getStrokeScaleEnabled(){return!0}}due.prototype._fillFunc=function(e){e.fillText(this._partialText,this._partialTextX,this._partialTextY)},due.prototype._strokeFunc=function(e){e.strokeText(this._partialText,this._partialTextX,this._partialTextY)},due.prototype.className="Text",due.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"],Ase(due),Zse.overWriteSetter(due,"width",Gse()),Zse.overWriteSetter(due,"height",Gse()),Zse.addGetterSetter(due,"fontFamily","Arial"),Zse.addGetterSetter(due,"fontSize",12,$se()),Zse.addGetterSetter(due,"fontStyle",oue),Zse.addGetterSetter(due,"fontVariant",oue),Zse.addGetterSetter(due,"padding",0,$se()),Zse.addGetterSetter(due,"align",rue),Zse.addGetterSetter(due,"verticalAlign","top"),Zse.addGetterSetter(due,"lineHeight",1,$se()),Zse.addGetterSetter(due,"wrap","word"),Zse.addGetterSetter(due,"ellipsis",!1,Xse()),Zse.addGetterSetter(due,"letterSpacing",0,$se()),Zse.addGetterSetter(due,"text","",Yse()),Zse.addGetterSetter(due,"textDecoration","");var uue="normal";function mue(e){e.fillText(this.partialText,0,0)}function pue(e){e.strokeText(this.partialText,0,0)}class vue extends vde{constructor(e){super(e),this.dummyCanvas=jse.createCanvasElement(),this.dataArray=[],this.dataArray=Rde.parsePathData(this.attrs.data),this.on("dataChange.konva",(function(){this.dataArray=Rde.parsePathData(this.attrs.data),this._setTextData()})),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var t=this.textDecoration(),n=this.fill(),r=this.fontSize(),a=this.glyphInfo;"underline"===t&&e.beginPath();for(var o=0;o<a.length;o++){e.save();var c=a[o].p0;e.translate(c.x,c.y),e.rotate(a[o].rotation),this.partialText=a[o].text,e.fillStrokeShape(this),"underline"===t&&(0===o&&e.moveTo(0,r/2+1),e.lineTo(r,r/2+1)),e.restore()}"underline"===t&&(e.strokeStyle=n,e.lineWidth=r/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var t=this.glyphInfo;if(t.length>=1){var n=t[0].p0;e.moveTo(n.x,n.y)}for(var r=0;r<t.length;r++){var a=t[r].p1;e.lineTo(a.x,a.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return jse.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return due.prototype.setText.call(this,e)}_getContextFont(){return due.prototype._getContextFont.call(this)}_getTextSize(e){var t=this.dummyCanvas.getContext("2d");t.save(),t.font=this._getContextFont();var n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(this.attrs.fontSize,10)}}_setTextData(){var e=this,t=this._getTextSize(this.attrs.text),n=this.letterSpacing(),r=this.align(),a=this.kerningFunc();this.textWidth=t.width,this.textHeight=t.height;var o=Math.max(this.textWidth+((this.attrs.text||"").length-1)*n,0);this.glyphInfo=[];for(var c=0,i=0;i<e.dataArray.length;i++)e.dataArray[i].pathLength>0&&(c+=e.dataArray[i].pathLength);var l=0;"center"===r&&(l=Math.max(0,c/2-o/2)),"right"===r&&(l=Math.max(0,c-o));for(var s,h,d,u=Zde(this.text()),m=this.text().split(" ").length-1,p=-1,v=0,f=function(){v=0;for(var t=e.dataArray,n=p+1;n<t.length;n++){if(t[n].pathLength>0)return p=n,t[n];"M"===t[n].command&&(s={x:t[n].points[0],y:t[n].points[1]})}return{}},z=function(t){var a=e._getTextSize(t).width+n;" "===t&&"justify"===r&&(a+=(c-o)/m);var i=0,l=0;for(h=void 0;Math.abs(a-i)/a>.01&&l<20;){l++;for(var u=i;void 0===d;)(d=f())&&u+d.pathLength<a&&(u+=d.pathLength,d=void 0);if(0===Object.keys(d).length||void 0===s)return;var p=!1;switch(d.command){case"L":Rde.getLineLength(s.x,s.y,d.points[0],d.points[1])>a?h=Rde.getPointOnLine(a,s.x,s.y,d.points[0],d.points[1],s.x,s.y):d=void 0;break;case"A":var z=d.points[4],g=d.points[5],y=d.points[4]+g;0===v?v=z+1e-8:a>i?v+=Math.PI/180*g/Math.abs(g):v-=Math.PI/360*g/Math.abs(g),(g<0&&v<y||g>=0&&v>y)&&(v=y,p=!0),h=Rde.getPointOnEllipticalArc(d.points[0],d.points[1],d.points[2],d.points[3],v,d.points[6]);break;case"C":0===v?v=a>d.pathLength?1e-8:a/d.pathLength:a>i?v+=(a-i)/d.pathLength/2:v=Math.max(v-(i-a)/d.pathLength/2,0),v>1&&(v=1,p=!0),h=Rde.getPointOnCubicBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3],d.points[4],d.points[5]);break;case"Q":0===v?v=a/d.pathLength:a>i?v+=(a-i)/d.pathLength:v-=(i-a)/d.pathLength,v>1&&(v=1,p=!0),h=Rde.getPointOnQuadraticBezier(v,d.start.x,d.start.y,d.points[0],d.points[1],d.points[2],d.points[3])}void 0!==h&&(i=Rde.getLineLength(s.x,s.y,h.x,h.y)),p&&(p=!1,d=void 0)}},g=l/(e._getTextSize("C").width+n)-1,y=0;y<g&&(z("C"),void 0!==s&&void 0!==h);y++)s=h;for(var M=0;M<u.length&&(z(u[M]),void 0!==s&&void 0!==h);M++){var E=Rde.getLineLength(s.x,s.y,h.x,h.y),b=0;if(a)try{b=a(u[M-1],u[M])*this.fontSize()}catch(e){b=0}s.x+=b,h.x+=b,this.textWidth+=b;var H=Rde.getPointOnLine(b+E/2,s.x,s.y,h.x,h.y),V=Math.atan2(h.y-s.y,h.x-s.x);this.glyphInfo.push({transposeX:H.x,transposeY:H.y,text:u[M],rotation:V,p0:s,p1:h}),s=h}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach((function(t){e.push(t.p0.x),e.push(t.p0.y),e.push(t.p1.x),e.push(t.p1.y)}));for(var t,n,r=e[0]||0,a=e[0]||0,o=e[1]||0,c=e[1]||0,i=0;i<e.length/2;i++)t=e[2*i],n=e[2*i+1],r=Math.min(r,t),a=Math.max(a,t),o=Math.min(o,n),c=Math.max(c,n);var l=this.fontSize();return{x:r-l/2,y:o-l/2,width:a-r+l,height:c-o+l}}destroy(){return jse.releaseCanvas(this.dummyCanvas),super.destroy()}}vue.prototype._fillFunc=mue,vue.prototype._strokeFunc=pue,vue.prototype._fillFuncHit=mue,vue.prototype._strokeFuncHit=pue,vue.prototype.className="TextPath",vue.prototype._attrsAffectingSize=["text","fontSize","data"],Ase(vue),Zse.addGetterSetter(vue,"data"),Zse.addGetterSetter(vue,"fontFamily","Arial"),Zse.addGetterSetter(vue,"fontSize",12,$se()),Zse.addGetterSetter(vue,"fontStyle",uue),Zse.addGetterSetter(vue,"align","left"),Zse.addGetterSetter(vue,"letterSpacing",0,$se()),Zse.addGetterSetter(vue,"textBaseline","middle"),Zse.addGetterSetter(vue,"fontVariant",uue),Zse.addGetterSetter(vue,"text",""),Zse.addGetterSetter(vue,"textDecoration",null),Zse.addGetterSetter(vue,"kerningFunc",null);var fue="tr-konva",zue=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange"].map((e=>e+`.${fue}`)).join(" "),gue="nodesRect",yue=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],Mue={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const Eue="ontouchstart"in Ose._global;var bue=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"];function Hue(e,t,n){const r=n.x+(e.x-n.x)*Math.cos(t)-(e.y-n.y)*Math.sin(t),a=n.y+(e.x-n.x)*Math.sin(t)+(e.y-n.y)*Math.cos(t);return Object.assign(Object.assign({},e),{rotation:e.rotation+t,x:r,y:a})}class Vue extends Mde{constructor(e){super(e),this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(zue,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return jse.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return fue+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const t=e.filter((e=>!e.isAncestorOf(this)||(jse.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1)));return this._nodes=e=t,1===e.length&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach((e=>{const t=()=>{1===this.nodes().length&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),this._transforming||this.isDragging()||this.update()},n=e._attrsAffectingSize.map((e=>e+"Change."+this._getEventNamespace())).join(" ");e.on(n,t),e.on(yue.map((e=>e+`.${this._getEventNamespace()}`)).join(" "),t),e.on(`absoluteTransformChange.${this._getEventNamespace()}`,t),this._proxyDrag(e)})),this._resetTransformCache(),!!this.findOne(".top-left")&&this.update(),this}_proxyDrag(e){let t;e.on(`dragstart.${this._getEventNamespace()}`,(n=>{t=e.getAbsolutePosition(),this.isDragging()||e===this.findOne(".back")||this.startDrag(n,!1)})),e.on(`dragmove.${this._getEventNamespace()}`,(n=>{if(!t)return;const r=e.getAbsolutePosition(),a=r.x-t.x,o=r.y-t.y;this.nodes().forEach((t=>{if(t===e)return;if(t.isDragging())return;const r=t.getAbsolutePosition();t.setAbsolutePosition({x:r.x+a,y:r.y+o}),t.startDrag(n)})),t=null}))}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach((e=>{e.off("."+this._getEventNamespace())})),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(gue),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(gue,this.__getNodeRect)}__getNodeShape(e,t=this.rotation(),n){var r=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),a=e.getAbsoluteScale(n),o=e.getAbsolutePosition(n),c=r.x*a.x-e.offsetX()*a.x,i=r.y*a.y-e.offsetY()*a.y;const l=(Ose.getAngle(e.getAbsoluteRotation())+2*Math.PI)%(2*Math.PI);return Hue({x:o.x+c*Math.cos(l)+i*Math.sin(-l),y:o.y+i*Math.cos(l)+c*Math.sin(l),width:r.width*a.x,height:r.height*a.y,rotation:l},-Ose.getAngle(t),{x:0,y:0})}__getNodeRect(){if(!this.getNode())return{x:-1e8,y:-1e8,width:0,height:0,rotation:0};const e=[];this.nodes().map((t=>{const n=t.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var r=[{x:n.x,y:n.y},{x:n.x+n.width,y:n.y},{x:n.x+n.width,y:n.y+n.height},{x:n.x,y:n.y+n.height}],a=t.getAbsoluteTransform();r.forEach((function(t){var n=a.point(t);e.push(n)}))}));const t=new Rse;var n,r,a,o;t.rotate(-Ose.getAngle(this.rotation())),e.forEach((function(e){var c=t.point(e);void 0===n&&(n=a=c.x,r=o=c.y),n=Math.min(n,c.x),r=Math.min(r,c.y),a=Math.max(a,c.x),o=Math.max(o,c.y)})),t.invert();const c=t.point({x:n,y:r});return{x:c.x,y:c.y,width:a-n,height:o-r,rotation:Ose.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),bue.forEach(function(e){this._createAnchor(e)}.bind(this)),this._createAnchor("rotater")}_createAnchor(e){var t=new Gde({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:Eue?10:"auto"}),n=this;t.on("mousedown touchstart",(function(e){n._handleMouseDown(e)})),t.on("dragstart",(e=>{t.stopDrag(),e.cancelBubble=!0})),t.on("dragend",(e=>{e.cancelBubble=!0})),t.on("mouseenter",(()=>{var n=Ose.getAngle(this.rotation()),r=function(e,t){if("rotater"===e)return"crosshair";t+=jse.degToRad(Mue[e]||0);var n=(jse.radToDeg(t)%360+360)%360;return jse._inRange(n,337.5,360)||jse._inRange(n,0,22.5)?"ns-resize":jse._inRange(n,22.5,67.5)?"nesw-resize":jse._inRange(n,67.5,112.5)?"ew-resize":jse._inRange(n,112.5,157.5)?"nwse-resize":jse._inRange(n,157.5,202.5)?"ns-resize":jse._inRange(n,202.5,247.5)?"nesw-resize":jse._inRange(n,247.5,292.5)?"ew-resize":jse._inRange(n,292.5,337.5)?"nwse-resize":(jse.error("Transformer has unknown angle for cursor detection: "+n),"pointer")}(e,n);t.getStage().content&&(t.getStage().content.style.cursor=r),this._cursorChange=!0})),t.on("mouseout",(()=>{t.getStage().content&&(t.getStage().content.style.cursor=""),this._cursorChange=!1})),this.add(t)}_createBack(){var e=new vde({name:"back",width:0,height:0,draggable:!0,sceneFunc(e){var t=this.getParent(),n=t.padding();e.beginPath(),e.rect(-n,-n,this.width()+2*n,this.height()+2*n),e.moveTo(this.width()/2,-n),t.rotateEnabled()&&e.lineTo(this.width()/2,-t.rotateAnchorOffset()*jse._sign(this.height())-n),e.fillStrokeShape(this)},hitFunc:(e,t)=>{if(this.shouldOverdrawWholeArea()){var n=this.padding();e.beginPath(),e.rect(-n,-n,t.width()+2*n,t.height()+2*n),e.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",(e=>{e.cancelBubble=!0})),e.on("dragmove",(e=>{e.cancelBubble=!0})),e.on("dragend",(e=>{e.cancelBubble=!0})),this.on("dragmove",(e=>{this.update()}))}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var t=this._getNodeRect(),n=t.width,r=t.height,a=Math.sqrt(Math.pow(n,2)+Math.pow(r,2));this.sin=Math.abs(r/a),this.cos=Math.abs(n/a),"undefined"!=typeof window&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var o=e.target.getAbsolutePosition(),c=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:c.x-o.x,y:c.y-o.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach((t=>{t._fire("transformstart",{evt:e.evt,target:t})}))}_handleMouseMove(e){var t,n,r,a=this.findOne("."+this._movingAnchorName),o=a.getStage();o.setPointersPositions(e);const c=o.getPointerPosition();let i={x:c.x-this._anchorDragOffset.x,y:c.y-this._anchorDragOffset.y};const l=a.getAbsolutePosition();this.anchorDragBoundFunc()&&(i=this.anchorDragBoundFunc()(l,i,e)),a.setAbsolutePosition(i);const s=a.getAbsolutePosition();if(l.x!==s.x||l.y!==s.y)if("rotater"!==this._movingAnchorName){var h=this.keepRatio()||e.shiftKey,d=this.centeredScaling()||e.altKey;if("top-left"===this._movingAnchorName){if(h){var u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};r=Math.sqrt(Math.pow(u.x-a.x(),2)+Math.pow(u.y-a.y(),2));var m=this.findOne(".top-left").x()>u.x?-1:1,p=this.findOne(".top-left").y()>u.y?-1:1;t=r*this.cos*m,n=r*this.sin*p,this.findOne(".top-left").x(u.x-t),this.findOne(".top-left").y(u.y-n)}}else if("top-center"===this._movingAnchorName)this.findOne(".top-left").y(a.y());else if("top-right"===this._movingAnchorName){h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()},r=Math.sqrt(Math.pow(a.x()-u.x,2)+Math.pow(u.y-a.y(),2)),m=this.findOne(".top-right").x()<u.x?-1:1,p=this.findOne(".top-right").y()>u.y?-1:1,t=r*this.cos*m,n=r*this.sin*p,this.findOne(".top-right").x(u.x+t),this.findOne(".top-right").y(u.y-n));var v=a.position();this.findOne(".top-left").y(v.y),this.findOne(".bottom-right").x(v.x)}else"middle-left"===this._movingAnchorName?this.findOne(".top-left").x(a.x()):"middle-right"===this._movingAnchorName?this.findOne(".bottom-right").x(a.x()):"bottom-left"===this._movingAnchorName?(h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()},r=Math.sqrt(Math.pow(u.x-a.x(),2)+Math.pow(a.y()-u.y,2)),m=u.x<a.x()?-1:1,p=a.y()<u.y?-1:1,t=r*this.cos*m,n=r*this.sin*p,a.x(u.x-t),a.y(u.y+n)),v=a.position(),this.findOne(".top-left").x(v.x),this.findOne(".bottom-right").y(v.y)):"bottom-center"===this._movingAnchorName?this.findOne(".bottom-right").y(a.y()):"bottom-right"===this._movingAnchorName?h&&(u=d?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()},r=Math.sqrt(Math.pow(a.x()-u.x,2)+Math.pow(a.y()-u.y,2)),m=this.findOne(".bottom-right").x()<u.x?-1:1,p=this.findOne(".bottom-right").y()<u.y?-1:1,t=r*this.cos*m,n=r*this.sin*p,this.findOne(".bottom-right").x(u.x+t),this.findOne(".bottom-right").y(u.y+n)):console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));if(d=this.centeredScaling()||e.altKey){var f=this.findOne(".top-left"),z=this.findOne(".bottom-right"),g=f.x(),y=f.y(),M=this.getWidth()-z.x(),E=this.getHeight()-z.y();z.move({x:-g,y:-y}),f.move({x:M,y:E})}var b=this.findOne(".top-left").getAbsolutePosition();t=b.x,n=b.y;var H=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),V=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:t,y:n,width:H,height:V,rotation:Ose.getAngle(this.rotation())},e)}else{var C=this._getNodeRect();t=a.x()-C.width/2,n=-a.y()+C.height/2;let r=Math.atan2(-n,t)+Math.PI/2;C.height<0&&(r-=Math.PI);const o=Ose.getAngle(this.rotation())+r,c=Ose.getAngle(this.rotationSnapTolerance()),i=function(e,t){const n=function(e){return{x:e.x+e.width/2*Math.cos(e.rotation)+e.height/2*Math.sin(-e.rotation),y:e.y+e.height/2*Math.cos(e.rotation)+e.width/2*Math.sin(e.rotation)}}(e);return Hue(e,t,n)}(C,function(e,t,n){let r=t;for(let a=0;a<e.length;a++){const o=Ose.getAngle(e[a]),c=Math.abs(o-t)%(2*Math.PI);Math.min(c,2*Math.PI-c)<n&&(r=o)}return r}(this.rotationSnaps(),o,c)-C.rotation);this._fitNodesInto(i,e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,"undefined"!=typeof window&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var t=this.getNode();this._fire("transformend",{evt:e,target:t}),t&&this._nodes.forEach((t=>{t._fire("transformend",{evt:e,target:t})})),this._movingAnchorName=null}}_fitNodesInto(e,t){var n=this._getNodeRect();if(jse._inRange(e.width,2*-this.padding()-1,1))return void this.update();if(jse._inRange(e.height,2*-this.padding()-1,1))return void this.update();const r=this.flipEnabled();var a=new Rse;if(a.rotate(Ose.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const t=a.point({x:2*-this.padding(),y:0});if(e.x+=t.x,e.y+=t.y,e.width+=2*this.padding(),this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,!r)return void this.update()}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const t=a.point({x:2*this.padding(),y:0});if(this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.width+=2*this.padding(),!r)return void this.update()}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const t=a.point({x:0,y:2*-this.padding()});if(e.x+=t.x,e.y+=t.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!r)return void this.update()}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const t=a.point({x:0,y:2*this.padding()});if(this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=t.x,this._anchorDragOffset.y-=t.y,e.height+=2*this.padding(),!r)return void this.update()}if(this.boundBoxFunc()){const t=this.boundBoxFunc()(n,e);t?e=t:jse.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const o=1e7,c=new Rse;c.translate(n.x,n.y),c.rotate(n.rotation),c.scale(n.width/o,n.height/o);const i=new Rse;i.translate(e.x,e.y),i.rotate(e.rotation),i.scale(e.width/o,e.height/o);const l=i.multiply(c.invert());this._nodes.forEach((e=>{var n;const r=e.getParent().getAbsoluteTransform(),a=e.getTransform().copy();a.translate(e.offsetX(),e.offsetY());const o=new Rse;o.multiply(r.copy().invert()).multiply(l).multiply(r).multiply(a);const c=o.decompose();e.setAttrs(c),this._fire("transform",{evt:t,target:e}),e._fire("transform",{evt:t,target:e}),null===(n=e.getLayer())||void 0===n||n.batchDraw()})),this.rotation(jse._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,t){this.findOne(e).setAttrs(t)}update(){var e,t=this._getNodeRect();this.rotation(jse._getRotation(t.rotation));var n=t.width,r=t.height,a=this.enabledAnchors(),o=this.resizeEnabled(),c=this.padding(),i=this.anchorSize();this.find("._anchor").forEach((e=>{e.setAttrs({width:i,height:i,offsetX:i/2,offsetY:i/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})})),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:i/2+c,offsetY:i/2+c,visible:o&&a.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:n/2,y:0,offsetY:i/2+c,visible:o&&a.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:n,y:0,offsetX:i/2-c,offsetY:i/2+c,visible:o&&a.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:r/2,offsetX:i/2+c,visible:o&&a.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:n,y:r/2,offsetX:i/2-c,visible:o&&a.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:r,offsetX:i/2+c,offsetY:i/2-c,visible:o&&a.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:n/2,y:r,offsetY:i/2-c,visible:o&&a.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:n,y:r,offsetX:i/2-c,offsetY:i/2-c,visible:o&&a.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:n/2,y:-this.rotateAnchorOffset()*jse._sign(r)-c,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:n,height:r,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0}),null===(e=this.getLayer())||void 0===e||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Mde.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Vhe.prototype.toObject.call(this)}clone(e){return Vhe.prototype.clone.call(this,e)}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Vue.prototype.className="Transformer",Ase(Vue),Zse.addGetterSetter(Vue,"enabledAnchors",bue,(function(e){return e instanceof Array||jse.warn("enabledAnchors value should be an array"),e instanceof Array&&e.forEach((function(e){-1===bue.indexOf(e)&&jse.warn("Unknown anchor name: "+e+". Available names are: "+bue.join(", "))})),e||[]})),Zse.addGetterSetter(Vue,"flipEnabled",!0,Xse()),Zse.addGetterSetter(Vue,"resizeEnabled",!0),Zse.addGetterSetter(Vue,"anchorSize",10,$se()),Zse.addGetterSetter(Vue,"rotateEnabled",!0),Zse.addGetterSetter(Vue,"rotationSnaps",[]),Zse.addGetterSetter(Vue,"rotateAnchorOffset",50,$se()),Zse.addGetterSetter(Vue,"rotationSnapTolerance",5,$se()),Zse.addGetterSetter(Vue,"borderEnabled",!0),Zse.addGetterSetter(Vue,"anchorStroke","rgb(0, 161, 255)"),Zse.addGetterSetter(Vue,"anchorStrokeWidth",1,$se()),Zse.addGetterSetter(Vue,"anchorFill","white"),Zse.addGetterSetter(Vue,"anchorCornerRadius",0,$se()),Zse.addGetterSetter(Vue,"borderStroke","rgb(0, 161, 255)"),Zse.addGetterSetter(Vue,"borderStrokeWidth",1,$se()),Zse.addGetterSetter(Vue,"borderDash"),Zse.addGetterSetter(Vue,"keepRatio",!0),Zse.addGetterSetter(Vue,"centeredScaling",!1),Zse.addGetterSetter(Vue,"ignoreStroke",!1),Zse.addGetterSetter(Vue,"padding",0,$se()),Zse.addGetterSetter(Vue,"node"),Zse.addGetterSetter(Vue,"nodes"),Zse.addGetterSetter(Vue,"boundBoxFunc"),Zse.addGetterSetter(Vue,"anchorDragBoundFunc"),Zse.addGetterSetter(Vue,"shouldOverdrawWholeArea",!1),Zse.addGetterSetter(Vue,"useSingleNodeRotation",!0),Zse.backCompat(Vue,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});class Cue extends vde{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Ose.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return 2*this.radius()}getHeight(){return 2*this.radius()}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}function Lue(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}Cue.prototype.className="Wedge",Cue.prototype._centroid=!0,Cue.prototype._attrsAffectingSize=["radius"],Ase(Cue),Zse.addGetterSetter(Cue,"radius",0,$se()),Zse.addGetterSetter(Cue,"angle",0,$se()),Zse.addGetterSetter(Cue,"clockwise",!1),Zse.backCompat(Cue,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var wue=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],kue=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function xue(e,t,n,r,a){var o=n-t,c=a-r;return 0===o?r+c/2:0===c?r:c*((e-t)/o)+r}function Sue(e,t,n){var r=4*(n*e.width+t),a=[];return a.push(e.data[r++],e.data[r++],e.data[r++],e.data[r++]),a}function Tue(e,t){return Math.sqrt(Math.pow(e[0]-t[0],2)+Math.pow(e[1]-t[1],2)+Math.pow(e[2]-t[2],2))}function Oue(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}Zse.addGetterSetter(Vhe,"blurRadius",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"brightness",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"contrast",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossStrength",.5,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossWhiteLevel",.5,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossDirection","top-left",null,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"embossBlend",!1,null,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"enhance",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"hue",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"saturation",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"luminance",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"hue",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"saturation",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"value",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"kaleidoscopePower",2,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"kaleidoscopeAngle",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"threshold",0,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"noise",.2,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"pixelSize",8,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"levels",.5,$se(),Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"blue",0,Wse,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"red",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"green",0,(function(e){return this._filterUpToDate=!1,e>255?255:e<0?0:Math.round(e)})),Zse.addGetterSetter(Vhe,"blue",0,Wse,Zse.afterSetFilter),Zse.addGetterSetter(Vhe,"alpha",1,(function(e){return this._filterUpToDate=!1,e>1?1:e<0?0:e})),Zse.addGetterSetter(Vhe,"threshold",.5,$se(),Zse.afterSetFilter),xde.Util._assign(xde,{Arc:Sde,Arrow:Nde,Circle:_de,Ellipse:Dde,Image:Pde,Label:$de,Tag:qde,Line:Ade,Path:Rde,Rect:Gde,RegularPolygon:Yde,Ring:Xde,Sprite:Qde,Star:Jde,Text:due,TextPath:vue,Transformer:Vue,Wedge:Cue,Filters:{Blur:function(e){var t=Math.round(this.blurRadius());t>0&&function(e,t){var n,r,a,o,c,i,l,s,h,d,u,m,p,v,f,z,g,y,M,E,b,H,V,C,L=e.data,w=e.width,k=e.height,x=t+t+1,S=w-1,T=k-1,O=t+1,A=O*(O+1)/2,R=new Lue,N=null,_=R,D=null,P=null,F=wue[t],I=kue[t];for(a=1;a<x;a++)_=_.next=new Lue,a===O&&(N=_);for(_.next=R,l=i=0,r=0;r<k;r++){for(z=g=y=M=s=h=d=u=0,m=O*(E=L[i]),p=O*(b=L[i+1]),v=O*(H=L[i+2]),f=O*(V=L[i+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,a=0;a<O;a++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(a=1;a<O;a++)o=i+((S<a?S:a)<<2),s+=(_.r=E=L[o])*(C=O-a),h+=(_.g=b=L[o+1])*C,d+=(_.b=H=L[o+2])*C,u+=(_.a=V=L[o+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next;for(D=R,P=N,n=0;n<w;n++)L[i+3]=V=u*F>>I,0!==V?(V=255/V,L[i]=(s*F>>I)*V,L[i+1]=(h*F>>I)*V,L[i+2]=(d*F>>I)*V):L[i]=L[i+1]=L[i+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=l+((o=n+t+1)<S?o:S)<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,i+=4;l+=w}for(n=0;n<w;n++){for(g=y=M=z=h=d=u=s=0,m=O*(E=L[i=n<<2]),p=O*(b=L[i+1]),v=O*(H=L[i+2]),f=O*(V=L[i+3]),s+=A*E,h+=A*b,d+=A*H,u+=A*V,_=R,a=0;a<O;a++)_.r=E,_.g=b,_.b=H,_.a=V,_=_.next;for(c=w,a=1;a<=t;a++)i=c+n<<2,s+=(_.r=E=L[i])*(C=O-a),h+=(_.g=b=L[i+1])*C,d+=(_.b=H=L[i+2])*C,u+=(_.a=V=L[i+3])*C,z+=E,g+=b,y+=H,M+=V,_=_.next,a<T&&(c+=w);for(i=n,D=R,P=N,r=0;r<k;r++)L[3+(o=i<<2)]=V=u*F>>I,V>0?(V=255/V,L[o]=(s*F>>I)*V,L[o+1]=(h*F>>I)*V,L[o+2]=(d*F>>I)*V):L[o]=L[o+1]=L[o+2]=0,s-=m,h-=p,d-=v,u-=f,m-=D.r,p-=D.g,v-=D.b,f-=D.a,o=n+((o=r+O)<T?o:T)*w<<2,s+=z+=D.r=L[o],h+=g+=D.g=L[o+1],d+=y+=D.b=L[o+2],u+=M+=D.a=L[o+3],D=D.next,m+=E=P.r,p+=b=P.g,v+=H=P.b,f+=V=P.a,z-=E,g-=b,y-=H,M-=V,P=P.next,i+=w}}(e,t)},Brighten:function(e){var t,n=255*this.brightness(),r=e.data,a=r.length;for(t=0;t<a;t+=4)r[t]+=n,r[t+1]+=n,r[t+2]+=n},Contrast:function(e){var t,n=Math.pow((this.contrast()+100)/100,2),r=e.data,a=r.length,o=150,c=150,i=150;for(t=0;t<a;t+=4)o=r[t],c=r[t+1],i=r[t+2],o/=255,o-=.5,o*=n,o+=.5,c/=255,c-=.5,c*=n,c+=.5,i/=255,i-=.5,i*=n,i+=.5,o=(o*=255)<0?0:o>255?255:o,c=(c*=255)<0?0:c>255?255:c,i=(i*=255)<0?0:i>255?255:i,r[t]=o,r[t+1]=c,r[t+2]=i},Emboss:function(e){var t=10*this.embossStrength(),n=255*this.embossWhiteLevel(),r=this.embossDirection(),a=this.embossBlend(),o=0,c=0,i=e.data,l=e.width,s=e.height,h=4*l,d=s;switch(r){case"top-left":o=-1,c=-1;break;case"top":o=-1,c=0;break;case"top-right":o=-1,c=1;break;case"right":o=0,c=1;break;case"bottom-right":o=1,c=1;break;case"bottom":o=1,c=0;break;case"bottom-left":o=1,c=-1;break;case"left":o=0,c=-1;break;default:jse.error("Unknown emboss direction: "+r)}do{var u=(d-1)*h,m=o;d+m<1&&(m=0),d+m>s&&(m=0);var p=(d-1+m)*l*4,v=l;do{var f=u+4*(v-1),z=c;v+z<1&&(z=0),v+z>l&&(z=0);var g=p+4*(v-1+z),y=i[f]-i[g],M=i[f+1]-i[g+1],E=i[f+2]-i[g+2],b=y,H=b>0?b:-b;if((M>0?M:-M)>H&&(b=M),(E>0?E:-E)>H&&(b=E),b*=t,a){var V=i[f]+b,C=i[f+1]+b,L=i[f+2]+b;i[f]=V>255?255:V<0?0:V,i[f+1]=C>255?255:C<0?0:C,i[f+2]=L>255?255:L<0?0:L}else{var w=n-b;w<0?w=0:w>255&&(w=255),i[f]=i[f+1]=i[f+2]=w}}while(--v)}while(--d)},Enhance:function(e){var t,n,r,a,o=e.data,c=o.length,i=o[0],l=i,s=o[1],h=s,d=o[2],u=d,m=this.enhance();if(0!==m){for(a=0;a<c;a+=4)(t=o[a+0])<i?i=t:t>l&&(l=t),(n=o[a+1])<s?s=n:n>h&&(h=n),(r=o[a+2])<d?d=r:r>u&&(u=r);var p,v,f,z,g,y,M,E,b;for(l===i&&(l=255,i=0),h===s&&(h=255,s=0),u===d&&(u=255,d=0),m>0?(v=l+m*(255-l),f=i-m*(i-0),g=h+m*(255-h),y=s-m*(s-0),E=u+m*(255-u),b=d-m*(d-0)):(v=l+m*(l-(p=.5*(l+i))),f=i+m*(i-p),g=h+m*(h-(z=.5*(h+s))),y=s+m*(s-z),E=u+m*(u-(M=.5*(u+d))),b=d+m*(d-M)),a=0;a<c;a+=4)o[a+0]=xue(o[a+0],i,l,f,v),o[a+1]=xue(o[a+1],s,h,y,g),o[a+2]=xue(o[a+2],d,u,b,E)}},Grayscale:function(e){var t,n,r=e.data,a=r.length;for(t=0;t<a;t+=4)n=.34*r[t]+.5*r[t+1]+.16*r[t+2],r[t]=n,r[t+1]=n,r[t+2]=n},HSL:function(e){var t,n,r,a,o,c=e.data,i=c.length,l=Math.pow(2,this.saturation()),s=Math.abs(this.hue()+360)%360,h=127*this.luminance(),d=1*l*Math.cos(s*Math.PI/180),u=1*l*Math.sin(s*Math.PI/180),m=.299+.701*d+.167*u,p=.587-.587*d+.33*u,v=.114-.114*d-.497*u,f=.299-.299*d-.328*u,z=.587+.413*d+.035*u,g=.114-.114*d+.293*u,y=.299-.3*d+1.25*u,M=.587-.586*d-1.05*u,E=.114+.886*d-.2*u;for(t=0;t<i;t+=4)n=c[t+0],r=c[t+1],a=c[t+2],o=c[t+3],c[t+0]=m*n+p*r+v*a+h,c[t+1]=f*n+z*r+g*a+h,c[t+2]=y*n+M*r+E*a+h,c[t+3]=o},HSV:function(e){var t,n,r,a,o,c=e.data,i=c.length,l=Math.pow(2,this.value()),s=Math.pow(2,this.saturation()),h=Math.abs(this.hue()+360)%360,d=l*s*Math.cos(h*Math.PI/180),u=l*s*Math.sin(h*Math.PI/180),m=.299*l+.701*d+.167*u,p=.587*l-.587*d+.33*u,v=.114*l-.114*d-.497*u,f=.299*l-.299*d-.328*u,z=.587*l+.413*d+.035*u,g=.114*l-.114*d+.293*u,y=.299*l-.3*d+1.25*u,M=.587*l-.586*d-1.05*u,E=.114*l+.886*d-.2*u;for(t=0;t<i;t+=4)n=c[t+0],r=c[t+1],a=c[t+2],o=c[t+3],c[t+0]=m*n+p*r+v*a,c[t+1]=f*n+z*r+g*a,c[t+2]=y*n+M*r+E*a,c[t+3]=o},Invert:function(e){var t,n=e.data,r=n.length;for(t=0;t<r;t+=4)n[t]=255-n[t],n[t+1]=255-n[t+1],n[t+2]=255-n[t+2]},Kaleidoscope:function(e){var t,n,r,a,o,c,i,l,s,h=e.width,d=e.height,u=Math.round(this.kaleidoscopePower()),m=Math.round(this.kaleidoscopeAngle()),p=Math.floor(h*(m%360)/360);if(!(u<1)){var v=jse.createCanvasElement();v.width=h,v.height=d;var f=v.getContext("2d").getImageData(0,0,h,d);jse.releaseCanvas(v),function(e,t,n){var r,a,o,c,i=e.data,l=t.data,s=e.width,h=e.height,d=n.polarCenterX||s/2,u=n.polarCenterY||h/2,m=0,p=0,v=0,f=0,z=Math.sqrt(d*d+u*u);a=s-d,o=h-u,z=(c=Math.sqrt(a*a+o*o))>z?c:z;var g,y,M,E,b=h,H=s,V=360/H*Math.PI/180;for(y=0;y<H;y+=1)for(M=Math.sin(y*V),E=Math.cos(y*V),g=0;g<b;g+=1)a=Math.floor(d+z*g/b*E),m=i[0+(r=4*((o=Math.floor(u+z*g/b*M))*s+a))],p=i[r+1],v=i[r+2],f=i[r+3],l[0+(r=4*(y+g*s))]=m,l[r+1]=p,l[r+2]=v,l[r+3]=f}(e,f,{polarCenterX:h/2,polarCenterY:d/2});for(var z=h/Math.pow(2,u);z<=8;)z*=2,u-=1;var g=z=Math.ceil(z),y=0,M=g,E=1;for(p+z>h&&(y=g,M=0,E=-1),n=0;n<d;n+=1)for(t=y;t!==M;t+=E)l=4*(h*n+Math.round(t+p)%h),a=f.data[l+0],o=f.data[l+1],c=f.data[l+2],i=f.data[l+3],s=4*(h*n+t),f.data[s+0]=a,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=i;for(n=0;n<d;n+=1)for(g=Math.floor(z),r=0;r<u;r+=1){for(t=0;t<g+1;t+=1)l=4*(h*n+t),a=f.data[l+0],o=f.data[l+1],c=f.data[l+2],i=f.data[l+3],s=4*(h*n+2*g-t-1),f.data[s+0]=a,f.data[s+1]=o,f.data[s+2]=c,f.data[s+3]=i;g*=2}!function(e,t,n){var r,a,o,c,i,l,s=e.data,h=t.data,d=e.width,u=e.height,m=n.polarCenterX||d/2,p=n.polarCenterY||u/2,v=0,f=0,z=0,g=0,y=Math.sqrt(m*m+p*p);a=d-m,o=u-p,y=(l=Math.sqrt(a*a+o*o))>y?l:y;var M,E,b,H=u,V=d,C=n.polarRotation||0;for(a=0;a<d;a+=1)for(o=0;o<u;o+=1)c=a-m,i=o-p,M=Math.sqrt(c*c+i*i)*H/y,E=(E=(180*Math.atan2(i,c)/Math.PI+360+C)%360)*V/360,b=Math.floor(E),v=s[0+(r=4*(Math.floor(M)*d+b))],f=s[r+1],z=s[r+2],g=s[r+3],h[0+(r=4*(o*d+a))]=v,h[r+1]=f,h[r+2]=z,h[r+3]=g}(f,e,{polarRotation:0})}},Mask:function(e){var t=function(e,t){var n=Sue(e,0,0),r=Sue(e,e.width-1,0),a=Sue(e,0,e.height-1),o=Sue(e,e.width-1,e.height-1),c=t||10;if(Tue(n,r)<c&&Tue(r,o)<c&&Tue(o,a)<c&&Tue(a,n)<c){for(var i=function(e){for(var t=[0,0,0],n=0;n<e.length;n++)t[0]+=e[n][0],t[1]+=e[n][1],t[2]+=e[n][2];return t[0]/=e.length,t[1]/=e.length,t[2]/=e.length,t}([r,n,o,a]),l=[],s=0;s<e.width*e.height;s++){var h=Tue(i,[e.data[4*s],e.data[4*s+1],e.data[4*s+2]]);l[s]=h<c?0:255}return l}}(e,this.threshold());return t&&function(e,t){for(var n=0;n<e.width*e.height;n++)e.data[4*n+3]=t[n]}(e,t=function(e,t,n){for(var r=[1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9,1/9],a=Math.round(Math.sqrt(r.length)),o=Math.floor(a/2),c=[],i=0;i<n;i++)for(var l=0;l<t;l++){for(var s=i*t+l,h=0,d=0;d<a;d++)for(var u=0;u<a;u++){var m=i+d-o,p=l+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=r[d*a+u];h+=e[m*t+p]*v}}c[s]=h}return c}(t=function(e,t,n){for(var r=[1,1,1,1,1,1,1,1,1],a=Math.round(Math.sqrt(r.length)),o=Math.floor(a/2),c=[],i=0;i<n;i++)for(var l=0;l<t;l++){for(var s=i*t+l,h=0,d=0;d<a;d++)for(var u=0;u<a;u++){var m=i+d-o,p=l+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=r[d*a+u];h+=e[m*t+p]*v}}c[s]=h>=1020?255:0}return c}(t=function(e,t,n){for(var r=[1,1,1,1,0,1,1,1,1],a=Math.round(Math.sqrt(r.length)),o=Math.floor(a/2),c=[],i=0;i<n;i++)for(var l=0;l<t;l++){for(var s=i*t+l,h=0,d=0;d<a;d++)for(var u=0;u<a;u++){var m=i+d-o,p=l+u-o;if(m>=0&&m<n&&p>=0&&p<t){var v=r[d*a+u];h+=e[m*t+p]*v}}c[s]=2040===h?255:0}return c}(t,e.width,e.height),e.width,e.height),e.width,e.height)),e},Noise:function(e){var t,n=255*this.noise(),r=e.data,a=r.length,o=n/2;for(t=0;t<a;t+=4)r[t+0]+=o-2*o*Math.random(),r[t+1]+=o-2*o*Math.random(),r[t+2]+=o-2*o*Math.random()},Pixelate:function(e){var t,n,r,a,o,c,i,l,s,h,d,u,m,p,v=Math.ceil(this.pixelSize()),f=e.width,z=e.height,g=Math.ceil(f/v),y=Math.ceil(z/v),M=e.data;if(v<=0)jse.error("pixelSize value can not be <= 0");else for(u=0;u<g;u+=1)for(m=0;m<y;m+=1){for(a=0,o=0,c=0,i=0,s=(l=u*v)+v,d=(h=m*v)+v,p=0,t=l;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(a+=M[0+(r=4*(f*n+t))],o+=M[r+1],c+=M[r+2],i+=M[r+3],p+=1);for(a/=p,o/=p,c/=p,i/=p,t=l;t<s;t+=1)if(!(t>=f))for(n=h;n<d;n+=1)n>=z||(M[0+(r=4*(f*n+t))]=a,M[r+1]=o,M[r+2]=c,M[r+3]=i)}},Posterize:function(e){var t,n=Math.round(254*this.levels())+1,r=e.data,a=r.length,o=255/n;for(t=0;t<a;t+=1)r[t]=Math.floor(r[t]/o)*o},RGB:function(e){var t,n,r=e.data,a=r.length,o=this.red(),c=this.green(),i=this.blue();for(t=0;t<a;t+=4)n=(.34*r[t]+.5*r[t+1]+.16*r[t+2])/255,r[t]=n*o,r[t+1]=n*c,r[t+2]=n*i,r[t+3]=r[t+3]},RGBA:function(e){var t,n,r=e.data,a=r.length,o=this.red(),c=this.green(),i=this.blue(),l=this.alpha();for(t=0;t<a;t+=4)n=1-l,r[t]=o*l+r[t]*n,r[t+1]=c*l+r[t+1]*n,r[t+2]=i*l+r[t+2]*n},Sepia:function(e){var t,n,r,a,o=e.data,c=o.length;for(t=0;t<c;t+=4)n=o[t+0],r=o[t+1],a=o[t+2],o[t+0]=Math.min(255,.393*n+.769*r+.189*a),o[t+1]=Math.min(255,.349*n+.686*r+.168*a),o[t+2]=Math.min(255,.272*n+.534*r+.131*a)},Solarize:function(e){var t=e.data,n=e.width,r=4*n,a=e.height;do{var o=(a-1)*r,c=n;do{var i=o+4*(c-1),l=t[i],s=t[i+1],h=t[i+2];l>127&&(l=255-l),s>127&&(s=255-s),h>127&&(h=255-h),t[i]=l,t[i+1]=s,t[i+2]=h}while(--c)}while(--a)},Threshold:function(e){var t,n=255*this.threshold(),r=e.data,a=r.length;for(t=0;t<a;t+=1)r[t]=r[t]<n?0:255}}});var Aue,Rue,Nue={exports:{}},_ue={exports:{}};function Due(){if(Rue)return Aue;Rue=1;var e=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;return Aue=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},n=0;n<10;n++)t["_"+String.fromCharCode(n)]=n;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var r={};return"abcdefghijklmnopqrst".split("").forEach((function(e){r[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},r)).join("")}catch(e){return!1}}()?Object.assign:function(r,a){for(var o,c,i=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(r),l=1;l<arguments.length;l++){for(var s in o=Object(arguments[l]))t.call(o,s)&&(i[s]=o[s]);if(e){c=e(o);for(var h=0;h<c.length;h++)n.call(o,c[h])&&(i[c[h]]=o[c[h]])}}return i},Aue}var Pue,Fue,Iue,Bue,jue={exports:{}},Uue={},Wue={};function $ue(){return Iue||(Iue=1,"production"===ite.env.NODE_ENV?jue.exports=(Pue||(Pue=1,function(e){var t,n,r,a;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,i=c.now();e.unstable_now=function(){return c.now()-i}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var l=null,s=null,h=function(){if(null!==l)try{var t=e.unstable_now();l(!0,t),l=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==l?setTimeout(t,0,e):(l=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},r=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},a=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.cancelAnimationFrame;"function"!=typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof m&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var p=!1,v=null,f=-1,z=5,g=0;e.unstable_shouldYield=function(){return e.unstable_now()>=g},a=function(){},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<e?Math.floor(1e3/e):5};var y=new MessageChannel,M=y.port2;y.port1.onmessage=function(){if(null!==v){var t=e.unstable_now();g=t+z;try{v(!0,t)?M.postMessage(null):(p=!1,v=null)}catch(e){throw M.postMessage(null),e}}else p=!1},t=function(e){v=e,p||(p=!0,M.postMessage(null))},n=function(t,n){f=d((function(){t(e.unstable_now())}),n)},r=function(){u(f),f=-1}}function E(e,t){var n=e.length;e.push(t);e:for(;;){var r=n-1>>>1,a=e[r];if(!(void 0!==a&&0<V(a,t)))break e;e[r]=t,e[n]=a,n=r}}function b(e){return void 0===(e=e[0])?null:e}function H(e){var t=e[0];if(void 0!==t){var n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,a=e.length;r<a;){var o=2*(r+1)-1,c=e[o],i=o+1,l=e[i];if(void 0!==c&&0>V(c,n))void 0!==l&&0>V(l,c)?(e[r]=l,e[i]=n,r=i):(e[r]=c,e[o]=n,r=o);else{if(!(void 0!==l&&0>V(l,n)))break e;e[r]=l,e[i]=n,r=i}}}return t}return null}function V(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var C=[],L=[],w=1,k=null,x=3,S=!1,T=!1,O=!1;function A(e){for(var t=b(L);null!==t;){if(null===t.callback)H(L);else{if(!(t.startTime<=e))break;H(L),t.sortIndex=t.expirationTime,E(C,t)}t=b(L)}}function R(e){if(O=!1,A(e),!T)if(null!==b(C))T=!0,t(N);else{var r=b(L);null!==r&&n(R,r.startTime-e)}}function N(t,a){T=!1,O&&(O=!1,r()),S=!0;var o=x;try{for(A(a),k=b(C);null!==k&&(!(k.expirationTime>a)||t&&!e.unstable_shouldYield());){var c=k.callback;if("function"==typeof c){k.callback=null,x=k.priorityLevel;var i=c(k.expirationTime<=a);a=e.unstable_now(),"function"==typeof i?k.callback=i:k===b(C)&&H(C),A(a)}else H(C);k=b(C)}if(null!==k)var l=!0;else{var s=b(L);null!==s&&n(R,s.startTime-a),l=!1}return l}finally{k=null,x=o,S=!1}}var _=a;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){T||S||(T=!0,t(N))},e.unstable_getCurrentPriorityLevel=function(){return x},e.unstable_getFirstCallbackNode=function(){return b(C)},e.unstable_next=function(e){switch(x){case 1:case 2:case 3:var t=3;break;default:t=x}var n=x;x=t;try{return e()}finally{x=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=_,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=x;x=e;try{return t()}finally{x=n}},e.unstable_scheduleCallback=function(a,o,c){var i=e.unstable_now();switch(c="object"==typeof c&&null!==c&&"number"==typeof(c=c.delay)&&0<c?i+c:i,a){case 1:var l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}return a={id:w++,callback:o,priorityLevel:a,startTime:c,expirationTime:l=c+l,sortIndex:-1},c>i?(a.sortIndex=c,E(L,a),null===b(C)&&a===b(L)&&(O?r():O=!0,n(R,c-i))):(a.sortIndex=l,E(C,a),T||S||(T=!0,t(N))),a},e.unstable_wrapCallback=function(e){var t=x;return function(){var n=x;x=t;try{return e.apply(this,arguments)}finally{x=n}}}}(Uue)),Uue):jue.exports=function(){return Fue||(Fue=1,e=Wue,"production"!==ite.env.NODE_ENV&&function(){var t,n,r,a;if("object"==typeof performance&&"function"==typeof performance.now){var o=performance;e.unstable_now=function(){return o.now()}}else{var c=Date,i=c.now();e.unstable_now=function(){return c.now()-i}}if("undefined"==typeof window||"function"!=typeof MessageChannel){var l=null,s=null,h=function(){if(null!==l)try{var t=e.unstable_now();l(!0,t),l=null}catch(e){throw setTimeout(h,0),e}};t=function(e){null!==l?setTimeout(t,0,e):(l=e,setTimeout(h,0))},n=function(e,t){s=setTimeout(e,t)},r=function(){clearTimeout(s)},e.unstable_shouldYield=function(){return!1},a=e.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,u=window.clearTimeout;if("undefined"!=typeof console){var m=window.requestAnimationFrame,p=window.cancelAnimationFrame;"function"!=typeof m&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!=typeof p&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var v=!1,f=null,z=-1,g=5,y=0;e.unstable_shouldYield=function(){return e.unstable_now()>=y},a=function(){},e.unstable_forceFrameRate=function(e){e<0||e>125?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):g=e>0?Math.floor(1e3/e):5};var M=new MessageChannel,E=M.port2;M.port1.onmessage=function(){if(null!==f){var t=e.unstable_now();y=t+g;try{f(!0,t)?E.postMessage(null):(v=!1,f=null)}catch(e){throw E.postMessage(null),e}}else v=!1},t=function(e){f=e,v||(v=!0,E.postMessage(null))},n=function(t,n){z=d((function(){t(e.unstable_now())}),n)},r=function(){u(z),z=-1}}function b(e,t){var n=e.length;e.push(t),function(e,t,n){for(var r=n;;){var a=r-1>>>1,o=e[a];if(!(void 0!==o&&C(o,t)>0))return;e[a]=t,e[r]=o,r=a}}(e,t,n)}function H(e){var t=e[0];return void 0===t?null:t}function V(e){var t=e[0];if(void 0!==t){var n=e.pop();return n!==t&&(e[0]=n,function(e,t){for(var n=0,r=e.length;n<r;){var a=2*(n+1)-1,o=e[a],c=a+1,i=e[c];if(void 0!==o&&C(o,t)<0)void 0!==i&&C(i,o)<0?(e[n]=i,e[c]=t,n=c):(e[n]=o,e[a]=t,n=a);else{if(!(void 0!==i&&C(i,t)<0))return;e[n]=i,e[c]=t,n=c}}}(e,n)),t}return null}function C(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}var L=[],w=[],k=1,x=null,S=3,T=!1,O=!1,A=!1;function R(e){for(var t=H(w);null!==t;){if(null===t.callback)V(w);else{if(!(t.startTime<=e))return;V(w),t.sortIndex=t.expirationTime,b(L,t)}t=H(w)}}function N(e){if(A=!1,R(e),!O)if(null!==H(L))O=!0,t(_);else{var r=H(w);null!==r&&n(N,r.startTime-e)}}function _(t,a){O=!1,A&&(A=!1,r()),T=!0;var o=S;try{return function(t,r){var a=r;for(R(a),x=H(L);null!==x&&(!(x.expirationTime>a)||t&&!e.unstable_shouldYield());){var o=x.callback;if("function"==typeof o){x.callback=null,S=x.priorityLevel;var c=o(x.expirationTime<=a);a=e.unstable_now(),"function"==typeof c?x.callback=c:x===H(L)&&V(L),R(a)}else V(L);x=H(L)}if(null!==x)return!0;var i=H(w);return null!==i&&n(N,i.startTime-a),!1}(t,a)}finally{x=null,S=o,T=!1}}var D=a;e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_continueExecution=function(){O||T||(O=!0,t(_))},e.unstable_getCurrentPriorityLevel=function(){return S},e.unstable_getFirstCallbackNode=function(){return H(L)},e.unstable_next=function(e){var t;switch(S){case 1:case 2:case 3:t=3;break;default:t=S}var n=S;S=t;try{return e()}finally{S=n}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=D,e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=S;S=e;try{return t()}finally{S=n}},e.unstable_scheduleCallback=function(a,o,c){var i,l,s=e.unstable_now();if("object"==typeof c&&null!==c){var h=c.delay;i="number"==typeof h&&h>0?s+h:s}else i=s;switch(a){case 1:l=-1;break;case 2:l=250;break;case 5:l=1073741823;break;case 4:l=1e4;break;default:l=5e3}var d=i+l,u={id:k++,callback:o,priorityLevel:a,startTime:i,expirationTime:d,sortIndex:-1};return i>s?(u.sortIndex=i,b(w,u),null===H(L)&&u===H(w)&&(A?r():A=!0,n(N,i-s))):(u.sortIndex=d,b(L,u),O||T||(O=!0,t(_))),u},e.unstable_wrapCallback=function(e){var t=S;return function(){var n=S;S=t;try{return e.apply(this,arguments)}finally{S=n}}}}()),Wue;var e}()),jue.exports}
344
344
  /** @license React v0.26.2
345
345
  * react-reconciler.production.min.js
346
346
  *