/*! For license information please see 1602.6561aab0.js.LICENSE.txt */ "use strict";(self.webpackChunk_coze_studio_app=self.webpackChunk_coze_studio_app||[]).push([["1602"],{789034:function(e,t,n){n.d(t,{k:function(){return i}});function i(e,t){for(var n,i=arguments.length,r=Array(i>2?i-2:0),o=2;onQ});var i,r,o,s,a={};n.r(a),n.d(a,{access:()=>D,bound:()=>b,dfs:()=>A,focusNextElement:()=>k,focusPrevElement:()=>T,getInsertIndex:()=>L,getInsertParentId:()=>j,identify:()=>I,identifyNull:()=>O,indexOf:()=>S,isClosed:()=>x,isDescendant:()=>_,isItem:()=>y,isOpenWithEmptyChildren:()=>w,mergeRefs:()=>N,noop:()=>C,safeRun:()=>P,waitFor:()=>R,walk:()=>E});var l={};n.r(l),n.d(l,{FILE:()=>tT,HTML:()=>tO,TEXT:()=>tD,URL:()=>tM});var d=n("151064"),c=n("455069"),h=n("532973");let u=(0,c.createContext)(null);function p(){let e=(0,c.useContext)(u);if(null===e)throw Error("No Tree Api Provided");return e}let f=(0,c.createContext)(null),m=(0,c.createContext)(null),g=(0,c.createContext)(0);function v(){(0,c.useContext)(g)}function b(e,t,n){return Math.max(Math.min(e,n),t)}function y(e){return e&&e.isLeaf}function x(e){return e&&e.isInternal&&!e.isOpen}function w(e){var t;return e&&e.isOpen&&!(null===(t=e.children)||void 0===t?void 0:t.length)}let _=(e,t)=>{let n=e;for(;n;){if(n.id===t.id)return!0;n=n.parent}return!1},S=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function C(){}function A(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let n of e.children){let e=A(n,t);if(e)return e}return null}function E(e,t){if(t(e),e.children)for(let n of e.children)E(n,t)}function k(e){let t;let n=M(e);for(let i=0;i=0?e[t-1]:e[e.length-1]}(n,i);break}null==t||t.focus()}function M(e){return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter(t=>t===e||!e.contains(t))}function D(e,t){return"boolean"==typeof t?t:"string"==typeof t?e[t]:t(e)}function O(e){return null===e?null:I(e)}function I(e){return"string"==typeof e?e:e.id}function N(...e){return t=>{e.forEach(e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)})}}function P(e,...t){if(e)return e(...t)}function R(e){return new Promise((t,n)=>{let i=0;!function r(){100===(i+=1)&&n(),e()?t():setTimeout(r,10)}()})}function L(e){var t,n;let i=e.focusedNode;return i?i.isOpen?0:i.parent?i.childIndex+1:0:null!==(n=null===(t=e.root.children)||void 0===t?void 0:t.length)&&void 0!==n?n:0}function j(e){let t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}let F={display:"flex",alignItems:"center",zIndex:1},B={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},z={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},H=c.memo(function({top:e,left:t,indent:n}){return(0,d.jsxs)("div",{style:Object.assign(Object.assign({},F),{position:"absolute",pointerEvents:"none",top:e-2+"px",left:t+"px",right:n+"px"}),children:[(0,d.jsx)("div",{style:Object.assign({},z)}),(0,d.jsx)("div",{style:Object.assign({},B)})]})});function V({node:e,attrs:t,innerRef:n,children:i}){return(0,d.jsx)("div",Object.assign({},t,{ref:n,onFocus:e=>e.stopPropagation(),onClick:e.handleClick,children:i}))}function U(e){return(0,d.jsxs)("div",{ref:e.dragHandle,style:e.style,children:[(0,d.jsx)("span",{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?"\uD83C\uDF33":e.node.isOpen?"\uD83D\uDDC1":"\uD83D\uDDC0"})," ",e.node.isEditing?(0,d.jsx)(W,Object.assign({},e)):(0,d.jsx)($,Object.assign({},e))]})}function $(e){return(0,d.jsx)(d.Fragment,{children:(0,d.jsx)("span",{children:e.node.data.name})})}function W({node:e}){let t=(0,c.useRef)();return(0,c.useEffect)(()=>{var e,n;null===(e=t.current)||void 0===e||e.focus(),null===(n=t.current)||void 0===n||n.select()},[]),(0,d.jsx)("input",{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:n=>{var i;"Escape"===n.key&&e.reset(),"Enter"===n.key&&e.submit((null===(i=t.current)||void 0===i?void 0:i.value)||"")}})}function q(e){return{type:"EDIT",id:e}}function G(e){return{type:"FOCUS",id:e}}class K{constructor(e){this.handleClick=e=>{e.metaKey&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():e.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=e.tree,this.id=e.id,this.data=e.data,this.level=e.level,this.children=e.children,this.parent=e.parent,this.isDraggable=e.isDraggable,this.rowIndex=e.rowIndex}get isRoot(){return this.id===Z}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return!this.isLeaf&&this.tree.isOpen(this.id)}get isClosed(){return!this.isLeaf&&!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){var e;return this.isSelected&&!(null===(e=this.prev)||void 0===e?void 0:e.isSelected)}get isSelectedEnd(){var e;return this.isSelected&&!(null===(e=this.next)||void 0===e?void 0:e.isSelected)}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(e=>e.id===this.id):-1}get next(){return null===this.rowIndex?null:this.tree.at(this.rowIndex+1)}get prev(){return null===this.rowIndex?null:this.tree.at(this.rowIndex-1)}get nextSibling(){var e,t;let n=this.childIndex;return null!==(t=null===(e=this.parent)||void 0===e?void 0:e.children[n+1])&&void 0!==t?t:null}isAncestorOf(e){if(!e)return!1;let t=e;for(;t;){if(t.id===this.id)return!0;t=t.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(e){this.tree.submit(this,e)}reset(){this.tree.reset()}clone(){return new K(Object.assign({},this))}edit(){return this.tree.edit(this)}}let Z="__REACT_ARBORIST_INTERNAL_ROOT__";function Y(e){var t;let n=new K({tree:e,id:Z,data:{id:Z},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null}),i=null!==(t=e.props.data)&&void 0!==t?t:[];return n.children=i.map(t=>(function t(n,i,r){let o=e.accessId(n),s=new K({tree:e,data:n,level:i,parent:r,id:o,children:null,isDraggable:e.isDraggable(n),rowIndex:null}),a=e.accessChildren(n);return a&&(s.children=a.map(e=>t(e,i+1,s))),s})(t,0,n)),n}let X={open:(e,t)=>({type:"VISIBILITY_OPEN",id:e,filtered:t}),close:(e,t)=>({type:"VISIBILITY_CLOSE",id:e,filtered:t}),clear:e=>({type:"VISIBILITY_CLEAR",filtered:e})};function J(e={},t){if("VISIBILITY_OPEN"===t.type)return Object.assign(Object.assign({},e),{[t.id]:!0});if("VISIBILITY_CLOSE"===t.type)return Object.assign(Object.assign({},e),{[t.id]:!1});if("VISIBILITY_TOGGLE"===t.type){let n=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!n})}else if("VISIBILITY_CLEAR"===t.type)return{};else return e}let Q=e=>{var t;return{nodes:{open:{filtered:{},unfiltered:null!==(t=null==e?void 0:e.initialOpenState)&&void 0!==t?t:{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:"none"},dragId:null,dragIds:[],parentId:null,index:-1}}},ee={only:e=>({type:"SELECTION_ONLY",id:I(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(I)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(I)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:null===e?null:I(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:null===e?null:I(e)})},et={cursor:e=>({type:"DND_CURSOR",cursor:e}),dragStart:(e,t)=>({type:"DND_DRAG_START",id:e,dragIds:t}),dragEnd:()=>({type:"DND_DRAG_END"}),hovering:(e,t)=>({type:"DND_HOVERING",parentId:e,index:t})},en={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},ei=e=>{if(!e)return{display:"none"};let{x:t,y:n}=e;return{transform:`translate(${t}px, ${n}px)`}},er=e=>{if(!e)return{display:"none"};let{x:t,y:n}=e;return{transform:`translate(${t+10}px, ${n+10}px)`}};function eo({offset:e,mouse:t,id:n,dragIds:i,isDragging:r}){return(0,d.jsxs)(es,{isDragging:r,children:[(0,d.jsx)(ea,{offset:e,children:(0,d.jsx)(ed,{id:n,dragIds:i})}),(0,d.jsx)(el,{mouse:t,count:i.length})]})}let es=(0,c.memo)(function(e){return e.isDragging?(0,d.jsx)("div",{style:en,children:e.children}):null});function ea(e){return(0,d.jsx)("div",{className:"row preview",style:ei(e.offset),children:e.children})}function el(e){let{count:t,mouse:n}=e;return t>1?(0,d.jsx)("div",{className:"selected-count",style:er(n),children:t}):null}let ed=(0,c.memo)(function(e){let t=p(),n=t.get(e.id);return n?(0,d.jsx)(t.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*t.indent,opacity:.2,background:"transparent"},tree:t}):null});var ec=n("517432");function eh(){var e,t;let n=p(),i=function(){let e=(0,c.useContext)(m);if(null===e)throw Error("Provide a DnDContext");return e}().cursor;if(!i||"line"!==i.type)return null;let r=n.indent,o=n.rowHeight*i.index+(null!==(t=null!==(e=n.props.padding)&&void 0!==e?e:n.props.paddingTop)&&void 0!==t?t:0),s=r*i.level,a=n.renderCursor;return(0,d.jsx)(a,{top:o,left:s,indent:r})}var eu=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);rt.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};let ep=(0,c.forwardRef)(function(e,t){let{children:n}=e,i=eu(e,["children"]),r=p();return(0,d.jsxs)("div",Object.assign({ref:t},i,{onClick:e=>{e.currentTarget===e.target&&r.deselectAll()},children:[(0,d.jsx)(ef,{}),n]}))}),ef=()=>{let e=p();return(0,d.jsx)("div",{style:{height:e.visibleNodes.length*e.rowHeight,width:"100%",position:"absolute",left:"0",right:"0"},children:(0,d.jsx)(eh,{})})};var em=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);rt.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};let eg=(0,c.forwardRef)(function(e,t){var n,i,r,o,{style:s}=e,a=em(e,["style"]);let l=p(),c=null!==(i=null!==(n=l.props.padding)&&void 0!==n?n:l.props.paddingTop)&&void 0!==i?i:0,h=null!==(o=null!==(r=l.props.padding)&&void 0!==r?r:l.props.paddingBottom)&&void 0!==o?o:0;return(0,d.jsx)("div",Object.assign({ref:t,style:Object.assign(Object.assign({},s),{height:`${parseFloat(s.height)+c+h}px`})},a))});var ev="undefined"!=typeof window?c.useLayoutEffect:c.useEffect;function eb(e){return(eb="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)}function ey(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=Array(t);ne.length)&&(t=e.length);for(var n=0,i=Array(t);n0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,c.isValidElement)(e)?(!function(e){if("string"!=typeof e.type){var t=e.type.displayName||e.type.name||"the component";throw Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a
, or turn it into a ")+"drag source or a drop target itself.")}}(e),function(e,t){var n=e.ref;return((0,e_.k)("string"!=typeof n,"Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a or
. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),n)?(0,c.cloneElement)(e,{ref:function(e){eP(n,e),eP(t,e)}}):(0,c.cloneElement)(e,{ref:t})}(e,t?function(e){return r(e,t)}:r)):(r(e,t),e)});t[n]=function(){return o}}}),t}function eP(e,t){"function"==typeof e?e(t):e.current=t}function eR(e){return(eR="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)}function eL(e){return null!==e&&"object"===eR(e)&&Object.prototype.hasOwnProperty.call(e,"current")}var ej=n("712003");function eF(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=Array(t);ne.length)&&(t=e.length);for(var n=0,i=Array(t);ne.length)&&(t=e.length);for(var n=0,i=Array(t);nt;)i=i.parent;let r=(null===(n=i.parent)||void 0===n?void 0:n.id)||null;return{parentId:r,index:S(i)+1}}function e7(e){var t;let n=function(e,t){let n=e.getBoundingClientRect(),i=t.x-Math.round(n.x),r=t.y-Math.round(n.y),o=n.height,s=rl&&rl.level?{drop:e4(l.id,0),cursor:e6(l.rowIndex+1,e)}:{drop:e8(l,e),cursor:e6(l.rowIndex+1,e)}}return{drop:e4(null==l?void 0:l.id,0),cursor:e6(l.rowIndex+1,l.level+1)}}let e9=c.memo(function({index:e,style:t}){v(),!function(){let e=(0,c.useContext)(f);if(null===e)throw Error("Provide a NodesContext");}();let n=p(),i=function(e){let t=p(),n=t.at(e);if(!n)throw Error(`Could not find node for index: ${e}`);return(0,c.useMemo)(()=>{let i=n.clone();return t.visibleNodes[e]=i,i},[...Object.values(n.state),n])}(e),o=(0,c.useRef)(null),s=function(e){var t,n,i,o,s,a,l,d,h,u,f,m,g,v,b,y,x,w,_,S,C;let A=p(),E=A.selectedIds;let[k,T,M]=(t=ek(()=>({canDrag:()=>e.isDraggable,type:"NODE",item:()=>{let t=A.isSelected(e.id)?Array.from(E):[e.id];return A.dispatch(et.dragStart(e.id,t)),{id:e.id,dragIds:t}},end:()=>{A.hideCursor(),A.dispatch(et.dragEnd())}}),[E,e]),(0,e_.k)(!t.begin,"useDrag::spec.begin was deprecated in v14. Replace spec.begin() with spec.item(). (see more here - https://react-dnd.github.io/react-dnd/docs/api/use-drag)"),i=(n=eC(),(0,c.useMemo)(function(){return new eI(n)},[n])),d=(o=t.options,s=t.previewOptions,a=eC(),ev(function(){return l.dragSourceOptions=o||null,l.reconnect(),function(){return l.disconnectDragSource()}},[l=(0,c.useMemo)(function(){return new ez(a.getBackend())},[a]),o]),ev(function(){return l.dragPreviewOptions=s||null,l.reconnect(),function(){return l.disconnectDragPreview()}},[l,s]),l),h=t,u=i,f=d,m=eC(),x=(g=h,v=u,b=f,y=(0,c.useMemo)(function(){return new ew(g,v,b)},[v,b]),(0,c.useEffect)(function(){y.spec=g},[g]),y),ev(function(){if(null!=_){var e,t,n,i,r,o,s=(o=2,function(e){if(Array.isArray(e))return e}(r=(e=_,t=x,[i=(n=m.getRegistry()).addSource(e,t),function(){return n.removeSource(i)}]))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{!s&&null!=r.return&&r.return()}finally{if(a)throw i}}return o}}(r,2)||function(e,t){if(e){if("string"==typeof e)return eA(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eA(e,t)}}(r,o)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=s[0],l=s[1];return u.receiveHandlerId(a),f.receiveHandlerId(a),l}},[m,u,f,x,_=(w=h,(0,c.useMemo)(function(){var e=w.type;return(0,e_.k)(null!=e,"spec.type must be defined"),e},[w]))]),[eq(t.collect,i,d),(S=d,(0,c.useMemo)(function(){return S.hooks.dragSource()},[S])),(C=d,(0,c.useMemo)(function(){return C.hooks.dragPreview()},[C]))]);return(0,c.useEffect)(()=>{M((!r&&((r=new Image).src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),r))},[M]),T}(i),a=function(e,t){let n=p(),[i,r]=e3(()=>({accept:"NODE",canDrop:()=>n.canDrop(),hover:(i,r)=>{let o=r.getClientOffset();if(!e.current||!o)return;let{cursor:s,drop:a}=e7({element:e.current,offset:o,indent:n.indent,node:t,prevNode:t.prev,nextNode:t.next});a&&n.dispatch(et.hovering(a.parentId,a.index)),r.canDrop()?s&&n.showCursor(s):n.hideCursor()},drop:(e,t)=>{if(!t.canDrop())return null;let{parentId:i,index:r,dragIds:o}=n.state.dnd;P(n.props.onMove,{dragIds:o,parentId:i===Z?null:i,index:null===r?0:r,dragNodes:n.dragNodes,parentNode:n.get(i)}),n.open(i)}}),[t,e.current,n.props]);return r}(o,i),l=(0,c.useCallback)(e=>{o.current=e,a(e)},[a]),h=n.indent*i.level,u=(0,c.useMemo)(()=>({paddingLeft:h}),[h]),m=(0,c.useMemo)(()=>{var e,i;return Object.assign(Object.assign({},t),{top:parseFloat(t.top)+(null!==(i=null!==(e=n.props.padding)&&void 0!==e?e:n.props.paddingTop)&&void 0!==i?i:0)})},[t,n.props.padding,n.props.paddingTop]),g={role:"treeitem","aria-level":i.level+1,"aria-selected":i.isSelected,"aria-expanded":i.isOpen,style:m,tabIndex:-1,className:n.props.rowClassName};(0,c.useEffect)(()=>{var e;!i.isEditing&&i.isFocused&&(null===(e=o.current)||void 0===e||e.focus({preventScroll:!0}))},[i.isEditing,i.isFocused,o.current]);let b=n.renderNode,y=n.renderRow;return(0,d.jsx)(y,{node:i,innerRef:l,attrs:g,children:(0,d.jsx)(b,{node:i,tree:n,style:u,dragHandle:s})})}),te="",tt=null;function tn(){v();let e=p();return(0,d.jsx)("div",{role:"tree",style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{!t.currentTarget.contains(t.relatedTarget)&&e.onFocus()},onBlur:t=>{!t.currentTarget.contains(t.relatedTarget)&&e.onBlur()},onKeyDown:t=>{var n;if(e.isEditing)return;if("Backspace"===t.key){if(!e.props.onDelete)return;let t=Array.from(e.selectedIds);if(t.length>1){let n=e.mostRecentNode;for(;n&&n.isSelected;)n=n.nextSibling;!n&&(n=e.lastNode),e.focus(n,{scroll:!1}),e.delete(Array.from(t))}else{let t=e.focusedNode;if(t){let n=t.nextSibling,i=t.parent;e.focus(n||i,{scroll:!1}),e.delete(t)}}return}if("Tab"===t.key&&!t.shiftKey){t.preventDefault(),k(t.currentTarget);return}if("Tab"===t.key&&t.shiftKey){t.preventDefault(),T(t.currentTarget);return}if("ArrowDown"===t.key){t.preventDefault();let n=e.nextNode;if(t.metaKey){e.select(e.focusedNode),e.activate(e.focusedNode);return}if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}else{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.firstNode);return}}if("ArrowUp"===t.key){t.preventDefault();let n=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection){e.focus(n);return}{if(!n)return;let t=e.focusedNode;t?t.isSelected?e.selectContiguous(n):e.selectMulti(n):e.focus(e.lastNode);return}}if("ArrowRight"===t.key){let t=e.focusedNode;if(!t)return;t.isInternal&&t.isOpen?e.focus(e.nextNode):t.isInternal&&e.open(t.id);return}if("ArrowLeft"===t.key){let t=e.focusedNode;if(!t||t.isRoot)return;t.isInternal&&t.isOpen?e.close(t.id):!(null===(n=t.parent)||void 0===n?void 0:n.isRoot)&&e.focus(t.parent);return}if("a"===t.key&&t.metaKey&&!e.props.disableMultiSelection){t.preventDefault(),e.selectAll();return}if("a"===t.key&&!t.metaKey&&e.props.onCreate){e.createLeaf();return}if("A"===t.key&&!t.metaKey){if(!e.props.onCreate)return;e.createInternal();return}if("Home"===t.key){t.preventDefault(),e.focus(e.firstNode);return}if("End"===t.key){t.preventDefault(),e.focus(e.lastNode);return}if("Enter"===t.key){let t=e.focusedNode;if(!t||!t.isEditable||!e.props.onRename)return;setTimeout(()=>{t&&e.edit(t)});return}if(" "===t.key){t.preventDefault();let n=e.focusedNode;if(!n)return;n.isLeaf?(n.select(),n.activate()):n.toggle();return}if("*"===t.key){let t=e.focusedNode;if(!t)return;e.openSiblings(t);return}if("PageUp"===t.key){t.preventDefault(),e.pageUp();return}"PageDown"===t.key&&(t.preventDefault(),e.pageDown()),clearTimeout(tt),te+=t.key,tt=setTimeout(()=>{te=""},600);let i=e.visibleNodes.find(e=>{let t=e.data.name;return"string"==typeof t&&t.toLowerCase().startsWith(te)});i&&e.focus(i.id)},children:(0,d.jsx)(ec.t7,{className:e.props.className,outerRef:e.listEl,itemCount:e.visibleNodes.length,height:e.height,width:e.width,itemSize:e.rowHeight,overscanCount:e.overscanCount,itemKey:t=>{var n;return(null===(n=e.visibleNodes[t])||void 0===n?void 0:n.id)||t},outerElementType:ep,innerElementType:eg,onScroll:e.props.onScroll,onItemsRendered:e.onItemsRendered.bind(e),ref:e.list,children:e9})})}function ti(e){return e.isFiltered?function(e,t){let n={},i=[];return!function e(i){if(!i.isRoot&&t(i)){n[i.id]=!0;let e=i.parent;for(;e;)n[e.id]=!0,e=e.parent}if(i.children)for(let t of i.children)e(t)}(e),!function e(t){var r;t.level>=0&&n[t.id]&&i.push(t),t.isOpen&&(null===(r=t.children)||void 0===r||r.forEach(e))}(e),i.forEach(tr),i}(e.root,e.isMatch.bind(e)):function(e){let t=[];return!function e(n){var i;n.level>=0&&t.push(n),n.isOpen&&(null===(i=n.children)||void 0===i||i.forEach(e))}(e),t.forEach(tr),t}(e.root)}function tr(e,t){e.rowIndex=t}let to=e=>e.reduce((e,t,n)=>(e[t.id]=n,e),{});var ts=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})};let{safeRun:ta,identify:tl,identifyNull:td}=a;class tc{constructor(e,t,n,i){this.store=e,this.props=t,this.list=n,this.listEl=i,this.visibleStartIndex=0,this.visibleStopIndex=0,this.root=Y(this),this.visibleNodes=ti(this),this.idToIndex=to(this.visibleNodes)}update(e){this.props=e,this.root=Y(this),this.visibleNodes=ti(this),this.idToIndex=to(this.visibleNodes)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){var e;return null!==(e=this.props.width)&&void 0!==e?e:300}get height(){var e;return null!==(e=this.props.height)&&void 0!==e?e:500}get indent(){var e;return null!==(e=this.props.indent)&&void 0!==e?e:24}get rowHeight(){var e;return null!==(e=this.props.rowHeight)&&void 0!==e?e:24}get overscanCount(){var e;return null!==(e=this.props.overscanCount)&&void 0!==e?e:1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){var e;let t=null!==(e=this.props.searchMatch)&&void 0!==e?e:(e,t)=>JSON.stringify(Object.values(e.data)).toLocaleLowerCase().includes(t.toLocaleLowerCase());return e=>t(e,this.searchTerm)}accessChildren(e){var t;return null!==(t=D(e,this.props.childrenAccessor||"children"))&&void 0!==t?t:null}accessId(e){let t=D(e,this.props.idAccessor||"id");if(!t)throw Error("Data must contain an 'id' property or props.idAccessor must return a string");return t}get firstNode(){var e;return null!==(e=this.visibleNodes[0])&&void 0!==e?e:null}get lastNode(){var e;return null!==(e=this.visibleNodes[this.visibleNodes.length-1])&&void 0!==e?e:null}get focusedNode(){var e;return null!==(e=this.get(this.state.nodes.focus.id))&&void 0!==e?e:null}get mostRecentNode(){var e;return null!==(e=this.get(this.state.nodes.selection.mostRecent))&&void 0!==e?e:null}get nextNode(){let e=this.indexOf(this.focusedNode);return null===e?null:this.at(e+1)}get prevNode(){let e=this.indexOf(this.focusedNode);return null===e?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,t){var n;if(null===e||null===t)return[];let i=null!==(n=this.indexOf(e))&&void 0!==n?n:0,r=this.indexOf(t);if(null===r)return[];let o=Math.min(i,r),s=Math.max(i,r);return this.visibleNodes.slice(o,s+1)}indexOf(e){let t=O(e);return t?this.idToIndex[t]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(){return ts(this,arguments,void 0,function*(e={}){var t,n;let i=void 0===e.parentId?j(this):e.parentId,r=null!==(t=e.index)&&void 0!==t?t:L(this),o=null!==(n=e.type)&&void 0!==n?n:"leaf",s=yield ta(this.props.onCreate,{type:o,parentId:i,index:r,parentNode:this.get(i)});s&&(this.focus(s),setTimeout(()=>{this.edit(s).then(()=>{this.select(s),this.activate(s)})}))})}delete(e){return ts(this,void 0,void 0,function*(){if(!e)return;let t=(Array.isArray(e)?e:[e]).map(tl),n=t.map(e=>this.get(e)).filter(e=>!!e);yield ta(this.props.onDelete,{nodes:n,ids:t})})}edit(e){let t=tl(e);return this.resolveEdit({cancelled:!0}),this.scrollTo(t),this.dispatch(q(t)),new Promise(e=>{tc.editPromise=e})}submit(e,t){return ts(this,void 0,void 0,function*(){if(!e)return;let n=tl(e);yield ta(this.props.onRename,{id:n,name:t,node:this.get(n)}),this.dispatch(q(null)),this.resolveEdit({cancelled:!1,value:t}),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(q(null)),this.resolveEdit({cancelled:!0}),setTimeout(()=>this.onFocus())}activate(e){let t=this.get(td(e));t&&ta(this.props.onActivate,t)}resolveEdit(e){let t=tc.editPromise;t&&t(e),tc.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let t of Array.from(this.selectedIds)){let n=this.get(t);n&&e.push(n)}return e}focus(e,t={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(G(tl(e))),!1!==t.scroll&&this.scrollTo(e),this.focusedNode&&ta(this.props.onFocus,this.focusedNode)))}pageUp(){var e,t;let n=this.visibleStartIndex,i=this.visibleStopIndex-n,r=null!==(t=null===(e=this.focusedNode)||void 0===e?void 0:e.rowIndex)&&void 0!==t?t:0;r=r>n?n:Math.max(n-i,0),this.focus(this.at(r))}pageDown(){var e,t;let n=this.visibleStartIndex,i=this.visibleStopIndex,r=i-n,o=null!==(t=null===(e=this.focusedNode)||void 0===e?void 0:e.rowIndex)&&void 0!==t?t:0;o=othis.get(e)).filter(e=>!!e)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){var e;if(this.isFiltered)return!1;let t=null!==(e=this.get(this.state.dnd.parentId))&&void 0!==e?e:this.root,n=this.dragNodes,i=this.props.disableDrop;for(let e of n)if(!e||!t||e.isInternal&&_(t,e))return!1;if("function"==typeof i)return!i({parentNode:t,dragNodes:this.dragNodes,index:this.state.dnd.index||0});if("string"==typeof i)return!t.data[i];if("boolean"==typeof i)return!i;else return!0}hideCursor(){this.dispatch(et.cursor({type:"none"}))}showCursor(e){this.dispatch(et.cursor(e))}open(e){let t=td(e);if(!!t)!this.isOpen(t)&&(this.dispatch(X.open(t,this.isFiltered)),ta(this.props.onToggle,t))}close(e){let t=td(e);if(!!t)this.isOpen(t)&&(this.dispatch(X.close(t,this.isFiltered)),ta(this.props.onToggle,t))}toggle(e){let t=td(e);if(t)return this.isOpen(t)?this.close(t):this.open(t)}openParents(e){let t=td(e);if(!t)return;let n=A(this.root,t),i=null==n?void 0:n.parent;for(;i;)this.open(i.id),i=i.parent}openSiblings(e){let t=e.parent;if(t){if(t.children){let n=e.isOpen;for(let e of t.children)e.isInternal&&(n?this.close(e.id):this.open(e.id));this.scrollTo(this.focusedNode)}}else this.toggle(e.id)}openAll(){E(this.root,e=>{e.isInternal&&e.open()})}closeAll(){E(this.root,e=>{e.isInternal&&e.close()})}scrollTo(e,t="smart"){if(!e)return;let n=tl(e);return this.openParents(n),R(()=>n in this.idToIndex).then(()=>{var e;let i=this.idToIndex[n];void 0!==i&&(null===(e=this.list.current)||void 0===e||e.scrollToItem(i,t))}).catch(()=>{})}get isEditing(){return null!==this.state.nodes.edit.id}get isFiltered(){var e;return!!(null===(e=this.props.searchTerm)||void 0===e?void 0:e.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return 0===this.state.nodes.selection.ids.size}get hasOneSelection(){return 1===this.state.nodes.selection.ids.size}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return!!e&&this.state.nodes.selection.ids.has(e)}isOpen(e){var t,n,i;if(!e)return!1;if(e===Z)return!0;let r=null===(t=this.props.openByDefault)||void 0===t||t;return this.isFiltered?null===(n=this.state.nodes.open.filtered[e])||void 0===n||n:null!==(i=this.state.nodes.open.unfiltered[e])&&void 0!==i?i:r}isEditable(e){return!D(e,this.props.disableEdit||(()=>!1))}isDraggable(e){return!D(e,this.props.disableDrag||(()=>!1))}isDragging(e){let t=td(e);return!!t&&this.state.nodes.drag.id===t}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){let t=td(e);if(!t)return!1;let{destinationParentId:n,destinationIndex:i}=this.state.nodes.drag;return t===n&&null===i}onFocus(){let e=this.focusedNode||this.firstNode;e&&this.dispatch(G(e.id))}onBlur(){this.dispatch({type:"TREE_BLUR"})}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||tn}get renderRow(){return this.props.renderRow||V}get renderNode(){return this.props.children||U}get renderDragPreview(){return this.props.renderDragPreview||eo}get renderCursor(){return this.props.renderCursor||H}}function th(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var tu="function"==typeof Symbol&&Symbol.observable||"@@observable",tp=()=>Math.random().toString(36).substring(7).split("").join("."),tf={INIT:`@@redux/INIT${tp()}`,REPLACE:`@@redux/REPLACE${tp()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${tp()}`};function tm(e){let t;let n=Object.keys(e),i={};for(let t=0;t{let n=e[t];if(void 0===n(void 0,{type:tf.INIT}))throw Error(th(12));if(void 0===n(void 0,{type:tf.PROBE_UNKNOWN_ACTION()}))throw Error(th(13))})}(i)}catch(e){t=e}return function(e={},n){if(t)throw t;let o=!1,s={};for(let t=0;tn.add(e)),Object.assign(Object.assign({},e),{ids:new Set(n)});case"SELECTION_REMOVE":if(0===t.ids.length)return e;return t.ids.forEach(e=>n.delete(e)),Object.assign(Object.assign({},e),{ids:new Set(n)});case"SELECTION_SET":return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case"SELECTION_MOST_RECENT":return Object.assign(Object.assign({},e),{mostRecent:t.id});case"SELECTION_ANCHOR":return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}},drag:function(e=Q().nodes.drag,t){switch(t.type){case"DND_DRAG_START":return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":if(t.parentId!==e.destinationParentId||t.index!=e.destinationIndex)return Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index});return e;default:return e}}}),dnd:function(e=Q().dnd,t){switch(t.type){case"DND_CURSOR":return Object.assign(Object.assign({},e),{cursor:t.cursor});case"DND_DRAG_START":return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case"DND_DRAG_END":return Q().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}});function tv(e){var t=null;return function(){return null==t&&(t=e()),t}}function tb(e,t){for(var n=0;n0}},{key:"leave",value:function(e){var t,n,i=this.entered.length;return this.entered=(t=this.entered.filter(this.isNodeInDocument),n=e,t.filter(function(e){return e!==n})),i>0&&0===this.entered.length}},{key:"reset",value:function(){this.entered=[]}}],tb(e.prototype,t),i}(),tw=tv(function(){return/firefox/i.test(navigator.userAgent)}),t_=tv(function(){return!!window.safari});function tS(e,t){for(var n=0;ne))return i[t];d=t-1}}var h=e-n[a=Math.max(0,d)],u=h*h;return i[a]+r[a]*h+o[a]*u+s[a]*h*u}}],tS(e.prototype,t),i}();function tE(e){var t=1===e.nodeType?e:e.parentElement;if(!t)return null;var n=t.getBoundingClientRect(),i=n.top;return{x:n.left,y:i}}function tk(e){return{x:e.clientX,y:e.clientY}}var tT="__NATIVE_FILE__",tM="__NATIVE_URL__",tD="__NATIVE_TEXT__",tO="__NATIVE_HTML__";function tI(e,t,n){var i=t.reduce(function(t,n){return t||e.getData(n)},"");return null!=i?i:n}function tN(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var tP=(tN(o={},tT,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:["Files"]}),tN(o,tO,{exposeProperties:{html:function(e,t){return tI(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Html","text/html"]}),tN(o,tM,{exposeProperties:{urls:function(e,t){return tI(e,t,"").split("\n")},dataTransfer:function(e){return e}},matchesTypes:["Url","text/uri-list"]}),tN(o,tD,{exposeProperties:{text:function(e,t){return tI(e,t,"")},dataTransfer:function(e){return e}},matchesTypes:["Text","text/plain"]}),o);function tR(e,t){for(var n=0;n-1})})[0]||null}function tB(e,t){for(var n=0;n0&&r.actions.hover(t,{clientOffset:tk(e)}),t.some(function(e){return r.monitor.canDropOnTarget(e)})&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=r.getCurrentDropEffect()))}),tW(this,"handleTopDragOverCapture",function(){r.dragOverTargetIds=[]}),tW(this,"handleTopDragOver",function(e){var t=r.dragOverTargetIds;if(r.dragOverTargetIds=[],!r.monitor.isDragging()){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none");return}r.altKeyPressed=e.altKey,r.lastClientOffset=tk(e),null===r.hoverRafId&&"undefined"!=typeof requestAnimationFrame&&(r.hoverRafId=requestAnimationFrame(function(){r.monitor.isDragging()&&r.actions.hover(t||[],{clientOffset:r.lastClientOffset}),r.hoverRafId=null})),(t||[]).some(function(e){return r.monitor.canDropOnTarget(e)})?(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=r.getCurrentDropEffect())):r.isDraggingNativeItem()?e.preventDefault():(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect="none"))}),tW(this,"handleTopDragLeaveCapture",function(e){if(r.isDraggingNativeItem()&&e.preventDefault(),!!r.enterLeaveCounter.leave(e.target))r.isDraggingNativeItem()&&setTimeout(function(){return r.endDragNativeItem()},0)}),tW(this,"handleTopDropCapture",function(e){if(r.dropTargetIds=[],r.isDraggingNativeItem()){var t;e.preventDefault(),null===(t=r.currentNativeSource)||void 0===t||t.loadDataTransfer(e.dataTransfer)}else tF(e.dataTransfer)&&e.preventDefault();r.enterLeaveCounter.reset()}),tW(this,"handleTopDrop",function(e){var t=r.dropTargetIds;r.dropTargetIds=[],r.actions.hover(t,{clientOffset:tk(e)}),r.actions.drop({dropEffect:r.getCurrentDropEffect()}),r.isDraggingNativeItem()?r.endDragNativeItem():r.monitor.isDragging()&&r.actions.endDrag()}),tW(this,"handleSelectStart",function(e){var t=e.target;if("function"==typeof t.dragDrop&&"INPUT"!==t.tagName&&"SELECT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable)e.preventDefault(),t.dragDrop()}),this.options=new tH(t,n),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new tx(this.isNodeInDocument)}return e=i,t=[{key:"profile",value:function(){var e,t;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:(null===(e=this.dragStartSourceIds)||void 0===e?void 0:e.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:(null===(t=this.dragOverTargetIds)||void 0===t?void 0:t.length)||0}}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var e=this.rootElement;if(void 0!==e){if(e.__isReactDndBackendSetUp)throw Error("Cannot have two HTML5 backends at the same time.");e.__isReactDndBackendSetUp=!0,this.addEventListeners(e)}}},{key:"teardown",value:function(){var e,t=this.rootElement;if(void 0!==t)t.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId&&(null===(e=this.window)||void 0===e||e.cancelAnimationFrame(this.asyncEndDragFrameId))}},{key:"connectDragPreview",value:function(e,t,n){var i=this;return this.sourcePreviewNodeOptions.set(e,n),this.sourcePreviewNodes.set(e,t),function(){i.sourcePreviewNodes.delete(e),i.sourcePreviewNodeOptions.delete(e)}}},{key:"connectDragSource",value:function(e,t,n){var i=this;this.sourceNodes.set(e,t),this.sourceNodeOptions.set(e,n);var r=function(t){return i.handleDragStart(t,e)},o=function(e){return i.handleSelectStart(e)};return t.setAttribute("draggable","true"),t.addEventListener("dragstart",r),t.addEventListener("selectstart",o),function(){i.sourceNodes.delete(e),i.sourceNodeOptions.delete(e),t.removeEventListener("dragstart",r),t.removeEventListener("selectstart",o),t.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(e,t){var n=this,i=function(t){return n.handleDragEnter(t,e)},r=function(t){return n.handleDragOver(t,e)},o=function(t){return n.handleDrop(t,e)};return t.addEventListener("dragenter",i),t.addEventListener("dragover",r),t.addEventListener("drop",o),function(){t.removeEventListener("dragenter",i),t.removeEventListener("dragover",r),t.removeEventListener("drop",o)}}},{key:"addEventListeners",value:function(e){if(!!e.addEventListener)e.addEventListener("dragstart",this.handleTopDragStart),e.addEventListener("dragstart",this.handleTopDragStartCapture,!0),e.addEventListener("dragend",this.handleTopDragEndCapture,!0),e.addEventListener("dragenter",this.handleTopDragEnter),e.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.addEventListener("dragover",this.handleTopDragOver),e.addEventListener("dragover",this.handleTopDragOverCapture,!0),e.addEventListener("drop",this.handleTopDrop),e.addEventListener("drop",this.handleTopDropCapture,!0)}},{key:"removeEventListeners",value:function(e){if(!!e.removeEventListener)e.removeEventListener("dragstart",this.handleTopDragStart),e.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),e.removeEventListener("dragend",this.handleTopDragEndCapture,!0),e.removeEventListener("dragenter",this.handleTopDragEnter),e.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),e.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),e.removeEventListener("dragover",this.handleTopDragOver),e.removeEventListener("dragover",this.handleTopDragOverCapture,!0),e.removeEventListener("drop",this.handleTopDrop),e.removeEventListener("drop",this.handleTopDropCapture,!0)}},{key:"getCurrentSourceNodeOptions",value:function(){var e=this.monitor.getSourceId(),t=this.sourceNodeOptions.get(e);return tU({dropEffect:this.altKeyPressed?"copy":"move"},t||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var e=this.monitor.getSourceId();return tU({anchorX:.5,anchorY:.5,captureDraggingState:!1},this.sourcePreviewNodeOptions.get(e)||{})}},{key:"isDraggingNativeItem",value:function(){var e=this.monitor.getItemType();return Object.keys(l).some(function(t){return l[t]===e})}},{key:"beginDragNativeItem",value:function(e,t){var n,i,r;this.clearCurrentDragSourceNode(),this.currentNativeSource=(n=e,i=t,(r=new tj(tP[n])).loadDataTransfer(i),r),this.currentNativeHandle=this.registry.addSource(e,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(e){var t=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=e;this.mouseMoveTimeoutTimer=setTimeout(function(){var e;return null===(e=t.rootElement)||void 0===e?void 0:e.addEventListener("mousemove",t.endDragIfSourceWasRemovedFromDOM,!0)},1e3)}},{key:"clearCurrentDragSourceNode",value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var e;null===(e=this.window)||void 0===e||e.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:"handleDragStart",value:function(e,t){if(!e.defaultPrevented)!this.dragStartSourceIds&&(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(t)}},{key:"handleDragEnter",value:function(e,t){this.dragEnterTargetIds.unshift(t)}},{key:"handleDragOver",value:function(e,t){null===this.dragOverTargetIds&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(t)}},{key:"handleDrop",value:function(e,t){this.dropTargetIds.unshift(t)}}],t$(e.prototype,t),i}(),tG=function(e,t,n){return new tq(e,t,n)},tK="dnd-core/INIT_COORDS",tZ="dnd-core/BEGIN_DRAG",tY="dnd-core/PUBLISH_DRAG_SOURCE",tX="dnd-core/HOVER",tJ="dnd-core/DROP",tQ="dnd-core/END_DRAG";function t0(e,t){return{type:tK,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function t1(e){return(t1="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)}function t2(e){return"object"===t1(e)}var t5={type:tK,payload:{clientOffset:null,sourceClientOffset:null}};function t3(e,t){return null===t?null===e:Array.isArray(e)?e.some(function(e){return e===t}):e===t}function t4(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,i)}return n}function t6(e){for(var t=1;t0;n.backend&&(e&&!n.isSetUp?(n.backend.setup(),n.isSetUp=!0):!e&&n.isSetUp&&(n.backend.teardown(),n.isSetUp=!1))}),this.store=e,this.monitor=t,e.subscribe(this.handleRefCountChange)}return e=i,t=[{key:"receiveBackend",value:function(e){this.backend=e}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var e,t,n,i,r,o,s=this,a=this.store.dispatch;var l=(e=this,{beginDrag:(t=e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{publishSource:!0},i=n.publishSource,r=n.clientOffset,o=n.getSourceClientOffset,s=t.getMonitor(),a=t.getRegistry();t.dispatch(t0(r)),function(e,t,n){(0,e_.k)(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(e){(0,e_.k)(n.getSource(e),"Expected sourceIds to be registered.")})}(e,s,a);var l=function(e,t){for(var n=null,i=e.length-1;i>=0;i--)if(t.canDragSource(e[i])){n=e[i];break}return n}(e,s);if(null===l){t.dispatch(t5);return}var d=null;if(r){if(!o)throw Error("getSourceClientOffset must be defined");(function(e){(0,e_.k)("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")})(o),d=o(l)}t.dispatch(t0(r,d));var c=a.getSource(l).beginDrag(s,l);if(null!=c)return function(e){(0,e_.k)(t2(e),"Item must be an object.")}(c),a.pinSource(l),{type:tZ,payload:{itemType:a.getSourceType(l),item:c,sourceId:l,clientOffset:r||null,sourceClientOffset:d||null,isSourcePublic:!!(void 0===i||i)}}}),publishDragSource:(n=e,function(){if(n.getMonitor().isDragging())return{type:tY}}),hover:(i=e,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.clientOffset;(function(e){(0,e_.k)(Array.isArray(e),"Expected targetIds to be an array.")})(e);var r=e.slice(0),o=i.getMonitor(),s=i.getRegistry();return function(e,t,n){(0,e_.k)(t.isDragging(),"Cannot call hover while not dragging."),(0,e_.k)(!t.didDrop(),"Cannot call hover after drop.");for(var i=0;i=0;i--){var r=e[i];!t3(t.getTargetType(r),n)&&e.splice(i,1)}}(r,s,o.getItemType()),function(e,t,n){e.forEach(function(e){n.getTarget(e).hover(t,e)})}(r,o,s),{type:tX,payload:{targetIds:r,clientOffset:n||null}}}),drop:(r=e,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.getMonitor(),n=r.getRegistry();(function(e){(0,e_.k)(e.isDragging(),"Cannot call drop while not dragging."),(0,e_.k)(!e.didDrop(),"Cannot call drop twice during one drag operation.")})(t),(function(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t})(t).forEach(function(i,o){var s=function(e,t,n,i){var r=n.getTarget(e),o=r?r.drop(i,e):void 0;return function(e){(0,e_.k)(void 0===e||t2(e),"Drop result must either be an object or undefined.")}(o),void 0===o&&(o=0===t?{}:i.getDropResult()),o}(i,o,n,t),a={type:tJ,payload:{dropResult:t6(t6({},e),s)}};r.dispatch(a)})}),endDrag:(o=e,function(){var e=o.getMonitor(),t=o.getRegistry();(function(e){(0,e_.k)(e.isDragging(),"Cannot call endDrag while not dragging.")})(e);var n=e.getSourceId();return null!=n&&(t.getSource(n,!0).endDrag(e,n),t.unpinSource()),{type:tQ}})});return Object.keys(l).reduce(function(e,t){var n,i=l[t];return e[t]=(n=i,function(){for(var e=arguments.length,t=Array(e),i=0;i0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:function(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];var e,t,n,i,r,o=arguments.length>1?arguments[1]:void 0;switch(o.type){case tX:break;case no:case ns:case nl:case na:return nu;default:return np}var s=o.payload,a=s.targetIds,l=void 0===a?[]:a,d=s.prevTargetIds,c=void 0===d?[]:d;var h=(e=l,t=c,n=new Map,i=function(e){n.set(e,n.has(e)?n.get(e)+1:1)},e.forEach(i),t.forEach(i),r=[],n.forEach(function(e,t){1===e&&r.push(t)}),r);if(!(h.length>0||!function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:nt;if(e.length!==t.length)return!1;for(var i=0;i0&&void 0!==arguments[0]?arguments[0]:nr,i=arguments.length>1?arguments[1]:void 0,r=i.payload;switch(i.type){case tK:case tZ:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case tX:;if(e=n.clientOffset,t=r.clientOffset,!e&&!t||e&&t&&e.x===t.x&&e.y===t.y)return n;return ni(ni({},n),{},{clientOffset:r.clientOffset});case tQ:case tJ:return nr;default:return n}}(n.dragOffset,i),refCount:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case no:case ns:return e+1;case na:case nl:return e-1;default:return e}}(n.refCount,i),dragOperation:function(){var e,t,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:nh,i=arguments.length>1?arguments[1]:void 0,r=i.payload;switch(i.type){case tZ:return nc(nc({},n),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case tY:return nc(nc({},n),{},{isSourcePublic:!0});case tX:return nc(nc({},n),{},{targetIds:r.targetIds});case nl:;if(-1===n.targetIds.indexOf(r.targetId))return n;return nc(nc({},n),{},{targetIds:(e=n.targetIds,t=r.targetId,e.filter(function(e){return e!==t}))});case tJ:return nc(nc({},n),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case tQ:return nc(nc({},n),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return n}}(n.dragOperation,i),stateId:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e+1}(n.stateId)}}function nv(e,t){return{x:e.x-t.x,y:e.y-t.y}}function nb(e,t){for(var n=0;n1&&void 0!==arguments[1]?arguments[1]:{handlerIds:void 0},i=n.handlerIds;(0,e_.k)("function"==typeof e,"listener must be a function."),(0,e_.k)(void 0===i||Array.isArray(i),"handlerIds, when specified, must be an array of strings.");var r=this.store.getState().stateId;return this.store.subscribe(function(){var n=t.store.getState(),o=n.stateId;try{!(o===r||o===r+1&&!function(e,t){var n,i;if(e===nu)return!1;if(e===np||void 0===t)return!0;return(n=t,i=e,n.filter(function(e){return i.indexOf(e)>-1})).length>0}(n.dirtyHandlerIds,i))&&e()}finally{r=o}})}},{key:"subscribeToOffsetChange",value:function(e){var t=this;(0,e_.k)("function"==typeof e,"listener must be a function.");var n=this.store.getState().dragOffset;return this.store.subscribe(function(){var i=t.store.getState().dragOffset;if(i!==n)n=i,e()})}},{key:"canDragSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return(0,e_.k)(t,"Expected to find a valid source. sourceId=".concat(e)),!this.isDragging()&&t.canDrag(this,e)}},{key:"canDropOnTarget",value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return(0,e_.k)(t,"Expected to find a valid target. targetId=".concat(e)),!(!this.isDragging()||this.didDrop())&&t3(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}},{key:"isDragging",value:function(){return!!this.getItemType()}},{key:"isDraggingSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return(0,e_.k)(t,"Expected to find a valid source. sourceId=".concat(e)),!!(this.isDragging()&&this.isSourcePublic())&&this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e)}},{key:"isOverTarget",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shallow:!1};if(!e)return!1;var n=t.shallow;if(!this.isDragging())return!1;var i=this.registry.getTargetType(e),r=this.getItemType();if(r&&!t3(i,r))return!1;var o=this.getTargetIds();if(!o.length)return!1;var s=o.indexOf(e);return n?s===o.length-1:s>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return!!this.store.getState().dragOperation.isSourcePublic}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return function(e){var t,n,i=e.clientOffset,r=e.initialClientOffset,o=e.initialSourceClientOffset;if(!i||!r||!o)return null;return nv((t=i,n=o,{x:t.x+n.x,y:t.y+n.y}),r)}(this.store.getState().dragOffset)}},{key:"getDifferenceFromInitialOffset",value:function(){var e,t,n;return t=(e=this.store.getState().dragOffset).clientOffset,n=e.initialClientOffset,t&&n?nv(t,n):null}}],nb(e.prototype,t),i}(),nw=0;function n_(e){return(n_="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)}(i=s||(s={})).SOURCE="SOURCE",i.TARGET="TARGET";function nS(e,t){if(t&&Array.isArray(e)){e.forEach(function(e){return nS(e,!1)});return}(0,e_.k)("string"==typeof e||"symbol"===n_(e),t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}let nC="undefined"!=typeof global?global:self,nA=nC.MutationObserver||nC.WebKitMutationObserver;function nE(e){return function(){let t=setTimeout(i,0),n=setInterval(i,50);function i(){clearTimeout(t),clearInterval(n),e()}}}let nk="function"==typeof nA?function(e){let t=1,n=new nA(e),i=document.createTextNode("");return n.observe(i,{characterData:!0}),function(){t=-t,i.data=t}}:nE;class nT{call(){try{this.task&&this.task()}catch(e){this.onError(e)}finally{this.task=null,this.release(this)}}constructor(e,t){this.onError=e,this.release=t,this.task=null}}let nM=new class e{enqueueTask(e){let{queue:t,requestFlush:n}=this;!t.length&&(n(),this.flushing=!0),t[t.length]=e}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{let{queue:e}=this;for(;this.indexthis.capacity){for(let t=0,n=e.length-this.index;t{this.pendingErrors.push(e),this.requestErrorThrow()},this.requestFlush=nk(this.flush),this.requestErrorThrow=nE(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}},nD=new class e{create(e){let t=this.freeTasks,n=t.length?t.pop():new nT(this.onError,e=>t[t.length]=e);return n.task=e,n}constructor(e){this.onError=e,this.freeTasks=[]}}(nM.registerPendingError);function nO(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,i=Array(t);n1&&void 0!==arguments[1]&&arguments[1];return(0,e_.k)(this.isSourceId(e),"Expected a valid source ID."),t&&e===this.pinnedSourceId?this.pinnedSource:this.dragSources.get(e)}},{key:"getTarget",value:function(e){return(0,e_.k)(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}},{key:"getSourceType",value:function(e){return(0,e_.k)(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}},{key:"getTargetType",value:function(e){return(0,e_.k)(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}},{key:"isSourceId",value:function(e){return nP(e)===s.SOURCE}},{key:"isTargetId",value:function(e){return nP(e)===s.TARGET}},{key:"removeSource",value:function(e){var t,n=this;(0,e_.k)(this.getSource(e),"Expected an existing source."),this.store.dispatch({type:na,payload:{sourceId:e}}),t=function(){n.dragSources.delete(e),n.types.delete(e)},nM.enqueueTask(nD.create(t))}},{key:"removeTarget",value:function(e){(0,e_.k)(this.getTarget(e),"Expected an existing target."),this.store.dispatch({type:nl,payload:{targetId:e}}),this.dropTargets.delete(e),this.types.delete(e)}},{key:"pinSource",value:function(e){var t=this.getSource(e);(0,e_.k)(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}},{key:"unpinSource",value:function(){(0,e_.k)(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(e,t,n){var i=function(e){var t=(nw++).toString();switch(e){case s.SOURCE:return"S".concat(t);case s.TARGET:return"T".concat(t);default:throw Error("Unknown Handler Role: ".concat(e))}}(e);return this.types.set(i,t),e===s.SOURCE?this.dragSources.set(i,n):e===s.TARGET&&this.dropTargets.set(i,n),i}}],nO(e.prototype,t),i}(),nj=["children"];function nF(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n1&&void 0!==arguments[1]?arguments[1]:nV(),n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return!t[nz]&&(t[nz]={dragDropManager:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=function(e){var t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return(0,ne.MT)(ng,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}(i),o=new nx(r,new nL(r)),s=new t9(r,o),a=e(s,t,n);return s.receiveBackend(a),s}(e,t,n,i)}),t[nz]}(e.backend,e.context,e.options,e.debugMode),!e.context]}(function(e,t){if(null==e)return{};var n,i,r=function(e,t){if(null==e)return{};var n,i,r={},o=Object.keys(e);for(i=0;i=0)&&(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i=0))Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}}return r}(e,nj)))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{!s&&null!=r.return&&r.return()}finally{if(a)throw i}}return o}}(t,2)||function(e,t){if(e){if("string"==typeof e)return nF(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nF(e,t)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=r[0],s=r[1];return(0,c.useEffect)(function(){if(s){var e=nV();return++nB,function(){0==--nB&&(e[nz]=null)}}},[]),(0,d.jsx)(eS.Provider,Object.assign({value:o},{children:i}),void 0)});function nV(){return void 0!==n.g?n.g:window}let nU=Q();function n$({treeProps:e,imperativeHandle:t,children:n}){let i=(0,c.useRef)(null),r=(0,c.useRef)(null),o=(0,c.useRef)(function e(t,n,i){if("function"!=typeof t)throw Error(th(2));if("function"==typeof n&&"function"==typeof i||"function"==typeof i&&"function"==typeof arguments[3])throw Error(th(0));if("function"==typeof n&&void 0===i&&(i=n,n=void 0),void 0!==i){if("function"!=typeof i)throw Error(th(1));return i(e)(t,n)}let r=t,o=n,s=new Map,a=s,l=0,d=!1;function c(){a===s&&(a=new Map,s.forEach((e,t)=>{a.set(t,e)}))}function h(){if(d)throw Error(th(3));return o}function u(e){if("function"!=typeof e)throw Error(th(4));if(d)throw Error(th(5));let t=!0;c();let n=l++;return a.set(n,e),function(){if(!!t){if(d)throw Error(th(6));t=!1,c(),a.delete(n),s=null}}}function p(e){if(!function(e){if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)}(e))throw Error(th(7));if(void 0===e.type)throw Error(th(8));if("string"!=typeof e.type)throw Error(th(17));if(d)throw Error(th(9));try{d=!0,o=r(o,e)}finally{d=!1}return(s=a).forEach(e=>{e()}),e}return p({type:tf.INIT}),{dispatch:p,subscribe:u,getState:h,replaceReducer:function(e){if("function"!=typeof e)throw Error(th(10));r=e,p({type:tf.REPLACE})},[tu]:function(){return{subscribe(e){if("object"!=typeof e||null===e)throw Error(th(11));function t(){e.next&&e.next(h())}return t(),{unsubscribe:u(t)}},[tu](){return this}}}}}(tg,Q(e))),s=(0,h.useSyncExternalStore)(o.current.subscribe,o.current.getState,()=>nU),a=(0,c.useMemo)(()=>new tc(o.current,e,i,r),[]),l=(0,c.useRef)(0);return(0,c.useMemo)(()=>{l.current+=1,a.update(e)},[...Object.values(e),s.nodes.open]),(0,c.useImperativeHandle)(t,()=>a),(0,c.useEffect)(()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()},[a.props.selection]),(0,c.useEffect)(()=>{!a.props.searchTerm&&o.current.dispatch(X.clear(!0))},[a.props.searchTerm]),(0,d.jsx)(u.Provider,{value:a,children:(0,d.jsx)(g.Provider,{value:l.current,children:(0,d.jsx)(f.Provider,{value:s.nodes,children:(0,d.jsx)(m.Provider,{value:s.dnd,children:(0,d.jsx)(nH,Object.assign({backend:tG,options:{rootElement:a.props.dndRootElement||void 0}},e.dndManager&&{manager:e.dndManager},{children:n}))})})})})}function nW(e){return!function(){let e=p(),[,t]=e3(()=>({accept:"NODE",canDrop:(t,n)=>!!n.isOver({shallow:!0})&&e.canDrop(),hover:(t,n)=>{if(!n.isOver({shallow:!0}))return;let i=n.getClientOffset();if(!e.listEl.current||!i)return;let{cursor:r,drop:o}=e7({element:e.listEl.current,offset:i,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});o&&e.dispatch(et.hovering(o.parentId,o.index)),n.canDrop()?r&&e.showCursor(r):e.hideCursor()}}),[e]);t(e.listEl)}(),e.children}function nq(){let e=p().props.renderContainer||tn;return(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(e,{})})}function nG(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n({offset:e.getSourceClientOffset(),mouse:e.getClientOffset(),item:e.getItem(),isDragging:e.isDragging()}),o=(r=(i=2,function(e){if(Array.isArray(e))return e}(n=e$(t=eC().getMonitor(),e))||function(e,t){var n,i,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],s=!0,a=!1;try{for(r=r.call(e);!(s=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);s=!0);}catch(e){a=!0,i=e}finally{try{!s&&null!=r.return&&r.return()}finally{if(a)throw i}}return o}}(n,2)||function(e,t){if(e){if("string"==typeof e)return nG(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return nG(e,t)}}(n,i)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()))[0],s=r[1],(0,c.useEffect)(function(){return t.subscribeToOffsetChange(s)}),(0,c.useEffect)(function(){return t.subscribeToStateChange(s)}),o),m=a.props.renderDragPreview||eo;return(0,d.jsx)(m,{offset:l,mouse:h,id:(null==u?void 0:u.id)||null,dragIds:(null==u?void 0:u.dragIds)||[],isDragging:f})}class nZ{constructor(e){this.root=function(e){let t=new nX({id:"ROOT"},null);return t.children=e.map(e=>nY(e,t)),t}(e)}get data(){var e,t;return null!==(t=null===(e=this.root.children)||void 0===e?void 0:e.map(e=>e.data))&&void 0!==t?t:[]}create(e){let t=e.parentId?this.find(e.parentId):this.root;if(!t)return null;t.addChild(e.data,e.index)}move(e){let t=this.find(e.id),n=e.parentId?this.find(e.parentId):this.root;t&&n&&(n.addChild(t.data,e.index),t.drop())}update(e){let t=this.find(e.id);t&&t.update(e.changes)}drop(e){let t=this.find(e.id);t&&t.drop()}find(e,t=this.root){if(!t)return null;if(t.id===e)return t;if(t.children)for(let n of t.children){let t=this.find(e,n);if(t)return t}return null}}function nY(e,t){let n=new nX(e,t);return e.children&&(n.children=e.children.map(e=>nY(e,n))),n}class nX{constructor(e,t){this.data=e,this.parent=t,this.id=e.id}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,t){var n,i;let r=nY(e,this);this.children=null!==(n=this.children)&&void 0!==n?n:[],this.children.splice(t,0,r),this.data.children=null!==(i=this.data.children)&&void 0!==i?i:[],this.data.children.splice(t,0,e)}removeChild(e){var t,n;null===(t=this.children)||void 0===t||t.splice(e,1),null===(n=this.data.children)||void 0===n||n.splice(e,1)}update(e){if(this.hasParent()){let t=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),t),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}}let nJ=0,nQ=(0,c.forwardRef)(function(e,t){let n=function(e){if(e.initialData&&e.data)throw Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw Error(`React Arborist Tree => You passed the initialData prop along with a data handler. Use the data prop if you want to provide your own handlers.`);if(!e.initialData)return e;{let[t,n]=function(e){let[t,n]=(0,c.useState)(e),i=(0,c.useMemo)(()=>new nZ(t),[t]);return[t,{onMove:e=>{for(let t of e.dragIds)i.move({id:t,parentId:e.parentId,index:e.index});n(i.data)},onRename:({name:e,id:t})=>{i.update({id:t,changes:{name:e}}),n(i.data)},onCreate:({parentId:e,index:t,type:r})=>{let o={id:`simple-tree-id-${nJ++}`,name:""};return"internal"===r&&(o.children=[]),i.create({parentId:e,index:t,data:o}),n(i.data),o},onDelete:e=>{e.ids.forEach(e=>i.drop({id:e})),n(i.data)}}]}(e.initialData);return Object.assign(Object.assign(Object.assign({},e),n),{data:t})}}(e);return(0,d.jsxs)(n$,{treeProps:n,imperativeHandle:t,children:[(0,d.jsx)(nW,{children:(0,d.jsx)(nq,{})}),(0,d.jsx)(nK,{})]})})},275211:function(e,t,n){n.d(t,{DE:function(){return c},MT:function(){return l},md:function(){return u},qC:function(){return h}});var i=n(894626);function r(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var o="function"==typeof Symbol&&Symbol.observable||"@@observable",s=function(){return Math.random().toString(36).substring(7).split("").join(".")},a={INIT:"@@redux/INIT"+s(),REPLACE:"@@redux/REPLACE"+s(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+s()}};function l(e,t,n){if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw Error(r(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw Error(r(1));return n(l)(e,t)}if("function"!=typeof e)throw Error(r(2));var i,s=e,d=t,c=[],h=c,u=!1;function p(){h===c&&(h=c.slice())}function f(){if(u)throw Error(r(3));return d}function m(e){if("function"!=typeof e)throw Error(r(4));if(u)throw Error(r(5));var t=!0;return p(),h.push(e),function(){if(!!t){if(u)throw Error(r(6));t=!1,p();var n=h.indexOf(e);h.splice(n,1),c=null}}}function g(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw Error(r(7));if(void 0===e.type)throw Error(r(8));if(u)throw Error(r(9));try{u=!0,d=s(d,e)}finally{u=!1}for(var t=c=h,n=0;n{var e=(0,o.L)(),[,t]=(0,i.useState)(0);return(0,i.useEffect)(()=>{var e=()=>{t(Date.now())};return r.l.on("change",e),()=>{r.l.off("change",e)}},[]),[e]}},757208:function(e,t,n){n.d(t,{OL:function(){return r}});var i,r=((i={})[i.PendingVectoring=0]="PendingVectoring",i[i.FinishVectoring=1]="FinishVectoring",i[i.Deactive=9]="Deactive",i[i.AuditFailed=1e3]="AuditFailed",i)},487377:function(e,t,n){n.d(t,{a:function(){return o}});var i=n(455069),r=n(579367),o=e=>{var{isLive:t,extra:n,scene:o=r.ik}=e;(0,i.useEffect)(()=>{t&&(0,r.WQ)(n,o)},[t])}},579367:function(e,t,n){n.d(t,{WQ:function(){return d},ik:function(){return l}});var i=n(808549),r=n(120454),o=n(297158),s="first-contentful-paint",a={name:"",reportScene:[]},l="init",d=(e,t)=>{var n=null!=t?t:l,d=performance.now(),u=performance.getEntriesByName("route_change"),p=u.at(-1);if(!((null==p?void 0:null===(g=p.detail)||void 0===g?void 0:null===(m=g.location)||void 0===m?void 0:m.pathname)&&p.detail.location.pathname===a.name&&a.reportScene.includes(n))){if("hidden"===document.visibilityState){o.E7.info({message:"page_hidden_on_tti_report",namespace:"performance"});return}if(a.name=null==p?void 0:null===(b=p.detail)||void 0===b?void 0:null===(v=b.location)||void 0===v?void 0:v.pathname,a.reportScene.push(n),u.length>1){h(d-(null!==(y=null==p?void 0:p.startTime)&&void 0!==y?y:0),e);return}var f=performance.getEntriesByName(s)[0];if(f)c(d>f.startTime?d:f.startTime,(0,r._)((0,i._)({},e),{fcpTime:"".concat(f.startTime)}));else if(window.PerformanceObserver){var m,g,v,b,y,x,w=new PerformanceObserver(t=>{var n=t.getEntriesByName(s)[0];n&&(c(n.startTime,(0,r._)((0,i._)({},e),{fcpTime:"".concat(n.startTime)})),w.disconnect())});try{w.observe({type:"paint",buffered:!0})}catch(e){if(null===(x=PerformanceObserver.supportedEntryTypes)||void 0===x?void 0:x.includes("paint"))try{w.observe({entryTypes:["paint"]})}catch(e){o.E7.info({message:e.message,namespace:"performance"})}o.E7.info({message:e.message,namespace:"performance"})}}}},c=(e,t)=>{var n;null===(n=(0,o.f5)())||void 0===n||n("sendCustomPerfMetric",{value:e,name:"coze_custom_tti",type:"perf",extra:(0,i._)({},t)}),o.kg.info({message:"coze_custom_tti",meta:{value:e,extra:t}})},h=(e,t)=>{var n;null===(n=(0,o.f5)())||void 0===n||n("sendCustomPerfMetric",{value:e,name:"coze_custom_tti_hot",type:"perf",extra:(0,i._)({},t)}),o.kg.info({message:"coze_custom_tti_hot",meta:{value:e,extra:t}})}},304194:function(e,t,n){n.d(t,{j:()=>c});var i=n("825955"),r=n("808549"),o=n("120454"),s=n("61111"),a=n("297158"),l=n("921463");class d{constructor(){this._listeners=new Set,this._produce=e=>{var t=(0,s.Uy)(this._state,e);t!==this._state&&(this._state=t,this._dispatch())},this._dispatch=()=>{if(!!this._listeners.size)(0,l.unstable_batchedUpdates)(()=>{this._listeners.forEach(e=>e())})},this.subscribe=e=>(this._listeners.add(e),()=>{this._listeners.delete(e)}),this.getSnapshot=()=>this._state,(0,s.MD)()}}new class e extends d{add(e){this._produce(t=>{t.add(e)})}delete(e){this._produce(t=>{t.delete(e)})}constructor(...e){super(...e),this._state=new Set}};class c extends d{get featureMap(){return this._state.featureMap}getFeature(e){var t=this.getFeatureKey(e),n=this.featureMap.get(t);if(!n){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," get feature not exist ").concat(e))});return}return n}getFeatureKey(e){return"feature_".concat(this.name,"_").concat(e)}getName(){return this.name}_register(e,t){var{defaultFeature:n}=this,{type:i}=t,r=this.getFeatureKey(i);if(n&&i===n.type){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," register type is default feature ").concat(i))});return}this._state.featureMap.get(r)&&a.kg.warning("[Message Feature]: ".concat(this.name," register feature already registered ").concat(i)),e.featureMap.set(r,(0,s.cA)(t))}register(e){return this._produce(t=>{this._register(t,e)}),()=>{this._produce(t=>{this._deregister(t,e.type)})}}registerSome(e){return this._produce(t=>{e.map(e=>this._register(t,e))}),()=>{this._produce(t=>{e.forEach(e=>{this._deregister(t,e.type)})})}}_deregister(e,t){var{defaultFeature:n}=this,i=this.getFeatureKey(t);if(n&&t===n.type){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," deregister type is default feature ").concat(t))});return}if(!this._state.featureMap.get(i)){a.kg.error({error:Error("[Message Feature]: ".concat(this.name," deregister invalid feature ").concat(t))});return}e.featureMap.delete(i)}deregister(e){this._produce(t=>{this._deregister(t,e)})}deregisterSome(e){this._produce(t=>{e.forEach(e=>{this._deregister(t,e)})})}deregisterAll(){this._produce(e=>{e.featureMap=new Map})}load(e){var t=this;return(0,i._)(function*(){var n=t.getFeature(e);if(!n){a.kg.error({error:Error("[Message Feature]: ".concat(t.name," load unknown feature ").concat(e))});return}if(!n.loader){a.kg.error({error:Error("[Message Feature]: ".concat(t.name," load feature loader unset ").concat(e))});return}var i=yield n.loader();t._produce(n=>{var r=n.featureMap.get(t.getFeatureKey(e));r&&(r.module=(0,s.cA)(i.default))})})()}isLoaded(e){var t=this.getFeature(e);return t?!!t.module||!1:(a.kg.error({error:Error("[Message Feature]: ".concat(this.name," isLoaded unknown feature ").concat(e))}),!1)}has(e){return!!this.getFeature(e)}getModule(e){var t=this.getFeature(e);if(!t){a.kg.error({error:Error("[Message Feature][getModule]: ".concat(this.name," get feature not exist ").concat(e))});return}if(!t.module){a.kg.error({error:Error("[Message Feature][getModule]: ".concat(this.name," get feature module unset ").concat(e))});return}return t.module}get(e){var t=this.getFeature(e);if(!t){a.kg.error({error:Error("[Message Feature][get]: ".concat(this.name," get feature not exist ").concat(e))});return}if(!t.module){a.kg.error({error:Error("[Message Feature][get]: ".concat(this.name," get feature module unset ").concat(e))});return}return(0,o._)((0,r._)({},t.module),{type:e})}getAsync(e){var t=this;return(0,i._)(function*(){var n=t.getFeature(e);if(!n){a.kg.error({error:Error("[Message Feature]: ".concat(t.name," getAsync unknown feature ").concat(e))});return}return!n.module&&(yield t.load(e)),t.get(e)})()}entries(){var{featureMap:e}=this;return[...e.values()].filter(e=>(!e.module&&a.kg.warning("[Message Feature][entries]: ".concat(this.name," entries module unloaded feature.type=").concat(e.type)),null!==e.module&&void 0!==e.module)).map(e=>[e.type,e.module])}getAllAsync(){var e=this;return(0,i._)(function*(){var{featureMap:t}=e,n=[...t.values()];return(yield Promise.all(n.map(t=>e.getAsync(t.type)))).filter(e=>!!e)})()}getTypeByContext(e){var t,n,{featureTypeParser:i}=this;if(!i)return a.kg.error({error:Error("[Message Feature]: ".concat(this.name," getTypeByContext featureTypeParser unset"))}),null!==(t=this.getDefaultType())&&void 0!==t?t:"";try{return i(e)}catch(e){return a.kg.error({error:Error("[Message Feature]: ".concat(this.name," getTypeByContext featureTypeParser error ").concat(e))}),null!==(n=this.getDefaultType())&&void 0!==n?n:""}}getByContext(e){var t=this.getTypeByContext(e);return this.get(t)}getByContextAsync(e){var t=this;return(0,i._)(function*(){var n=t.getTypeByContext(e);return t.getAsync(n)})()}getDefault(){if(!!this.defaultFeature)return(0,r._)({type:this.defaultFeature.type},this.defaultFeature.module)}getDefaultType(){var e;return null===(e=this.defaultFeature)||void 0===e?void 0:e.type}setDefaultFeature(e){var{type:t}=e,n=this.getFeatureKey(t);this.defaultFeature=e,this._produce(t=>{t.featureMap.set(n,(0,s.cA)(e))})}setFeatureTypeParser(e){this.featureTypeParser=e.bind({internalHas:e=>{try{var t=this.getFeatureKey(e);return!!this.featureMap.get(t)}catch(e){return a.kg.error({error:Error("[Message Feature]: ".concat(this.name," featureTypeParser internalHas error ").concat(e))}),!1}}})}deregisterByTag(e){var{featureMap:t}=this,n=[...t.values()].filter(t=>{var n;return null===(n=t.tags)||void 0===n?void 0:n.includes(e)});this._produce(e=>{n.forEach(t=>{this._deregister(e,t.type)})})}getByTag(e){var{featureMap:t}=this,n=[...t.values()].filter(t=>{var n;return null===(n=t.tags)||void 0===n?void 0:n.includes(e)});return n.length?n.map(e=>this.get(e.type)).filter((e,t)=>(!e&&a.kg.warning("[Message Feature]: ".concat(this.name," getByTag module unloaded features[index].type=").concat(n[t].type)),!!e)):(a.kg.warning("[Message Feature]: ".concat(this.name," getByTag no feature include tag ").concat(e)),[])}getByTagAsync(e){var t=this;return(0,i._)(function*(){var{featureMap:n}=t,i=[...n.values()].filter(t=>{var n;return null===(n=t.tags)||void 0===n?void 0:n.includes(e)});return i.length?(yield Promise.all(i.map(e=>t.getAsync(e.type)))).filter(e=>!!e):(a.kg.warning("[Message Feature]: ".concat(t.name," getByTagAsync no feature include tag ").concat(e)),[])})()}constructor(e){super();var{name:t,defaultFeature:n,features:i,featureTypeParser:r}=e;this.name=t,this._state={featureMap:new Map},n&&this.setDefaultFeature(n),i&&this.registerSome(i),r&&this.setFeatureTypeParser(r)}}},420998:function(e,t,n){n.d(t,{SA:()=>a,Tn:()=>l,yt:()=>F,Is:()=>g});var i=n("825955"),r=n("151064"),o=n("455069"),s=n("659596"),a=e=>{var{fileUrl:t}=e,[n,a]=(0,o.useState)(""),[l,d]=(0,o.useState)(!0);(0,o.useEffect)(()=>{fetch(t).then(e=>e.text()).then(e=>{d(!1),a(e)})},[t]);var c=(0,o.useRef)(null);return(0,o.useEffect)(()=>{function e(){return(e=(0,i._)(function*(){if(c.current){for(var e=0,t=n.length;esetTimeout(e,10)),c.current.textContent+=n.slice(5e4*e,(e+1)*5e4);c.current.textContent=n}})).apply(this,arguments)}!function(){e.apply(this,arguments)}()},[n]),(0,r.jsx)("div",{className:"flex flex-col items-center w-full h-full flex-1 py-2 px-4",children:(0,r.jsx)(s.yC,{wrapperClassName:"w-full h-full grow",spinning:l,childStyle:{width:"100%",height:"100%",flexGrow:1},children:n?(0,r.jsx)("div",{children:(0,r.jsx)("pre",{className:"max-w-full overflow-auto whitespace-pre-wrap break-all text-[14px] leading-[22px]",ref:c})}):null})})},l=e=>{var{fileUrl:t}=e,[n,a]=(0,o.useState)(""),[l,d]=(0,o.useState)(!0);(0,o.useEffect)(()=>{fetch(t).then(e=>e.text()).then(e=>{d(!1),a(e)})},[t]);var c=(0,o.useRef)(null);return(0,o.useEffect)(()=>{function e(){return(e=(0,i._)(function*(){if(c.current){for(var e=0,t=n.length;esetTimeout(e,10)),c.current&&(c.current.textContent+=n.slice(5e4*e,(e+1)*5e4));c.current&&(c.current.textContent=n)}})).apply(this,arguments)}!function(){e.apply(this,arguments)}()},[n]),(0,r.jsx)("div",{className:"flex flex-col items-center w-full h-full flex-1 py-2 px-4",children:(0,r.jsx)(s.yC,{wrapperClassName:"w-full h-full grow",spinning:l,childStyle:{width:"100%",height:"100%",flexGrow:1},children:(0,r.jsx)("pre",{className:"max-w-full overflow-auto whitespace-pre-wrap break-all text-[14px] leading-[22px]",ref:c})})})},d=n("262941"),c=n("876945"),h=n("90265"),u=n("252237"),p=n.n(u),f=n("910656");n("107440"),n("887869"),d.GlobalWorkerOptions.workerSrc="//lf-cdn.coze.cn/obj/unpkg/pdfjs-dist/".concat(d.version,"/build/pdf.worker.min.mjs");var m={cMapUrl:"//lf-cdn.coze.cn/obj/unpkg/pdfjs-dist/".concat(d.version,"/cmaps/"),cMapPacked:!0},g=e=>{var t,n,{fileUrl:i}=e,[a,l]=(0,o.useState)(!0),[d,u]=(0,o.useState)(0),[g,v]=(0,o.useState)(0),b=(0,o.useRef)(null),y=(0,o.useRef)(null),[x,w]=(0,o.useState)(null===(t=b.current)||void 0===t?void 0:t.clientHeight),_=Math.floor((null!=x?x:500)+20),S=e=>{var{scrollOffset:t}=e;v(Math.floor(t/_))},[C,A]=(0,o.useState)(1),E=(0,o.useMemo)(()=>a?null:(0,r.jsx)(f.qj,{children:e=>{var{height:t,width:n}=e;return(0,r.jsx)(f.t7,{height:null!=t?t:0,itemCount:d,itemSize:_,width:null!=n?n:0,onScroll:S,ref:y,children:e=>{var t,{index:i,style:o}=e;return(0,r.jsx)("div",{style:o,children:(0,r.jsx)(c.Z,{pageNumber:i+1,className:p()("flex items-center justify-center !coz-bg-primary"),width:(null!=n?n:100)-32,scale:C,onLoadSuccess:e=>{w(e.height)},loading:(0,r.jsx)("div",{style:{height:null===(t=b.current)||void 0===t?void 0:t.clientHeight}})})},"page_".concat(i+1))}})}}),[a,d,x,C,_]);return{pdfNode:(0,r.jsx)(r.Fragment,{children:(0,r.jsxs)("div",{className:"flex flex-col items-center w-full h-full relative coz-bg-primary",children:[(0,r.jsx)("div",{className:p()("absolute top-0 left-0 right-0 bot-0 flex items-center justify-center h-full","z-10",!a&&"invisible"),children:(0,r.jsx)(s.yC,{})}),(0,r.jsx)("div",{className:p()("flex absolute top-0 left-0 right-0 overflow-auto px-5 w-full h-full justify-center",a&&"invisible"),ref:b,children:(0,r.jsx)(h.Z,{file:i,onLoadSuccess:e=>{var{numPages:t}=e;l(!1),u(t)},options:m,className:p()("flex w-full h-full"),loading:(0,r.jsx)(s.yC,{wrapperClassName:"w-full h-full",childStyle:{width:null===(n=b.current)||void 0===n?void 0:n.clientWidth,height:"100%"}}),children:b.current?E:null},i)})]})}),numPages:d,currentPage:g+1,onNext:()=>{if(g{if(g>0){var e,t=g-1;v(t),null===(e=y.current)||void 0===e||e.scrollToItem(t,"start")}},scale:C,increaseScale:()=>{A(e=>Math.min(e+.1,2))},decreaseScale:()=>{A(e=>Math.max(e-.1,.5))}}},v=n("336205"),b=n("873183"),y=n("728901");n("615739");var x=n("127139"),w=n("193604");n("541269");var _=n("808549"),S=n("602042"),C=n("675210"),A=n("120454"),E=n("628949"),k=n("335740"),T=e=>{var t,n,i=e.find(e=>-1===e.parent&&"title"===e.type);return i?[(0,A._)((0,_._)({},i),{id:null===(t=i.id)||void 0===t?void 0:t.toString(),parent:null===(n=i.parent)||void 0===n?void 0:n.toString(),children:M(i,e)})]:e.map(e=>{var t;return(0,A._)((0,_._)({},e),{id:e.id.toString(),parent:null===(t=e.parent)||void 0===t?void 0:t.toString(),children:[]})})},M=(e,t)=>{var n;return(null!==(n=e.children)&&void 0!==n?n:[]).reduce((e,n)=>{var i,r,o=t.find(e=>e.id===n);return o?[...e,(0,A._)((0,_._)({},o),{id:null===(i=o.id)||void 0===i?void 0:i.toString(),parent:null===(r=o.parent)||void 0===r?void 0:r.toString(),children:M(o,t)})]:[...e]},[])},D=e=>{var t=new Set,n=e=>{if(!!e&&!!e.id){var{children:i}=e;i&&i.length&&i.forEach(e=>{e&&e.id&&(t.add(e.id),n(e))})}};return n(e),t},O=(e,t)=>{var n=function(t){var n=i.findIndex(e=>e.id.toString()===t);if(-1===n)return"continue";var r=i[n],o=i.find(t=>t.id.toString()===e.parentID);if(!o)return{v:{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_02")}};var s=o.children.indexOf(r.id)e.id===r.parent);null==a||a.children.splice(a.children.indexOf(r.id),1),r.parent=o.id}o.children=o.children.filter(e=>e!==r.id),o.children.splice(s,0,r.id)};if(null===e.parentID)return{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_01")};var i=(0,k.Z)(t);for(var r of e.dragIDs){var o=n(r);if("object"===(0,E._)(o))return o.v}return{segments:i,errMsg:null}},I=(e,t)=>{var n=function(e){var t=i.findIndex(t=>t.id.toString()===e),n=i.find(e=>e.id===i[t].parent);n&&(n.children=n.children.filter(e=>e!==i[t].id)),i.splice(t,1)},i=(0,k.Z)(t);for(var r of e)n(r);return i},N=(e,t,n)=>{var i=function(e){var t,n=r.find(t=>t.id.toString()===e);if(!n)return{v:{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_04")}};var i=r.find(e=>e.id===n.parent);if(i&&(i.children=i.children.filter(e=>e!==n.id)),["table","image","title"].includes(null!==(t=null==n?void 0:n.type)&&void 0!==t?t:""))n.parent=o.id,o.children.push(n.id);else{o.text+=n.text;var s=r.findIndex(e=>e.id===n.id);-1!==s&&r.splice(s,1)}},r=(0,k.Z)(n),o=r.find(t=>t.id.toString()===e);if(!o||-1===o.parent&&"title"===o.type)return{segments:null,errMsg:v.o.t("knowledge_hierarchies_categories_03")};for(var s of(o.children=[],o.type="section-text",t)){var a=i(s);if("object"===(0,E._)(a))return a.v}return{segments:r,errMsg:null}},P=n("22916"),R=e=>{var{segments:t,setLevelSegments:n,setSelectionIDs:i,disabled:a}=e,[l,d]=(0,o.useState)(new Set),[c,h]=(0,o.useState)(new Set),{ref:u,width:f,height:m}=(0,C.Z)(),g=e=>{d(new Set([e.id])),h(D(e)),null==i||i([e.id,...D(e)])},{popoverNode:y,onContextMenu:x}=function(e){var t,n,{onDelete:i,onMerge:a}=e,[l,d]=(0,o.useState)(),[c,h]=(0,o.useState)(!1),[u,p]=(0,o.useState)({top:0,left:0}),f=(0,P.kF)();return{popoverNode:(0,r.jsx)(s.v2,{visible:c,onVisibleChange:h,onClickOutSide:()=>{h(!1),d(null)},trigger:"custom",position:"bottomLeft",render:(0,r.jsxs)(s.oU,{mode:"menu",children:[!l||(null===(t=l.children)||void 0===t?void 0:t.length)?null:(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(s.v2.Item,{isMenu:!0,onClick:()=>{i(l.data),h(!1)},children:v.o.t("knowledge_level_028")})}),l&&(null===(n=l.children)||void 0===n?void 0:n.length)?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.v2.Item,{isMenu:!0,onClick:()=>{a(l.data),h(!1)},children:v.o.t("knowledge_level_029")}),(0,r.jsx)(s.v2.Item,{isMenu:!0,onClick:()=>{i(l.data),h(!1)},children:v.o.t("knowledge_level_028")})]}):null]}),children:(0,r.jsx)("div",{style:{height:0,width:0,position:"fixed",top:u.top,left:u.left}})}),onContainerScroll:()=>{c&&h(!1)},onContextMenu:(e,t)=>{e.preventDefault(),d(t);var n=e.pageX,i=e.pageY,r=document.getElementById("coze-project:///knowledge/".concat(f.datasetID));if(r){var{left:o,top:s}=r.getBoundingClientRect();n-=o,i-=s}p({left:n,top:i}),h(!0)}}}({onMerge:e=>{var{segments:i,errMsg:r}=N(e.id,Array.from(D(e)),t);r&&s.FN.error(r),(null==i?void 0:i.length)&&(null==n||n(i))},onDelete:e=>{var i=I([e.id,...D(e)],t);null==n||n(i)}});return(0,r.jsxs)("div",{ref:u,className:"w-full h-full relative translate-z-0",children:[(0,r.jsx)(S.m,{data:T(t),disableDrag:a,disableDrop:a,onMove:e=>{var{dragIds:i,parentId:r,index:o}=e,{segments:a,errMsg:l}=O({dragIDs:i,parentID:r,dropIndex:o},t);l&&s.FN.error(l),(null==a?void 0:a.length)&&(null==n||n(a))},rowHeight:34,paddingTop:4,paddingBottom:4,width:f,height:m,renderCursor:L,children:e=>{var t,{node:n,style:i,dragHandle:o}=e,{isOpen:d,data:h}=n,u=!(null===(t=h.children)||void 0===t?void 0:t.length),f=(0,r.jsx)(s.hU,{size:"small",color:"secondary",icon:(0,r.jsx)(b.x5d,{className:p()(d&&"rotate-90","transition duration-150 ease-in-out")}),onClick:e=>{e.stopPropagation(),n.toggle()},className:p()("bg-transparent ml-[4px] shrink-0")});return(0,r.jsxs)("div",{className:p()("flex items-center gap-[4px]","h-[32px] py-[4px] pr-[8px] mb-[2px]","hover:coz-mg-primary cursor-pointer","transition duration-150 ease-in-out","rounded-[8px]",(l.has(h.id)||c.has(h.id))&&"coz-mg-primary"),onClick:()=>{g(h)},onContextMenu:e=>{if(!a)x(e,n)},style:i,ref:o,children:[u?(0,r.jsx)("span",{className:"w-6 ml-[4px] shrink-0"}):f,(0,r.jsx)("span",{className:p()("text-[14px] leading-[20px] coz-fg-primary truncate"),children:"image"!==h.type?h.text.slice(0,50):v.o.t("knowledge_level_110")})]})}}),y]})},L=e=>{var{top:t,left:n,indent:i}=e;return(0,r.jsx)("div",{style:(0,_._)({},{display:"flex",alignItems:"center",zIndex:1},{position:"absolute",pointerEvents:"none",top:"".concat(t-2,"px"),left:"".concat(n,"px"),right:"".concat(i,"px")}),children:(0,r.jsx)("div",{className:p()("flex-1 h-[2px] coz-mg-hglt-plus")})})},j=e=>{var{id:t,onClick:n,title:i,selected:o,tag:a,label:l}=e;return(0,r.jsx)("div",{className:p()("w-full h-8 px-2 py-[6px] rounded-[8px] hover:coz-mg-primary cursor-pointer","flex items-center",o&&"coz-mg-primary"),onClick:()=>null==n?void 0:n(t),children:l?(0,r.jsx)("div",{className:"w-full",children:l}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(s.ZT.Text,{ellipsis:{showTooltip:!0},className:"w-full coz-fg-primary text-[14px] leading-[20px] grow truncate",children:i}),(0,r.jsx)("div",{className:"flex items-center shrink-0",children:a})]})})},F=e=>{var{isSearchable:t,list:n,onClick:i,selectedID:a,levelSegments:l,setLevelSegments:d,setSelectionIDs:c,treeDisabled:h,treeVisible:u}=e,[f,m]=(0,o.useState)("");return(0,r.jsxs)("div",{className:"flex flex-col grow w-full h-full",children:[t?(0,r.jsx)(s.ol,{value:f,placeholder:v.o.t("datasets_placeholder_search"),onChange:m}):null,(0,r.jsx)("div",{className:"pl-2 h-6 mt-4 mb-1 flex items-center",children:(0,r.jsx)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-4 shrink-0",children:v.o.t("knowledge_level_012")})}),(0,r.jsxs)("div",{className:"flex flex-col grow w-full",children:[(0,r.jsx)("div",{className:"flex flex-col gap-1 h-[150px] grow !overflow-auto shrink-0",children:n.filter(e=>e.title.includes(f)).map(e=>""!==e.id?(0,r.jsx)(j,{id:e.id,selected:e.id===a,onClick:i,title:e.title,tag:e.tag,label:e.label},e.id):null)}),(null==l?void 0:l.length)&&u?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-4 flex justify-center items-center px-[8px] mb-[8px]",children:(0,r.jsx)("div",{className:p()("border border-solid border-[0.5px] transition w-full","coz-stroke-primary")})}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 !overflow-auto",children:[(0,r.jsxs)("div",{className:"w-full pl-2 h-6 items-center flex gap-[4px]",children:[(0,r.jsx)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-4 shrink-0",children:v.o.t("knowledge_level_adjust")}),h?null:(0,r.jsx)(s.u,{style:{maxWidth:602},position:"left",content:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"coz-fg-plus text-[14px] font-[500] leading-[20px] mb-3",children:v.o.t("knowledge_hierarchies_categories")}),(0,r.jsxs)("div",{className:"flex gap-2",children:[(0,r.jsxs)("div",{className:"flex flex-col gap-1 justify-between w-[182px]",children:[(0,r.jsx)("span",{className:"coz-fg-primary text-[12px] leading-[16px] font-[400]",children:v.o.t("level_999")}),(0,r.jsx)("img",{src:x,className:"w-[182px]"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 justify-between w-[182px]",children:[(0,r.jsx)("span",{className:"coz-fg-primary text-[12px] leading-[16px] font-[400]",children:v.o.t("level_998")}),(0,r.jsx)("img",{src:y,className:"w-[182px]"})]}),(0,r.jsxs)("div",{className:"flex flex-col gap-1 justify-between w-[182px]",children:[(0,r.jsx)("span",{className:"coz-fg-primary text-[12px] leading-[16px] font-[400]",children:v.o.t("level_997")}),(0,r.jsx)("img",{src:w,className:"w-[182px]"})]})]})]}),children:(0,r.jsx)(b.L03,{className:"coz-fg-secondary"})})]}),(0,r.jsx)("div",{className:"h-[360px]",children:(0,r.jsx)(R,{segments:l,setLevelSegments:d,setSelectionIDs:c,disabled:h})})]})]}):null]})]})};n("461654"),n("136710"),n("347852"),n("601142")},788911:function(e,t,n){n.d(t,{OR:function(){return s},YB:function(){return o}});var i=n(455069),r=n(917085),o=(0,r.Z)(),s=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];(0,i.useEffect)(()=>(o.on(e,t),()=>{o.off(e,t)}),n)}},272661:function(e,t,n){n.d(t,{L:function(){return r}});var i=n(304194),r=e=>new i.j({name:e})},836511:function(e,t,n){n.d(t,{IF:()=>S,E1:()=>E});var i,r=n("151064"),o=n("455069"),s=n("336205"),a=n("659596"),l=n("825955"),d=n("745474"),c=n("458620"),h=n("727914"),u=n("178385"),p=n("382534"),f=e=>0x1400000>e,m=e=>new Promise((t,n)=>{var i=new FileReader;i.onload=e=>{var i,r=null===(i=e.target)||void 0===i?void 0:i.result;if(!r||"string"!=typeof r){n(new h.sH("getBase64","file read invalid"));return}t(r.replace(/^.*?,/,""))},i.onerror=()=>{a.FN.error(s.o.t("read_file_failed_please_retry")),n(new h.sH("getBase64","file read fail"))},i.onabort=()=>{n(new h.sH("getBase64","file read abort"))},i.readAsDataURL(e)}),g=e=>{var t=e.lastIndexOf(".");return e.slice(t+1)},v=e=>{var{customRequest:t,children:n}=e;return(0,r.jsx)(a.gq,{accept:"image/*",maxSize:20480,fileList:[],customRequest:t,onChange:e=>{var t,{currentFile:n}=e;if(n){;!f((null==n?void 0:null===(t=n.fileInstance)||void 0===t?void 0:t.size)||0)&&a.FN.error(s.o.t("knowledge_insert_img_013"))}},children:n})};var b=(i=(0,l._)(function*(e){var{object:t,options:n}=e,{onSuccess:i,onProgress:r,file:o}=t,{onFinish:s,onFinally:a,onBeforeUpload:l}=n;if("string"!=typeof o)try{null==l||l();var{name:f,fileInstance:v}=o;if(v){var b=g(f),y=yield m(v),x=yield p.nA.UploadFile({file_head:{file_type:b,biz_type:u.ym.BIZ_BOT_DATASET},data:y},{onUploadProgress:e=>{var t;r({total:null!==(t=e.total)&&void 0!==t?t:v.size,loaded:e.loaded})}});i(x.data),x.data&&(null==s||s({url:x.data.upload_url,tosKey:x.data.upload_uri}))}else d.s5.errorEvent(d.xW.KNOWLEDGE,{eventName:c.b.KnowledgeUploadFile,error:new h.sH(c.b.KnowledgeUploadFile,"".concat(c.b.KnowledgeUploadFile,": Failed to upload image"))})}catch(e){d.s5.errorEvent(d.xW.KNOWLEDGE,{eventName:c.b.KnowledgeUploadFile,error:e})}finally{null==a||a()}}),function(e){return i.apply(this,arguments)}),y=e=>{var{editor:t,disabled:n,showTooltip:i,renderUI:l}=e,d=i?a.u:o.Fragment;return(0,r.jsx)(v,{customRequest:e=>{if(!t)return;var{fileInstance:n}=e;if(!!n)return b({object:e,options:{onFinish:e=>{e.url&&t&&t.chain().focus().setImage({src:e.url}).run()}}})},children:(0,r.jsx)(d,{content:s.o.t("knowledge_insert_img_002"),clickToHide:!0,autoAdjustOverflow:!0,children:l({disabled:n,showTooltip:i})})})},x=n("808549"),w=n("120454"),_=n("873183"),S=e=>(0,r.jsx)(y,(0,w._)((0,x._)({},e),{renderUI:e=>{var{disabled:t}=e;return(0,r.jsx)(a.zx,{disabled:t,color:"primary",className:"coz-fg-primary leading-none",icon:(0,r.jsx)(_.Q2$,{className:"text-[14px]"}),children:s.o.t("knowledge_insert_img_002")})}})),C=n("252237"),A=n.n(C),E=e=>(0,r.jsx)(y,(0,w._)((0,x._)({},e),{renderUI:e=>{var{disabled:t}=e;return(0,r.jsx)(a.v2.Item,{disabled:t,icon:(0,r.jsx)(_.Q2$,{className:A()("w-3.5 h-3.5",{"opacity-30":t})}),className:A()("h-8 p-2 text-xs rounded-lg",{"cursor-not-allowed":t}),children:s.o.t("knowledge_insert_img_002")})}}))},461654:function(e,t,n){n.d(t,{R:()=>g});var i=n("151064"),r=n("455069"),o=n("252237"),s=n.n(o),a=n("707291"),l=n("819195"),d=n("636436"),c=n("373025"),h=n("17236"),u=e=>{var{editorRef:t,exclude:n,onExitEditMode:i}=e;(0,r.useEffect)(()=>{var e=e=>{t.current&&!t.current.contains(e.target)&&!(null==n?void 0:n.some(t=>{var n;return null===(n=t.current)||void 0===n?void 0:n.contains(e.target)}))&&(null==i||i())};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}},[t,n,i])},p=n("542284"),f=n("659596"),m=e=>{var{editorActionRegistry:t,readonly:n,contextMenuRef:r,x:o,y:a,editor:l}=e;return n?null:(0,i.jsx)("div",{ref:r,className:"absolute bg-white shadow-lg rounded-md py-1 z-50",style:{top:"".concat(a,"px"),left:"".concat(o,"px")},children:(0,i.jsx)(f.v2,{visible:!0,clickToHide:!0,keepDOM:!0,position:"bottomLeft",spacing:-4,trigger:"custom",getPopupContainer:()=>{var e;return null!==(e=r.current)&&void 0!==e?e:document.body},className:s()("coz-shadow-large"),render:(0,i.jsx)(f.v2.SubMenu,{className:s()("p-1"),mode:"menu",children:t.entries().map(e=>{var[t,{Component:n}]=e;return(0,i.jsx)(n,{editor:l},t)})})})})},g=e=>{var{editor:t,placeholder:n,editorContextMenuItemsRegistry:o,editorBottomSlot:f,onBlur:g}=e,v=(0,r.useRef)(null),b=(0,r.useRef)(null),{contextMenuPosition:y,openContextMenu:x}=(0,p.H)({contextMenuRef:b});return(u({editorRef:v,exclude:[b],onExitEditMode:()=>{var e=(0,l.k)(t);null==g||g(e)}}),t)?(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsx)("div",{ref:v,className:s()("relative","mb-2 p-2","text-sm leading-5","coz-fg-primary coz-bg-max","border border-solid coz-stroke-hglt rounded-lg"),onContextMenu:x,children:(0,i.jsxs)("div",{className:s()((0,c.X)(),(0,h.X)(),(0,d.I)()),children:[(0,i.jsx)(a.kg,{editor:t,placeholder:n}),f]})}),y&&o?(0,i.jsx)(m,{x:y.x,y:y.y,contextMenuRef:b,editor:t,editorActionRegistry:o}):null]}):null}},398412:function(e,t,n){n.d(t,{y:function(){return c}});var i=n(151064);n(455069);var r=n(385038),o=n(336205),s=n(873183),a=n(659596),l=n(95196),d=n(788911),c=e=>{var{chunk:t,chunks:n,disabled:c}=e,{addEmptyChunkAfter:h}=(0,l.i)({chunks:n||[],onChunksChange:e=>{var{newChunk:n,chunks:i}=e;d.YB.emit("hoverEditBarAction",{type:"add-after",targetChunk:t,chunks:i,newChunk:n})}});return(0,i.jsx)(a.u,{content:o.o.t("knowledge_optimize_016"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(a.hU,{"data-dtestid":"".concat(r.w.SegmentDetailContentItemAddBottomIcon,".").concat(t.text_knowledge_editor_chunk_uuid),size:"small",color:"secondary",disabled:c,icon:(0,i.jsx)(s.BPm,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>h(t)})})}},179231:function(e,t,n){n.d(t,{$:function(){return c}});var i=n(151064);n(455069);var r=n(385038),o=n(336205),s=n(873183),a=n(659596),l=n(95196),d=n(788911),c=e=>{var{chunk:t,chunks:n=[],disabled:c}=e,{addEmptyChunkBefore:h}=(0,l.i)({chunks:n,onChunksChange:e=>{var{newChunk:n,chunks:i}=e;d.YB.emit("hoverEditBarAction",{type:"add-before",targetChunk:t,chunks:i,newChunk:n})}});return(0,i.jsx)(a.u,{content:o.o.t("knowledge_optimize_017"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(a.hU,{"data-dtestid":"".concat(r.w.SegmentDetailContentItemAddTopIcon,".").concat(t.text_knowledge_editor_chunk_uuid),size:"small",color:"secondary",disabled:c,icon:(0,i.jsx)(s.wu0,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>h(t)})})}},876143:function(e,t,n){n.d(t,{s:function(){return d}});var i=n(151064);n(455069);var r=n(336205),o=n(873183),s=n(659596),a=n(95196),l=n(788911),d=e=>{var{chunk:t,chunks:n=[],disabled:d}=e,{deleteChunk:c}=(0,a.S)({chunks:n,onChunksChange:e=>{var{chunks:n}=e;l.YB.emit("hoverEditBarAction",{type:"delete",targetChunk:t,chunks:n})}});return(0,i.jsx)(s.u,{content:r.o.t("knowledge_level_028"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(s.hU,{size:"small",color:"secondary",disabled:d,icon:(0,i.jsx)(o.dVD,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>c(t)})})}},476350:function(e,t,n){n.d(t,{i:function(){return d}});var i=n(151064);n(455069);var r=n(385038),o=n(336205),s=n(873183),a=n(659596),l=n(788911),d=e=>{var{chunk:t,disabled:n}=e;return(0,i.jsx)(a.u,{content:o.o.t("datasets_segment_edit"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(a.hU,{"data-dtestid":"".concat(r.w.SegmentDetailContentItemEditIcon,".").concat(t.text_knowledge_editor_chunk_uuid),size:"small",color:"secondary",disabled:n,icon:(0,i.jsx)(s.JAz,{className:"text-[14px]"}),iconPosition:"left",className:"coz-fg-secondary leading-none !w-6 !h-6",onClick:()=>{l.YB.emit("hoverEditBarAction",{type:"edit",targetChunk:t})}})})}},144416:function(e,t,n){n.d(t,{H:function(){return r}});var i=n(304194),r=e=>new i.j({name:e})},642158:function(e,t,n){n.d(t,{o:function(){return c}});var i=n(151064);n(455069);var r=n(252237),o=n.n(r),s=n(336205),a=n(873183),l=n(659596),d=n(757208),c=e=>{var{chunk:t,chunks:n,disabled:r,hoverEditBarActionsRegistry:c,onChunksChange:h}=e,u=t.status===d.OL.AuditFailed;return c?(0,i.jsxs)("div",{className:"absolute top-[2px] right-[2px] flex z-10",children:[r?null:(0,i.jsx)("div",{className:o()("p-1 coz-bg-plus rounded-lg","coz-shadow-default"),children:(0,i.jsx)(l.T,{spacing:3,children:c.entries().map(e=>{var[r,{Component:o}]=e;return(0,i.jsx)(o,{chunk:t,chunks:n,onChunksChange:h},r)})})}),u?(0,i.jsx)("div",{className:o()("p-1 coz-bg-plus rounded-lg","coz-shadow-default","ml-1"),children:(0,i.jsx)(l.u,{content:s.o.t("community_This_is_a_toast_Machine_review_failed"),clickToHide:!0,autoAdjustOverflow:!0,children:(0,i.jsx)(l.hU,{icon:(0,i.jsx)(a.L03,{className:"text-[14px] coz-fg-hglt-red"}),size:"small",color:"secondary",className:"coz-fg-secondary leading-none !w-6 !h-6"})})}):null]}):null}},202147:function(e,t,n){n.d(t,{s:function(){return h}});var i=n(151064);n(455069);var r=n(252237),o=n.n(r),s=n(336205),a=n(873183),l=n(659596),d=n(95196),c=n(788911),h=e=>{let t,n;var{chunk:r,chunks:h=[],disabled:u}=e,{deleteChunk:p}=(0,d.S)({chunks:h,onChunksChange:e=>{var{chunks:t}=e;c.YB.emit("previewContextMenuItemAction",{type:"delete",targetChunk:r,chunks:t})}});return(0,i.jsx)(l.v2.Item,{disabled:u,icon:(0,i.jsx)(a.dVD,{className:(t=!!u,o()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>p(r),className:(n=!!u,o()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:s.o.t("Delete")})}},71132:function(e,t,n){n.d(t,{i:function(){return c}});var i=n(151064);n(455069);var r=n(252237),o=n.n(r),s=n(336205),a=n(873183),l=n(659596),d=n(788911),c=e=>{let t,n;var{chunk:r,disabled:c}=e;return(0,i.jsx)(l.v2.Item,{disabled:c,icon:(0,i.jsx)(a.JAz,{className:(t=!!c,o()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>{d.YB.emit("previewContextMenuItemAction",{type:"edit",targetChunk:r})},className:(n=!!c,o()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:s.o.t("Edit")})}},577487:function(e,t,n){n.d(t,{C:function(){return r}});var i=n(304194),r=e=>new i.j({name:e})},136710:function(e,t,n){n.d(t,{i:()=>y});var i=n("151064"),r=n("455069"),o=n("252237"),s=n.n(o),a=()=>{var[e,t]=(0,r.useState)(null);return{hoveredChunk:e,handleMouseEnter:e=>{t(e)},handleMouseLeave:()=>{t(null)}}},l=n("542284"),d=n("472891"),c=n.n(d),h=n("976482"),u=n("636436"),p=n("373025"),f=n("17236"),m=e=>{var t,n,{chunk:r,locateId:o}=e;return(0,i.jsx)("div",{id:o,className:s()("relative","mb-2 p-2","text-sm leading-5","coz-fg-primary hover:coz-mg-hglt-secondary-hovered coz-mg-secondary","border border-solid coz-stroke-primary rounded-lg",(0,p.X)(),(0,f.X)(),(0,u.I)()),children:(0,i.jsx)("p",{dangerouslySetInnerHTML:{__html:null!==(n=c().sanitize((0,h.F)(null!==(t=r.content)&&void 0!==t?t:""),{FORBID_TAGS:["style"]}))&&void 0!==n?n:""}})})},g=n("659596"),v=e=>{var{previewContextMenuItemsRegistry:t,chunk:n,chunks:r,readonly:o,contextMenuRef:a,x:l,y:d}=e;return o?null:(0,i.jsx)("div",{ref:a,className:"absolute bg-white shadow-lg rounded-md py-1 z-50",style:{top:"".concat(d,"px"),left:"".concat(l,"px")},children:(0,i.jsx)(g.v2,{visible:!0,position:"bottomLeft",spacing:-4,trigger:"custom",getPopupContainer:()=>{var e;return null!==(e=a.current)&&void 0!==e?e:document.body},className:s()("rounded-lg"),render:(0,i.jsx)(g.v2.SubMenu,{className:s()("w-40 p-1"),mode:"menu",children:t.entries().map(e=>{var[t,{Component:o}]=e;return(0,i.jsx)(o,{chunk:n,chunks:r},t)})})})})},b=n("642158"),y=r.memo(e=>{var{chunk:t,chunks:n,readonly:o=!1,locateId:d,onActivateEditMode:c,hoverEditBarActionsRegistry:h,previewContextMenuItemsRegistry:u}=e,p=(0,r.useRef)(null),{hoveredChunk:f,handleMouseEnter:g,handleMouseLeave:y}=a(),{contextMenuPosition:x,openContextMenu:w}=(0,l.H)({contextMenuRef:p});return(0,i.jsxs)("div",{className:"relative",children:[(0,i.jsxs)("div",{className:s()("relative overflow-hidden"),onContextMenu:o?void 0:e=>w(e),onMouseEnter:o?void 0:()=>g(t.text_knowledge_editor_chunk_uuid),onMouseLeave:o?void 0:y,onDoubleClick:o?void 0:()=>null==c?void 0:c(t),children:[f!==t.text_knowledge_editor_chunk_uuid||o?null:(0,i.jsx)(b.o,{chunk:t,chunks:n,hoverEditBarActionsRegistry:h}),(0,i.jsx)(m,{chunk:t,locateId:d||""})]}),x?(0,i.jsx)(v,{previewContextMenuItemsRegistry:u,x:x.x,y:x.y,chunk:t,chunks:n,readonly:o,contextMenuRef:p}):null]})},(e,t)=>e.chunk.content===t.chunk.content&&!0)},542284:function(e,t,n){n.d(t,{H:function(){return r}});var i=n(455069),r=e=>{var{contextMenuRef:t}=e,[n,r]=(0,i.useState)(null),o=()=>{r(null)};return(0,i.useEffect)(()=>{var e=e=>{t.current&&!t.current.contains(e.target)&&o()};return window.addEventListener("mousedown",e),()=>{window.removeEventListener("mousedown",e)}},[]),{contextMenuPosition:n,openContextMenu:e=>{e.preventDefault();var t=e.currentTarget.getBoundingClientRect();r({x:e.clientX-t.left,y:e.clientY-t.top})},closeContextMenu:o}}},195523:function(e,t,n){n.d(t,{z:function(){return a}});var i=n(825955),r=n(735114),o=n(727914),s=n(382534),a=()=>{var e,{runAsync:t}=(0,r.Z)((e=(0,i._)(function*(e){if(!e)throw new o.sH("normal_error","missing slice_id");yield s.MJ.DeleteSlice({slice_ids:[e]})}),function(t){return e.apply(this,arguments)}),{manual:!0});return{deleteSlice:t}}},95196:function(e,t,n){n.d(t,{S:()=>a,i:()=>o});var i=n("455069"),r=n("68851"),o=e=>{var{chunks:t,onChunksChange:n}=e,o=(0,i.useRef)(t);return(0,i.useEffect)(()=>{o.current=t},[t]),{addEmptyChunkAfter:e=>{var t,i,s=o.current,a=s.findIndex(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid);if(-1!==a){var l=null!==(i=null===(t=s.find(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid))||void 0===t?void 0:t.sequence)&&void 0!==i?i:"1",d=(0,r.k8)({sequence:String(Number(l)+1)}),c=[...s.slice(0,a+1),d,...s.slice(a+1)];null==n||n({newChunk:d,chunks:c})}},addEmptyChunkBefore:e=>{var t,i,s=o.current,a=s.findIndex(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid),l=null!==(i=null===(t=s.find(t=>t.text_knowledge_editor_chunk_uuid===e.text_knowledge_editor_chunk_uuid))||void 0===t?void 0:t.sequence)&&void 0!==i?i:"1";if(-1!==a){var d=(0,r.k8)({sequence:l}),c=[...s.slice(0,a),d,...s.slice(a)];null==n||n({newChunk:d,chunks:c})}}}},s=n("195523"),a=e=>{var{chunks:t,onChunksChange:n}=e,r=(0,i.useRef)(t),{deleteSlice:o}=(0,s.z)();return(0,i.useEffect)(()=>{r.current=t},[t]),{deleteChunk:(0,i.useCallback)(e=>{var t=r.current.filter(t=>t.text_knowledge_editor_chunk_uuid!==e.text_knowledge_editor_chunk_uuid);if(!!e.slice_id)o(e.slice_id).then(()=>{null==n||n({chunks:t,targetChunk:e})})},[n,o])}}},916853:function(e,t,n){n.d(t,{n:function(){return m}});var i=n(808549),r=n(120454),o=n(455069),s=n(724830),a=n(707291),l=n(76049),d=n(357962),c=n(778681),h=n(481265),u=n(550745),p=n(976482),f=n(819195),m=e=>{var{chunk:t,editorProps:n,onChange:m}=e,g=(0,a.jE)({extensions:[s.Z.configure({hardBreak:{keepMarks:!1},paragraph:{HTMLAttributes:{class:"text-knowledge-tiptap-editor-paragraph"}}}),h.ZP.configure({resizable:!0}),l.Z,c.Z,d.Z,u.ZP.configure({inline:!1,allowBase64:!0})],content:(0,p.F)((null==t?void 0:t.content)||""),parseOptions:{preserveWhitespace:"full"},onUpdate:e=>{var{editor:n}=e;if(!!t&&!!n){var o=(0,f.k)(n);null==m||m((0,r._)((0,i._)({},t),{content:o}))}},editorProps:(0,r._)((0,i._)({},n),{handlePaste(e,t,n){if(!g)return!1;var i,r=null===(i=t.clipboardData)||void 0===i?void 0:i.getData("text/plain");if(null==r?void 0:r.includes("\n")){t.preventDefault();var o=(0,p.F)(r);return g.chain().focus().insertContent(o).run(),!0}return!1}})});return(0,o.useEffect)(()=>{if(!!g&&!!t){var e=(0,p.F)(t.content||"");g.commands.setContent(e||"",!1,{preserveWhitespace:"full"})}},[t,g]),{editor:g}}},149951:function(e,t,n){n.d(t,{B:()=>x});var i=n("825955"),r=n("659596"),o=n("987633"),s=(e,t)=>{var n,i;return(0,o.PJ)(null!==(i=t.content)&&void 0!==i?i:"")!==(null===(n=e.find(e=>e.slice_id===t.slice_id))||void 0===n?void 0:n.content)},a=n("68851"),l=n("735114"),d=n("727914"),c=n("382534"),h=()=>{var e,{runAsync:t,loading:n}=(0,l.Z)((e=(0,i._)(function*(e,t){if(!e)throw new d.sH("normal_error","missing slice_id");return yield c.MJ.UpdateSlice({slice_id:e,raw_text:t}),t}),function(t,n){return e.apply(this,arguments)}),{manual:!0});return{updateSlice:t,updateLoading:n}},u=e=>{var t,{chunks:n,onChunksChange:o,onUpdateChunk:l}=e,{updateSlice:d}=h();return{updateRemoteChunk:(t=(0,i._)(function*(e){if(!e.slice_id){r.FN.error("The slice ID does not exist. Please refresh the page");return}if(!s(n,e)){null==o||o(n);return}yield d(e.slice_id,null!==(t=e.content)&&void 0!==t?t:"");var t,i=(0,a.PU)(n,e);null==l||l(e),null==o||o(i)}),function(e){return t.apply(this,arguments)})}},p=n("195523"),f=e=>{var t,{chunks:n,onChunksChange:r,onDeleteChunk:o}=e,{deleteSlice:s}=(0,p.z)();return{deleteRemoteChunk:(t=(0,i._)(function*(e){if(!!e.slice_id){yield s(e.slice_id);var t=(0,a.Qe)(n,e.slice_id);null==r||r(t),null==o||o(e)}}),function(e){return t.apply(this,arguments)})}},m=e=>{var{chunks:t,onChunksChange:n}=e;return{deleteLocalChunk:e=>{if(!!e.local_slice_id){var i=(0,a.wL)(t,e.local_slice_id);null==n||n(i)}}}},g=n("745474"),v=n("458620"),b=e=>{var t,{documentId:n}=e;var{runAsync:r}=(0,l.Z)((t=(0,i._)(function*(e){var t,{content:i,sequence:r}=e;if(!n)throw new d.sH("normal_error","missing doc_id");var o=yield c.MJ.CreateSlice({document_id:n,raw_text:i,sequence:r});return(0,a.bc)({slice_id:null!==(t=null==o?void 0:o.slice_id)&&void 0!==t?t:"",sequence:r,content:i})}),function(e){return t.apply(this,arguments)}),{manual:!0,onError:e=>{g.s5.errorEvent(g.xW.KNOWLEDGE,{eventName:v.b.KnowledgeCreateSlice,error:e})}});return{createChunk:r}},y=e=>{var t,{chunks:n,documentId:r,onChunksChange:o,onAddChunk:s}=e,{createChunk:l}=b({documentId:r});return{createLocalChunk:(t=(0,i._)(function*(e){if(!!e.local_slice_id){var t,i,r=yield l({content:null!==(t=e.content)&&void 0!==t?t:"",sequence:null!==(i=e.sequence)&&void 0!==i?i:"1"}),d=(0,a.Gf)({chunks:n,localChunkSliceId:e.local_slice_id,newChunk:r});null==s||s(r),null==o||o(d)}}),function(e){return t.apply(this,arguments)})}},x=e=>{var t,n,r,{chunks:o,documentId:s,onAddChunk:a,onUpdateChunk:l,onChunksChange:d,onDeleteChunk:c}=e,{createLocalChunk:h}=y({chunks:o,documentId:s,onChunksChange:d,onAddChunk:a}),{updateRemoteChunk:p}=u({chunks:o,onChunksChange:d,onUpdateChunk:l}),{deleteLocalChunk:g}=m({chunks:o,onChunksChange:d}),{deleteRemoteChunk:v}=f({chunks:o,onChunksChange:d,onDeleteChunk:c});var b=(t=(0,i._)(function*(e){if(""===e.content){yield v(e);return}yield p(e)}),function(e){return t.apply(this,arguments)});var x=(n=(0,i._)(function*(e){""===e.content?g(e):yield h(e)}),function(e){return n.apply(this,arguments)});return{saveChunk:(r=(0,i._)(function*(e){if(!e.local_slice_id){yield b(e);return}yield x(e)}),function(e){return r.apply(this,arguments)})}}},523652:function(e,t,n){n.d(t,{R_:()=>i.R,go:()=>s,pR:()=>a.p,UF:()=>l.U,nR:()=>r.n});var i=n("461654");n("136710"),n("149951");var r=n("916853"),o=n("151064"),s=e=>{var{editor:t,actionRegistry:n}=e;return(0,o.jsx)("div",{className:"h-[32px] box-content px-2 pt-2",children:n.entries().map(e=>{var[n,{Component:i}]=e;return(0,o.jsx)(i,{editor:t},n)})})},a=n("347852"),l=n("601142");n("642158"),n("476350"),n("876143"),n("179231"),n("398412"),n("144416"),n("788911")},789662:function(e,t,n){n.d(t,{p:function(){return s}});var i,r=n(836511),o=n(272661);var s=((i=(0,o.L)("editor-context-actions")).registerSome([{type:"upload-image",module:{Component:r.E1}}]),i)},601142:function(e,t,n){n.d(t,{U:()=>N});var i,r,o=n("808549"),s=n("120454"),a=n("151064"),l=n("455069"),d=n("149951"),c=n("916853"),h=n("788911"),u=n("136710"),p=n("461654"),f=n("577487"),m=n("71132"),g=n("202147"),v=n("252237"),b=n.n(v),y=n("336205"),x=n("873183"),w=n("659596"),_=n("95196"),S=e=>{let t,n;var{chunk:i,chunks:r=[],disabled:o}=e,{addEmptyChunkBefore:s}=(0,_.i)({chunks:r,onChunksChange:e=>{var{newChunk:t,chunks:n}=e;h.YB.emit("previewContextMenuItemAction",{type:"add-before",targetChunk:i,newChunk:t,chunks:n})}});return(0,a.jsx)(w.v2.Item,{disabled:o,icon:(0,a.jsx)(x.wu0,{className:(t=!!o,b()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>s(i),className:(n=!!o,b()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:y.o.t("knowledge_optimize_017")})},C=e=>{let t,n;var{chunk:i,chunks:r=[],disabled:o}=e,{addEmptyChunkAfter:s}=(0,_.i)({chunks:r,onChunksChange:e=>{var{newChunk:t,chunks:n}=e;h.YB.emit("previewContextMenuItemAction",{type:"add-after",newChunk:t,targetChunk:i,chunks:n})}});return(0,a.jsx)(w.v2.Item,{disabled:o,icon:(0,a.jsx)(x.BPm,{className:(t=!!o,b()("w-3.5 h-3.5",{"opacity-30":t}))}),onClick:()=>s(i),className:(n=!!o,b()("h-8 px-2 py-2 text-xs rounded-lg",{"cursor-not-allowed":n})),children:y.o.t("knowledge_optimize_016")})};var A=((i=(0,f.C)("preview-context-menu-items")).registerSome([{type:"edit",module:{Component:m.i}},{type:"add-before",module:{Component:S}},{type:"add-after",module:{Component:C}},{type:"delete",module:{Component:g.s}}]),i),E=n("144416"),k=n("476350"),T=n("876143"),M=n("179231"),D=n("398412");var O=((r=(0,E.H)("hover-edit-bar-actions")).registerSome([{type:"edit",module:{Component:k.i}},{type:"add-before",module:{Component:M.$}},{type:"add-after",module:{Component:D.y}},{type:"delete",module:{Component:T.s}}]),r),I=n("789662"),N=e=>{var{chunks:t,documentId:n,readonly:i=!1,onChange:r,onAddChunk:f,onDeleteChunk:m}=e,[g,v]=(0,l.useState)(t),[b,y]=(0,l.useState)(null),{editor:x}=(0,c.n)({chunk:b}),{saveChunk:w}=(0,d.B)({chunks:g,documentId:n,onChunksChange:e=>{null==r||r(e),y(null)},onAddChunk:f,onDeleteChunk:m});return(0,h.OR)("previewContextMenuItemAction",(0,l.useCallback)(e=>{var{type:t,newChunk:n,chunks:i,targetChunk:o}=e;"add-after"===t&&(n&&y(n),i&&v(i)),"add-before"===t&&(n&&y(n),i&&v(i)),"delete"===t&&(null==m||m(o),i&&(null==r||r(i))),"edit"===t&&y(o)},[m,r])),(0,h.OR)("hoverEditBarAction",(0,l.useCallback)(e=>{var{type:t,targetChunk:n,chunks:i,newChunk:o}=e;"add-after"===t&&(o&&y(o),i&&v(i)),"add-before"===t&&(o&&y(o),i&&v(i)),"delete"===t&&(null==m||m(n),i&&(null==r||r(i))),"edit"===t&&y(n)},[m,r])),(0,l.useEffect)(()=>{v(t)},[t]),(0,a.jsx)(a.Fragment,{children:g.map(e=>(0,a.jsx)("div",{children:e.text_knowledge_editor_chunk_uuid===(null==b?void 0:b.text_knowledge_editor_chunk_uuid)&&b?(0,a.jsx)(p.R,{editor:x,editorContextMenuItemsRegistry:I.p,onBlur:e=>{w((0,s._)((0,o._)({},b),{content:e}))}}):(0,a.jsx)(u.i,{chunk:e,chunks:g,readonly:i,onActivateEditMode:y,hoverEditBarActionsRegistry:O,previewContextMenuItemsRegistry:A})},e.text_knowledge_editor_chunk_uuid))})}},347852:function(e,t,n){n.d(t,{p:()=>L,D:()=>A});var i,r,o=n("151064"),s=n("455069"),a=n("987633"),l=n("149951"),d=n("916853"),c=n("788911"),h=n("252237"),u=n.n(h),p=e=>{var{title:t,id:n}=e;return(0,o.jsx)("div",{id:n,className:u()("w-full text-[14px] font-[500] leading-[20px] coz-fg-plus"),children:t})},f=n("472891"),m=n.n(f),g=e=>{var{base64:t,htmlText:n,link:i,caption:r,locateId:s,selected:a}=e;return(0,o.jsxs)("div",{id:s,className:u()("flex items-center flex-col gap-2","w-full p-2 coz-mg-secondary","border border-solid coz-stroke-primary rounded-[8px]",a&&"!coz-mg-hglt"),children:[t?(0,o.jsx)("img",{src:"data:image/jpeg;base64, ".concat(t),className:"w-full h-full"}):null,n?(0,o.jsx)("div",{className:"w-full h-full overflow-auto [&>*]:w-full [&>*]:h-full",dangerouslySetInnerHTML:{__html:m().sanitize(n)}}):null,i?(0,o.jsx)("div",{className:"coz-fg-primary text-[14px] leading-[20px] font-[400] break-all",children:i}):null,r?(0,o.jsx)("div",{className:"coz-fg-primary text-[14px] leading-[20px] font-[400] break-all",children:r}):null]})},v=n("789662"),b=n("136710"),y=n("461654"),x=e=>"segment-".concat(e),w=n("808549"),_=n("120454"),S=e=>{var t,n,i=e.find(e=>-1===e.parent&&"title"===e.type);return i?[(0,_._)((0,w._)({},i),{text:null!==(n=i.content)&&void 0!==n?n:"",parent:null===(t=i.parent)||void 0===t?void 0:t.toString(),children:C(i,e,"root"),renderLevel:"root-".concat(i.text_knowledge_editor_chunk_uuid)})]:e.map(e=>{var t,n;return(0,_._)((0,w._)({},e),{text:null!==(n=e.content)&&void 0!==n?n:"",parent:null===(t=e.parent)||void 0===t?void 0:t.toString(),children:[],renderLevel:"root-".concat(e.text_knowledge_editor_chunk_uuid)})})},C=(e,t,n)=>{var i;return(null!==(i=e.children)&&void 0!==i?i:[]).reduce((e,i,r)=>{var o=t.find(e=>e.id.toString()===i.toString());if(!o)return[...e];var s,a,l="".concat(n,"-").concat(r),d="".concat(l,"-").concat(o.text_knowledge_editor_chunk_uuid);return[...e,(0,_._)((0,w._)({},o),{parent:null===(s=o.parent)||void 0===s?void 0:s.toString(),text:null!==(a=o.content)&&void 0!==a?a:"",children:C(o,t,l),renderLevel:d})]},[])},A=(e,t)=>e.map(e=>-1!==e.parent||"title"!==e.type||e.text?e:(0,_._)((0,w._)({},e),{text:null!=t?t:""})),E=n("577487"),k=n("71132"),T=n("202147");var M=((i=(0,E.C)("preview-context-menu-items")).registerSome([{type:"edit",module:{Component:k.i}},{type:"delete",module:{Component:T.s}}]),i),D=n("144416"),O=n("476350"),I=n("876143");var N=((r=(0,D.H)("hover-edit-bar-actions")).registerSome([{type:"edit",module:{Component:O.i}},{type:"delete",module:{Component:I.s}}]),r),P=e=>{(0,s.useEffect)(()=>{if(null==e?void 0:e.length){var t=e[0],n=document.getElementById(x(t));null==n||n.scrollIntoView({behavior:"smooth",block:"start"})}},[e])},R=()=>{var[e,t]=(0,s.useState)({chunk:null,renderLevel:null});return{activeChunkInfo:e,clearActiveChunk:()=>{t({chunk:null,renderLevel:null})},setActiveChunkWithLevel:e=>{if(!e.renderLevel){console.warn("Chunk does not have renderLevel field",e);return}t({chunk:e,renderLevel:e.renderLevel})},isActiveChunk:t=>!!t&&t===e.renderLevel}},L=e=>{var{readonly:t,chunks:n,documentId:i,selectionIDs:r,onChange:a,onDeleteChunk:h}=e,[u,p]=(0,s.useState)(n),f=(0,s.useMemo)(()=>S(u),[u]),{activeChunkInfo:m,clearActiveChunk:g,setActiveChunkWithLevel:v,isActiveChunk:b}=R(),{editor:y}=(0,d.n)({chunk:m.chunk}),{saveChunk:x}=(0,l.B)({chunks:n,documentId:i,onChunksChange:e=>{null==a||a(e),g()},onDeleteChunk:e=>{null==h||h(e)}});return(P(r),(0,c.OR)("previewContextMenuItemAction",(0,s.useCallback)(e=>{var{type:t,targetChunk:n,chunks:i}=e;"delete"===t&&(null==h||h(n),i&&(null==a||a(i))),"edit"===t&&v(n)},[])),(0,c.OR)("hoverEditBarAction",(0,s.useCallback)(e=>{var{type:t,targetChunk:n,chunks:i}=e;"delete"===t&&(null==h||h(n),i&&(null==a||a(i))),"edit"===t&&v(n)},[])),(0,s.useEffect)(()=>{p(n)},[n]),f)?(0,o.jsx)("div",{className:"flex flex-col gap-2 w-full h-full",children:f.map(e=>(0,o.jsx)(j,{editor:y,chunks:u,levelDocumentTree:e,activeChunkInfo:m,isActiveChunk:b,setActiveChunkWithLevel:v,selectionIDs:r,readonly:t,saveChunk:x,setChunks:p},e.text_knowledge_editor_chunk_uuid))}):null},j=e=>{var t,n,i,r,s,{levelDocumentTree:l,selectionIDs:d,chunks:c,activeChunkInfo:h,isActiveChunk:u,setActiveChunkWithLevel:f,readonly:m,editor:w,saveChunk:_,setChunks:S}=e,C=(null==l?void 0:null===(t=l.children)||void 0===t?void 0:t.length)?(0,o.jsxs)("div",{className:"flex w-full",children:[(0,o.jsx)("div",{className:"w-6 shrink-0"}),(0,o.jsx)("div",{className:"flex flex-col w-[calc(100%-24px)] gap-2",children:l.children.map(e=>(0,o.jsx)(j,{editor:w,chunks:c,saveChunk:_,levelDocumentTree:e,selectionIDs:d,activeChunkInfo:h,isActiveChunk:u,setActiveChunkWithLevel:f,readonly:m,setChunks:S},e.text_knowledge_editor_chunk_uuid))})]}):null;return l?(0,o.jsxs)("div",{className:"flex flex-col gap-2 w-full",children:[["title","section-title","page-title"].includes(l.type)?(0,o.jsx)(p,{title:l.text,id:x(l.id)}):null,["section-text","text","header-footer","caption","header","footer","formula","footnote","toc","code","table"].includes(l.type)?(0,o.jsx)("div",{children:u(l.renderLevel)?(0,o.jsx)(y.R,{editor:w,editorContextMenuItemsRegistry:v.p,onBlur:e=>{null==_||_((0,a.Pd)(l,e))}}):(0,o.jsx)(b.i,{chunk:l,readonly:m,chunks:c,locateId:x(l.id),hoverEditBarActionsRegistry:N,previewContextMenuItemsRegistry:M,onActivateEditMode:e=>{f(e)}})},l.text_knowledge_editor_chunk_uuid):null,["image"].includes(l.type)?(0,o.jsx)(g,{base64:null!==(i=l.image_detail.base64)&&void 0!==i?i:"",htmlText:l.html_text||l.text,link:null!==(r=null===(n=l.image_detail.links)||void 0===n?void 0:n[0])&&void 0!==r?r:"",caption:null!==(s=l.image_detail.caption)&&void 0!==s?s:"",locateId:x(l.id),selected:null==d?void 0:d.includes(l.id.toString())}):null,C]},l.text_knowledge_editor_chunk_uuid):null}},68851:function(e,t,n){n.d(t,{Gf:function(){return s},PU:function(){return d},Qe:function(){return l},bc:function(){return c},k8:function(){return o},wL:function(){return a}});var i=n(801815),r=n(757208),o=e=>{var t=(0,i.x0)();return{text_knowledge_editor_chunk_uuid:(0,i.x0)(),local_slice_id:t,slice_id:t,sequence:e.sequence,content:""}},s=e=>{var{chunks:t,localChunkSliceId:n,newChunk:i}=e;return t.map(e=>e.local_slice_id===n?i:e)},a=(e,t)=>e.filter(e=>e.local_slice_id!==t),l=(e,t)=>e.filter(e=>e.slice_id!==t),d=(e,t)=>e.map(e=>e.slice_id===t.slice_id?t:e),c=e=>{var t;return{text_knowledge_editor_chunk_uuid:(0,i.x0)(),status:r.OL.FinishVectoring,content:e.content,sequence:e.sequence,slice_id:null!==(t=e.slice_id)&&void 0!==t?t:""}}},987633:function(e,t,n){n.d(t,{PJ:function(){return s},Pd:function(){return o}});var i=n(808549),r=n(120454),o=(e,t)=>(0,r._)((0,i._)({},e),{content:t}),s=e=>{if(!e)return"";var t=e.match(RegExp("^

(.*?)<\\/p>$","s"));return t?t[1]:e}},17236:function(e,t,n){n.d(t,{X:function(){return o}});var i=n(252237),r=n.n(i),o=()=>r()("[&_img]:relative [&_img]:block","[&_img]:my-3 [&_img]:bg-white [&_img]:rounded-md","[&_img]:max-w-[610px] [&_img]:max-h-[367px] [&_img]:w-auto","[&_img.ProseMirror-selectednode]:outline-2 [&_img.ProseMirror-selectednode]:outline [&_img.ProseMirror-selectednode]:outline-blue-500","[&_img.ProseMirror-selectednode]:shadow-md")},373025:function(e,t,n){n.d(t,{X:function(){return o}});var i=n(252237),r=n.n(i),o=()=>r()("[&_table]:border-collapse [&_table]:m-0 [&_table]:w-full [&_table]:table-fixed [&_table]:overflow-hidden [&_table]:text-[0.9em]","[&_table_td]:border [&_table_th]:border [&_table_td]:border-[#ddd] [&_table_th]:border-[#ddd]","[&_table_td]:p-2 [&_table_th]:p-2","[&_table_td]:relative [&_table_th]:relative","[&_table_td]:align-top [&_table_th]:align-top","[&_table_td]:box-border [&_table_th]:box-border","[&_table_td]:border-solid [&_table_th]:border-solid","[&_table_td]:min-w-[100px] [&_table_th]:min-w-[100px]")},636436:function(e,t,n){n.d(t,{I:function(){return o}});var i=n(252237),r=n.n(i),o=()=>r()("[&_p]:break-words [&_p]:whitespace-pre-wrap","[&_.ProseMirror_*]:break-words [&_.ProseMirror_*]:whitespace-pre-wrap","[&_.editor-paragraph]:min-h-[1.5em] [&_.editor-paragraph]:leading-normal","[&_.editor-paragraph:empty]:min-h-[1.5em] [&_.editor-paragraph:empty]:block")},819195:function(e,t,n){n.d(t,{k:function(){return i}});var i=e=>e?r(e.isEmpty?"":e.getHTML()):"",r=e=>{if(!e)return"";var t=new DOMParser().parseFromString(e,"text/html");return t.querySelectorAll("p.text-knowledge-tiptap-editor-paragraph").forEach(e=>{var t=e.parentNode;if(t){for(var n=document.createDocumentFragment();e.firstChild;)n.appendChild(e.firstChild);t.replaceChild(n,e)}}),t.body.innerHTML}},976482:function(e,t,n){n.d(t,{F:()=>r});var i=["img","table","colgroup","col","tbody","thead","tfoot","tr","td","th","br","p"],r=e=>""===e?"":(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;if(!e)return"";var n=t.join("|"),r=RegExp("<(?!(".concat(n,")\\b[^>]*>|\\/(?:").concat(n,")>)"),"g");return e.replace(r,"<")})(e).replace(/\n/g,"
")},431282:function(e,t,n){n.d(t,{zd:()=>o}),n("69258");var i=n("825955"),r=n("735114"),o=e=>{var{data:t,loading:n,error:o}=(0,r.Z)((0,i._)(function*(){if(!e)return null;var t=yield fetch(e,{cache:"no-cache"});if(!t.ok)throw Error("Failed to fetch content");return t.json()}),{refreshDeps:[e]});return{content:t,loading:n,error:o}}},616426:function(e,t,n){n.d(t,{ZK:()=>i.Z,mm:()=>l});var i=n("69258"),r=n("808549"),o=n("120454"),s=n("157728"),a=n("937393"),l=()=>{var e=(0,s.useNavigate)(),t=(0,a.S)();return(n,i)=>{if("string"==typeof n){var s=new URL(n.startsWith("/")?n:"".concat(location.pathname,"/").concat(n),window.location.origin);Object.entries(t).forEach(e=>{var[t,n]=e;n&&!s.searchParams.has(t)&&s.searchParams.set(t,n)});var{pathname:a,search:l}=s;return e("".concat(a).concat(l),i)}if(d(n)){var{search:h}=n,u=new URLSearchParams(h);return Object.entries(t).forEach(e=>{var[t,n]=e;n&&!u.has(t)&&u.set(t,n)}),e((0,o._)((0,r._)({},n),{search:u.toString()}),i)}return c(n)?e(n):e(n,i)}},d=e=>"object"==typeof e,c=e=>"number"==typeof e},69258:function(e,t,n){n.d(t,{Z:function(){return h}});var i=n(825955),r=n(735114),o=n(214942),s=n(297158),a=n(336205),l=n(727914),d=n(382534),c=n(659596),h=e=>{var t=(0,o.rY)(e=>e.space.id),n="dataset-".concat(e.datasetID),h=(0,s.UQ)();return(0,r.Z)((0,i._)(function*(){if(!e.datasetID)throw new l.sH("useListDataSetReq_error","datasetid cannot be empty");var n,i=yield d.MJ.ListDataset({filter:{dataset_ids:[e.datasetID]},space_id:t});if(null==i?void 0:i.total)return null==i?void 0:null===(n=i.dataset_list)||void 0===n?void 0:n.find(t=>t.dataset_id===e.datasetID);(null==i?void 0:i.total)!==0&&h(new l.sH("useListDataSetReq_error",i.msg||""))}),{cacheKey:n,setCache:e=>sessionStorage.setItem(n,JSON.stringify(e)),getCache:()=>JSON.parse(sessionStorage.getItem(n)||"{}"),onError:e=>{c.FN.error({content:a.o.t("Network_error"),showClose:!1}),h(e)}})}},937393:function(e,t,n){n.d(t,{S:function(){return i}});var i=()=>{var e=new URLSearchParams(location.search);return Object.fromEntries(Object.entries({biz:e.get("biz"),bot_id:e.get("bot_id"),workflow_id:e.get("workflow_id"),agent_id:e.get("agent_id"),page_mode:e.get("page_mode")}).filter(e=>!!e[1]))}},153696:function(e,t,n){n.d(t,{BZ:()=>nv,f5:()=>nm,PD:()=>nu,Y5:()=>np,b6:()=>nb});var i,r,o,s,a,l,d,c,h,u=n("808549"),p=n("151064"),f=n("455069"),m=n("664319"),g=n("22916"),v=n("825955"),b=n("735114"),y=n("458620"),x=n("297158"),w=n("336205"),_=n("214942"),S=n("382534"),C=n("745474"),A=n("727914"),E=n("659596"),k=(e,t)=>{var n,i=(0,x.UQ)(),r=(0,_.rY)(e=>e.space.id);var{data:o,run:s,loading:a,mutate:l}=(0,b.Z)((n=(0,v._)(function*(t){var{datasetID:n}=t;if(!n)throw new A.sH("useDataSetDetailReq_error","datasetid cannot be empty");try{var i,o=yield S.MJ.DatasetDetail({dataset_ids:[n],space_id:r}),s=null==o?void 0:null===(i=o.dataset_details)||void 0===i?void 0:i[n];if(s)return null==e||e(s),s}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeGetDataSetDeatil,error:e})}}),function(e){return n.apply(this,arguments)}),{manual:!0,onError:e=>{E.FN.error({content:w.o.t("Network_error"),showClose:!1}),i(e)}});return{data:o,run:s,loading:a,mutate:l}},T=()=>{var{datasetID:e=""}=(0,g.kF)(),{data:t,run:n}=k(),{setDataSetDetail:i,dataSetDetail:r}=(0,g.PR)((0,m.N)(e=>({setDataSetDetail:e.setDataSetDetail,dataSetDetail:e.dataSetDetail})));return(0,f.useEffect)(()=>{if(!r.dataset_id)n({datasetID:e})},[]),(0,f.useEffect)(()=>(i(t||{}),()=>{i({})}),[t]),{dataSetDetail:t}},M=n("274971"),D=n("771242"),O=n("695673"),I=n("653598"),N=n("537714");N.Cm.TABLE_GOOGLE_DRIVE,N.Cm.TABLE_FEISHU,N.Cm.TEXT_FEISHU,N.Cm.TEXT_LARK,N.Cm.TABLE_LARK,N.Cm.TEXT_GOOGLE_DRIVE,N.Cm.TEXT_DOC,N.Cm.TEXT_URL,N.Cm.TEXT_NOTION,N.Cm.TEXT_CUSTOM,I.a5.Text,w.o.t("content_view_001"),w.o.t("content_view_002");var P={[I.f3.NoUpdate]:w.o.t("datasets_segment_tag_updateNo"),[I.f3.Cover]:w.o.t("datasets_segment_tag_overwrite"),[I.f3.Append]:w.o.t("datasets_segment_tag_overwriteNo")},R=(e,t)=>{var n,i=(0,x.UQ)();var{data:r,run:o,loading:s,mutate:a}=(0,b.Z)((n=(0,v._)(function*(t){var{datasetID:n,page:r,size:o}=t;if(!n)throw new A.sH("useListDocumentReq_error","datasetid cannot be empty");try{var s=yield S.MJ.ListDocument({dataset_id:n,page:null!=r?r:0,size:null!=o?o:O.by});if(s.document_infos)return null==e||e(s.document_infos),s.document_infos;i(new A.sH("useListDataSetReq_error",s.msg||""))}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeGetDataSetDeatil,error:e})}}),function(e){return n.apply(this,arguments)}),{manual:!0,onError:e=>{E.FN.error({content:w.o.t("Network_error"),showClose:!1}),i(e)}});return{data:r,run:o,loading:s,mutate:a}},L=()=>{var e=(0,f.useRef)();return(0,f.useEffect)(()=>()=>{(0,D.uA)(e)},[]),(t,n)=>{e.current&&(0,D.uA)(e);var i,r=(i=(0,v._)(function*(){var i,r,{data:o=[]}=yield S.MJ.GetDocumentProgress({document_ids:t});n.isImage&&(i=null===(r=yield S.MJ.PhotoDetail({document_ids:t,dataset_id:n.dataSetId}))||void 0===r?void 0:r.photo_infos);var s=o.reduce((e,t)=>{var n=(null==i?void 0:i[t.document_id])||{};return e[t.document_id]=(0,u._)({status:t.status,progress:t.progress},n),e},{});(0,M.te)(o),n.onProgressing(s),(0,D.zP)(o)&&(n.onFinish(),(0,D.uA)(e))}),function(){return i.apply(this,arguments)});e.current=window.setInterval((r(),r),5e3)}},j=e=>{var t,{onSuccess:n}=e;var{run:i,loading:r}=(0,b.Z)((t=(0,v._)(function*(e){if(!e.document_id)throw new A.sH(y.b.KnowledgeUpdateDocumentName,"".concat(y.b.KnowledgeUpdateDocumentName,": missing doc_id"));yield S.MJ.UpdateDocument(e)}),function(e){return t.apply(this,arguments)}),{manual:!0,onSuccess:()=>{n()},onError:e=>{C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeUpdateDocumentName,error:e})}});return{run:i,loading:r}},F=()=>{var{datasetID:e=""}=(0,g.kF)(),{run:t,loading:n,data:i}=k(),{run:r,loading:o,data:s}=R(),{setDataSetDetail:a,setDocumentList:l}=(0,g.PR)((0,m.N)(e=>({setDataSetDetail:e.setDataSetDetail,setDocumentList:e.setDocumentList})));return(0,f.useEffect)(()=>{!n&&i&&a(i)},[i,n]),(0,f.useEffect)(()=>{!o&&s&&l(s)},[s,o]),{loading:n||o,reload:()=>{t({datasetID:e}),r({datasetID:e})},reset:()=>{a({}),l([])}}},B=n("280053"),z=n("487377"),H=n("298203"),V=n("120454"),U=n("974235"),$=e=>{var t,{params:n,onSuccess:i,onError:r,reloadDeps:o=[],target:s=null,dataReady:a=!0}=e;var{loading:l,data:d,loadingMore:c,mutate:h,cancel:p,reload:f,loadMore:m}=(0,U.Z)((t=(0,v._)(function*(e){if(!n.dataset_id&&!n.document_id)return{list:[],total:0,hasMore:!1,ready:!1};var t,i,r,o=!!n.dataset_id,s=(null==e?void 0:null===(t=e.list)||void 0===t?void 0:t.length)?e.list[e.list.length-1].sequence:void 0,a=o?{document_id:e&&(null==e?void 0:null===(i=e.list)||void 0===i?void 0:i.length)?e.list[e.list.length-1].document_id:void 0,sequence:s}:{sequence:s},l=yield S.MJ.ListSlice((0,u._)((0,V._)((0,u._)({},a),{page_size:String(50)}),n));return{list:(null==l?void 0:l.slices)||[],total:Number(null!==(r=null==l?void 0:l.total)&&void 0!==r?r:0),hasMore:null==l?void 0:l.hasmore,ready:!0}}),function(e){return t.apply(this,arguments)}),{isNoMore:e=>!(null==e?void 0:e.hasMore),target:s,onBefore:()=>{(c||l)&&p()},onSuccess:i,onError:r,reloadDeps:o});return{loading:l,data:d,loadingMore:c,mutate:h,cancel:p,reload:f,loadMore:m,pageSize:50}};var W=(i=(0,v._)(function*(e){if(!e||!e.length)throw new A.sH(y.b.KnowledgeDeleteSlice,"".concat(y.b.KnowledgeDeleteSlice,": missing slice_id"));return yield S.MJ.DeleteSlice({slice_ids:e}),e}),function(e){return i.apply(this,arguments)});var q=(r=(0,v._)(function*(e,t,n){if(!e)throw new A.sH("normal_error","missing slice_id");return yield S.MJ.UpdateSlice({slice_id:e,raw_text:t,table_unit_text:n}),E.FN.success(w.o.t("Update_success")),t}),function(e,t,n){return r.apply(this,arguments)}),G=e=>{var t,{onReload:n}=e;var{run:i}=(0,b.Z)((t=(0,v._)(function*(e){if(!e.document_id)throw new A.sH("normal_error","missing doc_id");var t=yield S.MJ.CreateSlice(e);return(0,u._)({},t,e)}),function(e){return t.apply(this,arguments)}),{manual:!0,onSuccess:e=>{var t;E.FN.success(w.o.t("Update_success")),n({document_id:e.document_id,slice_id:e.slice_id,sequence:"0",content:null!==(t=e.raw_text)&&void 0!==t?t:{}})},onError:e=>{C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeCreateSlice,error:e})}});return{createSlice:i}},K=e=>{var{keepDocTitle:t,className:n,renderNavBar:i,renderContent:r}=e,{onUpdateDisplayName:o,onStatusChange:s}=(0,g.kJ)(),{setDataSetDetail:a,dataSetDetail:l,setDocumentList:d,documentList:c}=(0,g.PR)((0,m.N)(e=>({setDataSetDetail:e.setDataSetDetail,dataSetDetail:e.dataSetDetail,setDocumentList:e.setDocumentList,documentList:e.documentList}))),[h,u]=(0,f.useState)({}),v=L(),{reload:b,loading:y,reset:x}=F();(0,f.useEffect)(()=>(b(),()=>{x()}),[]),(0,f.useEffect)(()=>{(null==l?void 0:l.name)&&(null==o||o(l.name),null==s||s("normal"))},[null==l?void 0:l.name]),(0,z.a)({isLive:!!(null==c?void 0:c.length)}),(0,f.useEffect)(()=>{var e=null==l?void 0:l.processing_file_id_list;e&&e.length&&v(e,{onProgressing:e=>{u(e)},onFinish:()=>{b()},dataSetId:null==l?void 0:l.dataset_id,isImage:(null==l?void 0:l.format_type)===B.a5.Image})},[l]);var _={layoutProps:{keepDocTitle:t,renderContent:r,renderNavBar:i},dataInfo:{dataSetDetail:l,documentList:c},statusInfo:{isReloading:y,progressMap:h},dataActions:{refreshData:b,updateDataSetDetail:e=>a(e||{}),updateDocumentList:e=>d(e||[])}};return(0,p.jsx)(C.xV,{namespace:C.xW.KNOWLEDGE,children:(0,p.jsxs)(E.Ar,{className:n||"flex flex-col p-[24px] pt-[16px] gap-[16px] !bg-transparent ",title:(0,H.Z$)("".concat(null==l?void 0:l.name," - ").concat(w.o.t("tab_dataset_list"))),keepDocTitle:t,children:[null==i?void 0:i(_),null==r?void 0:r(_)]})})},Z=n("252237"),Y=n.n(Z),X=n("420998"),J=n("801815"),Q=n("873183"),ee=()=>({[N.Cm.IMAGE_FILE]:{unitType:N.Cm.IMAGE_FILE,name:w.o.t("knowledge_photo_002"),icon:(0,p.jsx)(Q.da8,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TABLE_DOC]:{unitType:N.Cm.TABLE_DOC,name:w.o.t("datasets_createFileModel_step1_TabLocalTitle"),icon:(0,p.jsx)(Q.da8,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TABLE_API]:{unitType:N.Cm.TABLE_API,name:w.o.t("datasets_createFileModel_step1_apiTitle"),icon:(0,p.jsx)(Q.a4,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TABLE_CUSTOM]:{unitType:N.Cm.TABLE_CUSTOM,name:w.o.t("dataset_detail_source_custom"),icon:(0,p.jsx)(Q.YRi,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TABLE_FEISHU]:{unitType:N.Cm.TABLE_FEISHU,name:w.o.t("knowledge-3rd-party-feishu"),icon:(0,p.jsx)(Q.Ahw,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TABLE_LARK]:{unitType:N.Cm.TABLE_LARK,name:w.o.t("Lark_00001"),icon:(0,p.jsx)(Q.Ahw,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TABLE_GOOGLE_DRIVE]:{unitType:N.Cm.TABLE_GOOGLE_DRIVE,name:w.o.t("knowledge-3rd-party-google-drive"),icon:(0,p.jsx)(Q.Q4r,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_DOC]:{unitType:N.Cm.TEXT_DOC,name:w.o.t("datasets_createFileModel_step1_TabLocalTitle"),icon:(0,p.jsx)(Q.da8,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_URL]:{unitType:N.Cm.TEXT_URL,name:w.o.t("datasets_createFileModel_step1_urlTitle"),icon:(0,p.jsx)(Q.KQ3,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_EXTENSION]:{unitType:N.Cm.TEXT_EXTENSION,name:w.o.t("datasets_createFileModel_step1_urlTitle"),icon:(0,p.jsx)(Q.KQ3,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_NOTION]:{unitType:N.Cm.TEXT_NOTION,name:w.o.t("knowledge-3rd-party-notion"),icon:(0,p.jsx)(Q.S6N,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_FEISHU]:{unitType:N.Cm.TEXT_FEISHU,node:"item",name:w.o.t("knowledge-3rd-party-feishu"),icon:(0,p.jsx)(Q.Ahw,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_LARK]:{unitType:N.Cm.TEXT_LARK,name:w.o.t("Lark_00001"),icon:(0,p.jsx)(Q.Ahw,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_GOOGLE_DRIVE]:{unitType:N.Cm.TEXT_GOOGLE_DRIVE,name:w.o.t("knowledge-3rd-party-google-drive"),icon:(0,p.jsx)(Q.Q4r,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_CUSTOM]:{unitType:N.Cm.TEXT_CUSTOM,name:w.o.t("dataset_detail_source_custom"),icon:(0,p.jsx)(Q.YRi,{className:"w-4 h-4 [&>path]:fill-current"})},[N.Cm.TEXT_WECHAT]:{unitType:N.Cm.TEXT_WECHAT,name:w.o.t("公众号"),icon:(0,p.jsx)(Q.yrb,{className:"w-4 h-4 [&>path]:fill-current"})}}),et=e=>{if(e.format_type===B.a5.Text){if(e.source_type===B.NZ.Document)return N.Cm.TEXT_DOC;if(e.source_type===B.NZ.Web)return N.Cm.TEXT_URL;if(e.source_type===B.NZ.Custom)return N.Cm.TEXT_CUSTOM;if(e.source_type===B.NZ.FrontCrawl)return N.Cm.TEXT_EXTENSION;if(e.source_type===B.NZ.Notion)return N.Cm.TEXT_NOTION;if(e.source_type===B.NZ.GoogleDrive)return N.Cm.TEXT_GOOGLE_DRIVE;if(e.source_type===B.NZ.FeishuWeb)return N.Cm.TEXT_FEISHU;if(e.source_type===B.NZ.LarkWeb)return N.Cm.TEXT_LARK;if(e.source_type===B.NZ.WeChat)return N.Cm.TEXT_WECHAT}if(e.format_type===B.a5.Table){if(e.source_type===B.NZ.Document)return N.Cm.TABLE_DOC;if(e.source_type===B.NZ.Web)return N.Cm.TABLE_API;if(e.source_type===B.NZ.Custom)return N.Cm.TABLE_CUSTOM;if(e.source_type===B.NZ.GoogleDrive)return N.Cm.TABLE_GOOGLE_DRIVE;if(e.source_type===B.NZ.FeishuWeb)return N.Cm.TABLE_FEISHU;if(e.source_type===B.NZ.LarkWeb)return N.Cm.TABLE_LARK}return N.Cm.TEXT_URL},en={[B.NZ.Document]:w.o.t("dataset_detail_source_local"),[B.NZ.Web]:w.o.t("dataset_detail_source_online"),[B.NZ.Custom]:w.o.t("dataset_detail_source_custom"),[B.NZ.ThirdParty]:"",[B.NZ.FrontCrawl]:w.o.t("dataset_detail_source_online"),[B.NZ.GoogleDrive]:w.o.t("knowledge-3rd-party-google-drive"),[B.NZ.Notion]:w.o.t("knowledge-3rd-party-notion"),[B.NZ.FeishuWeb]:w.o.t("knowledge-3rd-party-feishu"),[B.NZ.LarkWeb]:w.o.t("Lark_00001"),[B.NZ.OpenApi]:w.o.t("dataset_detail_source_custom"),[B.NZ.WeChat]:w.o.t("knowledge_weixin_001")},ei=e=>{var{format_type:t,source_type:n}=e||{};return t===B.a5.Table&&n===B.NZ.Web?"Api":en[n||0]||"-"},er=e=>{switch(e){case N.Cm.TABLE:case N.Cm.TABLE_API:case N.Cm.TABLE_DOC:case N.Cm.TABLE_CUSTOM:case N.Cm.TABLE_FEISHU:case N.Cm.TABLE_GOOGLE_DRIVE:return B.a5.Table;case N.Cm.IMAGE:return B.a5.Image;default:return B.a5.Text}},eo=e=>{var{spaceID:t,datasetID:n,type:i,docID:r,formatType:o,pageMode:s,botId:a,actionType:l,isDouyinBot:d}=e,c="/space/".concat(t,"/knowledge/").concat(n,"/upload"),h={type:null!=i?i:""};o===B.a5.Table&&r&&(h.opt=N.VP.INCREMENTAL,h.doc_id=r),s&&(h.page_mode=s),a&&(h.bot_id=a),l&&(h.action_type=l),d&&(h.is_douyin="true");var u=new URLSearchParams(h);return"".concat(c,"?").concat(u.toString())},es=e=>(0,u._)({text_knowledge_editor_chunk_uuid:(0,J.x0)()},e),ea=e=>{var t;return(0,u._)({text_knowledge_editor_chunk_uuid:(0,J.x0)(),sequence:null===(t=e.slice_sequence)||void 0===t?void 0:t.toString(),content:e.text},e)},el=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=ee();return e.map(e=>{var i,r,o,s,a,l=n[et({format_type:null==e?void 0:e.format_type,source_type:null==e?void 0:e.source_type})];return{value:e.document_id,text:e.name,label:(0,p.jsxs)("div",{className:"flex flex-row items-center justify-center max-w-[603px] coz-fg-primary",children:[(0,p.jsx)("div",{className:"flex text-[16px]",children:null==l?void 0:l.icon}),(0,p.jsx)(E.ZT.Text,{ellipsis:{showTooltip:{opts:{theme:"dark"}}},fontSize:"14px",className:"w-full grow truncate ml-[8px]",children:e.name}),(0,p.jsxs)("div",{className:"flex items-center shrink-0 ml-[4px]",children:[Object.keys(t).includes(null!==(o=null==e?void 0:e.document_id)&&void 0!==o?o:"")&&(null==t?void 0:null===(i=t[null!==(s=null==e?void 0:e.document_id)&&void 0!==s?s:""])||void 0===i?void 0:i.progress)<100?(0,p.jsxs)(E.Vp,{color:"blue",size:"mini",className:"font-medium",children:[w.o.t("datasets_segment_tag_processing")," ".concat(null===(r=t[null!==(a=null==e?void 0:e.document_id)&&void 0!==a?a:""])||void 0===r?void 0:r.progress,"%")]}):null,(null==e?void 0:e.status)===B._m.Failed?(0,p.jsx)(E.u,{theme:"dark",content:null==e?void 0:e.status_descript,children:(0,p.jsx)(Q.L03,{className:"coz-fg-hglt-red"})}):null]})]},null==e?void 0:e.document_id)}})},ed=e=>{var{docId:t,documentType:n,documentSource:i,onDelete:r,onUpdateFrequency:o}=e,{node:s,delete:a}=(0,O.mp)({docId:t,onDel:()=>{null==r||r()}}),{node:l,edit:d}=(0,O.yI)({docId:t,onFinish:e=>{null==o||o(e)},type:n,documentSource:i});return{deleteModalNode:s,showDeleteModal:a,updateFrequencyModalNode:l,showUpdateFrequencyModal:d}},ec=e=>{var{curDocId:t,setCurDocId:n,documentList:i}=(0,g.PR)((0,m.N)(e=>({curDocId:e.curDocId,setCurDocId:e.setCurDocId,documentList:e.documentList}))),r=(0,f.useRef)(null),{run:o}=j({onSuccess:()=>{var t;E.FN.success(w.o.t("Update_success")),null==e||null===(t=e.reloadDataset)||void 0===t||t.call(e)}});return{prevDocIdRef:r,updateDocument:o,handleSelectDocument:e=>{r.current=t||null,n(e)},handleRenameDocument:(e,t)=>{o({document_id:e,document_name:t})},handleUpdateDocumentFrequency:(e,t)=>{if(!!i)return i.map(n=>n.document_id===e?(0,V._)((0,u._)({},n),{update_interval:null==t?void 0:t.updateInterval,update_type:t.updateInterval?B.$o.Cover:B.$o.NoUpdate}):n)},rollbackDocumentSelection:()=>{r.current&&n(r.current)}}},eh=()=>{var e=(0,g.PR)(e=>e.documentList),{handleSelectDocument:t}=ec();(0,f.useEffect)(()=>{if(null==e?void 0:e.length){var n,i;t(null!==(i=null===(n=e[0])||void 0===n?void 0:n.document_id)&&void 0!==i?i:"")}},[e])},eu=e=>{var[t,n]=(0,f.useState)(!1);return(0,f.useEffect)(()=>{t&&n(!1)},[e]),{showOriginalFile:t,handleToggleOriginalFile:e=>{n(e)}}},ep=e=>{var t,n,{documentList:i,dataSetDetail:r,curDocId:o}=(0,g.PR)((0,m.N)(e=>({curDocId:e.curDocId,documentList:e.documentList,dataSetDetail:e.dataSetDetail}))),s=null==i?void 0:i.find(e=>e.document_id===o),a=(null==s?void 0:s.status)===B._m.Processing,l=!!o&&(null===(t=e[o])||void 0===t?void 0:t.status)===B._m.Enable;return{curDoc:s,curDocId:o,isProcessing:a,processFinished:l,datasetId:null!==(n=null==r?void 0:r.dataset_id)&&void 0!==n?n:""}},ef=e=>{var{curDocId:t,datasetId:n,curChunkType:i,processFinished:r,target:o,rollbackDocumentSelection:s}=e,{searchValue:a}=(0,g.PR)((0,m.N)(e=>({searchValue:e.searchValue}))),{loading:l,data:d,mutate:c,reload:h}=$({target:o,params:{keyword:a,document_id:i!==B.x2.LevelChunk?t:""},reloadDeps:[a,t,n,r],onError:e=>{C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeGetSliceList,error:e}),E.FN.error(w.o.t("knowledge_document_view")),s()}}),p=(0,f.useMemo)(()=>{var e;return null!==(e=null==d?void 0:d.list.map(e=>es(e)))&&void 0!==e?e:[]},[null==d?void 0:d.list]);return{loading:l,sliceData:d,renderData:p,handleContentChange:e=>{var t;c((0,V._)((0,u._)({},d),{list:e,total:Number(null!==(t=null==d?void 0:d.total)&&void 0!==t?t:"0")}))},reload:h}},em=n("431282"),eg=n("347852"),ev=e=>{var t,{curDoc:n}=e,[i,r]=(0,f.useState)([]),{levelSegments:o,setLevelSegments:s}=(0,g.PR)((0,m.N)(e=>({levelSegments:e.levelSegments,setLevelSegments:e.setLevelSegments}))),{content:a,loading:l}=(0,em.zd)((null==n?void 0:null===(t=n.chunk_strategy)||void 0===t?void 0:t.chunk_type)===B.x2.LevelChunk?null==n?void 0:n.doc_tree_tos_url:void 0),d=(0,f.useMemo)(()=>o.map(e=>ea(e)),[o]);return(0,f.useEffect)(()=>{var e,t;s((0,eg.D)(null!==(e=null==a?void 0:a.chunks)&&void 0!==e?e:[],null!==(t=null==n?void 0:n.name)&&void 0!==t?t:""))},[a]),{levelSegments:o,renderLevelSegmentsData:d,selectionIDs:i,setSelectionIDs:r,tosLoading:l,handleLevelSegmentsChange:e=>{s(e)},handleLevelSegmentDelete:e=>{s(o.filter(t=>t.slice_id!==e.slice_id))}}},eb=()=>{var{dataSetDetail:e,setDataSetDetail:t}=(0,g.PR)((0,m.N)(e=>({dataSetDetail:e.dataSetDetail,setDataSetDetail:e.setDataSetDetail})));return{handleIncreaseSliceCount:()=>{if(!!e)t((0,V._)((0,u._)({},e),{slice_count:e.slice_count>-1?e.slice_count+1:0}))},handleDecreaseSliceCount:()=>{if(!!e)t((0,V._)((0,u._)({},e),{slice_count:e.slice_count>-1?e.slice_count-1:0}))}}},ey=n("263825"),ex=n("385038"),ew=n("523865"),e_=e=>{var{documentInfo:t}=e,n=(0,f.useMemo)(()=>{var e,n=P[null!==(e=null==t?void 0:t.update_type)&&void 0!==e?e:""];return(null==t?void 0:t.update_interval)&&(n="".concat(w.o.t("datasets_segment_tag_updateFrequency",{num:t.update_interval}))),n},[t]);return t?(0,p.jsxs)(E.T,{className:ew.Z["doc-tag-wrapper"],spacing:4,children:[(0,p.jsx)(E.Vp,{color:"primary",size:"mini",children:ei(t)}),t.source_type===B.NZ.Web&&(0,p.jsx)(E.Vp,{color:"primary",size:"mini",children:n}),(()=>{var{format_type:e,chunk_strategy:n}=t;return e===B.a5.Text&&n?n.chunk_type===B.x2.CustomChunk?(0,p.jsx)(E.Vp,{color:"primary",size:"mini",children:w.o.t("datasets_segment_tag_custom")}):n.chunk_type===B.x2.LevelChunk?(0,p.jsx)(E.Vp,{color:"primary",size:"mini",children:w.o.t("knowledge_level_016")}):(0,p.jsx)(E.Vp,{color:"primary",size:"mini",children:w.o.t("datasets_segment_tag_auto")}):null})()]}):null},eS=n("998600"),eC=e=>{var{type:t,options:n,value:i,onChange:r,canEdit:o,onRename:s}=e,[a,l]=(0,f.useState)(""),[d,c]=(0,f.useState)(""),[h,u]=(0,f.useState)(""),[m,g]=(0,f.useState)(!1),[v,b]=(0,f.useState)(!1),y=(0,eS.Z)(e=>{c(e||"")},{wait:300}),_=n.filter(e=>{if(!d)return!0;try{var t,n=new RegExp(d);return"all"!==e.value&&e.value===i||(null==e?void 0:null===(t=e.text)||void 0===t?void 0:t.match(n))}catch(e){return!0}}),S=()=>{var e,t=null===(e=n.find(e=>e.value===i))||void 0===e?void 0:e.text;t&&u(t)},C=e=>{e.stopPropagation(),g(!0)},A=()=>{if(!!h){b(!0);try{s(i,h),g(!1)}finally{b(!1)}}};return(0,p.jsx)(E.Ph,{clickToHide:!0,maxHeight:670,disabled:!0,className:Y()(ew.Z["doc-selector"]),dropdownClassName:ew.Z["doc-selector-dropdown"],optionList:_,value:i,onChange:r,getPopupContainer:()=>document.body,triggerRender:e=>{var{value:t}=e;return(0,p.jsx)(E.J2,{clickToHide:!0,visible:m,onClickOutSide:()=>g(!1),trigger:"custom",style:{padding:16,width:320},onVisibleChange:e=>{e&&S()},content:(0,p.jsxs)("div",{className:ew.Z["edit-doc-name-container"],onClick:e=>e.stopPropagation(),children:[(0,p.jsx)("div",{className:ew.Z["edit-doc-name-container-title"],children:w.o.t("knowledge_detail_doc_rename")}),(0,p.jsxs)("div",{className:ew.Z["edit-doc-name-container-input"],children:[(0,p.jsx)(E.Kx,{value:h,maxLength:100,maxCount:100,validateStatus:h?"default":"error",placeholder:w.o.t("knowledge_upload_text_custom_doc_name_tips"),onChange:e=>u(e)}),!h&&(0,p.jsx)("div",{className:ew.Z["edit-doc-name-container-input-error"],children:w.o.t("knowledge_upload_text_custom_doc_name_tips")})]}),(0,p.jsx)("div",{className:"text-right",children:(0,p.jsx)(E.zx,{disabled:!h,onClick:A,size:"small",loading:v,children:w.o.t("Save")})})]}),position:"bottomLeft",children:(0,p.jsxs)("div",{onClick:()=>{g(!1)},className:ew.Z["doc-selector-trigger"],"data-testid":ex.w.SegmentDetailContentSelectTrigger,children:[(0,p.jsx)("div",{className:ew.Z["doc-selector-trigger-label"],children:t.map(e=>(0,p.jsx)("div",{children:e.label},e.value))}),o&&i?(0,p.jsx)("div",{children:(0,p.jsx)(E.u,{clickToHide:!0,theme:"dark",content:w.o.t("knowledge_detail_doc_rename"),children:(0,p.jsx)("div",{className:ew.Z["doc-selector-trigger-icon"],onClick:C,"data-testid":ex.w.SegmentDetailContentSelectTriggerEditIcon,children:(0,p.jsx)(Q.JAz,{className:"text-[14px]"})})})}):null]})})},innerTopSlot:(0,p.jsx)(E.ol,{value:a,placeholder:w.o.t("datasets_placeholder_search"),onChange:e=>{l(e)},onSearch:e=>{x.kg.info({message:"onSearch",meta:{v:e}}),y.run(e)}})})},eA=e=>{var{documentData:{curDoc:t,curDocId:n,curFormatType:i,docOptions:r},filePreviewData:{showOriginalFile:o,fileUrl:s},documentActions:{onChangeDoc:a,onRenameDoc:l,onToggleOriginalFile:d,onResegment:c,onUpdateFrequency:h,onDelete:u},customUIElements:{linkOriginUrlButton:f,fetchSliceButton:m}}=e,v=(0,g.PR)(e=>e.canEdit),b=v&&t&&(t.source_type===B.NZ.Web||(0,ey.$6)(null==t?void 0:t.source_type)),y=t&&v,x=(null==t?void 0:t.format_type)===B.a5.Text,_=v&&t&&![B.NZ.Custom,B.NZ.Document].includes(t.source_type);return(0,p.jsxs)("div",{className:Y()("w-full flex items-center justify-between py-[12px] px-[16px]","border border-solid coz-stroke-primary border-l-0 border-t-0 border-r-0"),children:[(0,p.jsxs)("div",{className:Y()("flex items-center"),children:[(0,p.jsx)(eC,{type:i,options:r,canEdit:v,value:n,onChange:a,onRename:l}),(0,p.jsx)(e_,{documentInfo:t})]}),(0,p.jsxs)(E.T,{spacing:8,children:[s?(0,p.jsxs)("div",{className:"flex items-center gap-2",children:[(0,p.jsx)("span",{className:"coz-fg-secondary text-[12px] leading-[16px]",children:w.o.t("knowledge_level_030")}),(0,p.jsx)(E.rs,{size:"mini",checked:o,onChange:d})]}):null,x&&v?(0,p.jsx)(E.u,{theme:"dark",content:w.o.t("knowledge_new_001"),children:(0,p.jsx)(E.hU,{"data-testid":ex.w.SegmentDetailUpdateBtn,iconPosition:"left",color:"secondary",size:"small",icon:(0,p.jsx)(Q.CW,{}),onClick:c})}):null,b?(0,p.jsx)(E.u,{theme:"dark",content:w.o.t("datasets_unit_upload_field_update_frequency"),children:(0,p.jsx)(E.hU,{"data-dtestid":"".concat(ex.w.SegmentDetailContentItemFrequencyIcon,".").concat(null==t?void 0:t.document_id),icon:(0,p.jsx)(Q.VjM,{className:"text-[14px]"}),iconPosition:"left",color:"secondary",size:"small",onClick:h})}):null,_?m:null,f,y?(0,p.jsx)(E.u,{theme:"dark",content:w.o.t("kl2_006"),children:(0,p.jsx)(E.hU,{"data-testid":ex.w.SegmentDetailContentDeleteIcon,icon:(0,p.jsx)(Q.dVD,{className:"text-[14px]"}),color:"secondary",iconPosition:"left",size:"small",onClick:u})}):null]})]})},eE=n("763055"),ek=n("523652"),eT=n("44172"),eM=e=>{var{isProcessing:t,documentId:n,levelSegments:i,selectionIDs:r,onLevelSegmentsChange:o,onLevelSegmentDelete:s}=e,a=(0,g.PR)(e=>e.canEdit),l=(0,g.PR)(e=>e.searchValue),d=i.map(e=>ea(e));return 0===i.length?(0,p.jsx)("div",{className:Y()(ew.Z["empty-content"]),children:(0,p.jsx)(E.ub,{size:"large",icon:l?(0,p.jsx)(eE.xs,{style:{width:150,height:"100%"}}):(0,p.jsx)(eT.s9d,{style:{width:150,height:"100%"}}),title:t?w.o.t("content_view_003"):l?w.o.t("knowledge_no_result"):w.o.t("dataset_segment_empty_desc")})}):(0,p.jsx)(ek.pR,{chunks:d,selectionIDs:r,documentId:n,readonly:!a,onChange:o,onDeleteChunk:s})},eD=e=>{var{fileType:t,fileUrl:n,visible:i}=e,{pdfNode:r,numPages:o,currentPage:s,onNext:a,onBack:l,scale:d,increaseScale:c,decreaseScale:h}=(0,X.Is)({fileUrl:n});return(0,p.jsx)("div",{className:Y()("w-full h-full","border border-solid coz-stroke-primary border-t-0 border-b-0 border-l-0","flex flex-col items-center overflow-auto",!i&&"hidden"),children:"md"===t?(0,p.jsx)(X.SA,{fileUrl:n}):"txt"===t?(0,p.jsx)(X.Tn,{fileUrl:n}):["docx","pdf","doc"].includes(null!=t?t:"")?(0,p.jsxs)("div",{className:"grow w-full relative",children:[o>=1?(0,p.jsxs)("div",{className:Y()("flex w-fit h-[32px] items-center justify-center gap-[3px] absolute top-[8px] right-[8px]","coz-bg-max rounded-[8px] coz-shadow-default","z-10","px-[8px]"),children:[(0,p.jsx)(E.hU,{icon:(0,p.jsx)(Q.$1i,{}),size:"small",color:"secondary",onClick:l}),(0,p.jsxs)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-[24px]",children:[s," / ",o]}),(0,p.jsx)(E.hU,{icon:(0,p.jsx)(Q.x5d,{}),size:"small",color:"secondary",onClick:a}),(0,p.jsx)("div",{className:"w-[1px] h-[12px] coz-mg-primary"}),(0,p.jsx)(E.hU,{icon:(0,p.jsx)(Q.ozt,{}),size:"small",color:"secondary",onClick:h}),(0,p.jsxs)("div",{className:"coz-fg-secondary text-[12px] font-[400] leading-[16px]",children:[Math.round(100*d),"%"]}),(0,p.jsx)(E.hU,{icon:(0,p.jsx)(Q.PwN,{}),size:"small",color:"secondary",onClick:c})]}):null,r]}):null})},eO=e=>{var{loading:t,isProcessing:n,documentId:i,renderData:r,onContentChange:o,onAddChunk:s,onDeleteChunk:a}=e,l=(0,g.PR)(e=>e.canEdit),d=(0,g.PR)(e=>e.searchValue);return(null==r?void 0:r.length)!==0||t?(0,p.jsx)("div",{className:ew.Z["slice-article-content"],children:(0,p.jsx)(ek.UF,{chunks:r,documentId:i,readonly:!l,onChange:o,onAddChunk:s,onDeleteChunk:a})}):(0,p.jsx)("div",{className:Y()(ew.Z["empty-content"]),children:(0,p.jsx)(E.ub,{size:"large",icon:d?(0,p.jsx)(eE.xs,{style:{width:150,height:"100%"}}):(0,p.jsx)(eT.s9d,{style:{width:150,height:"100%"}}),title:n?w.o.t("content_view_003"):d?w.o.t("knowledge_no_result"):w.o.t("dataset_segment_empty_desc")})})},eI=e=>{var t,n,i,{onChangeDocList:r,reload:o,progressMap:s,linkOriginUrlButton:a,fetchSliceButton:l}=e,d=(0,f.useRef)(null),c=(0,g.kF)(),h=(0,g.PR)(e=>e.documentList),u=(0,g.EV)();eh();var{handleSelectDocument:m,handleRenameDocument:v,handleUpdateDocumentFrequency:b,rollbackDocumentSelection:y}=ec({reloadDataset:o}),{curDoc:x,curDocId:w,isProcessing:_,processFinished:S,datasetId:C}=ep(s),{showOriginalFile:A,handleToggleOriginalFile:k}=eu(w),{loading:T,renderData:M,handleContentChange:D,reload:O}=ef({curDocId:w,datasetId:C,curChunkType:null==x?void 0:null===(t=x.chunk_strategy)||void 0===t?void 0:t.chunk_type,processFinished:S,target:d,rollbackDocumentSelection:y}),{levelSegments:I,selectionIDs:P,setSelectionIDs:R,tosLoading:L,handleLevelSegmentsChange:j,handleLevelSegmentDelete:F}=ev({curDoc:x}),{handleIncreaseSliceCount:z,handleDecreaseSliceCount:H}=eb(),{deleteModalNode:V,showDeleteModal:U,updateFrequencyModalNode:$,showUpdateFrequencyModal:W}=ed({docId:null==x?void 0:x.document_id,documentType:null==x?void 0:x.format_type,documentSource:null==x?void 0:x.source_type,onDelete:()=>{null==o||o(),m("")},onUpdateFrequency:e=>{if(!!r&&!!x){var t,n=b(null!==(t=x.document_id)&&void 0!==t?t:"",e);n&&r(n)}}}),q=el(h,s),G="project"===c.biz;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:Y()("flex grow border-solid coz-stroke-primary coz-bg-max",G?"h-[calc(100%-64px)] border-0 border-t":"h-[calc(100%-112px)] border rounded-[8px]"),children:[(0,p.jsx)("div",{className:Y()("w-[300px] h-full shrink-0 overflow-auto p-[12px]","border-0 border-r border-solid coz-stroke-primary"),children:(0,p.jsx)(X.yt,{isSearchable:!0,list:(null!=h?h:[]).map(e=>{var t,n,i;return{id:null!==(n=e.document_id)&&void 0!==n?n:"",title:null!==(i=e.name)&&void 0!==i?i:"",label:null===(t=q.find(t=>t.value===e.document_id))||void 0===t?void 0:t.label}}),selectedID:w,onClick:e=>{e!==w&&m(e)},levelSegments:I,setSelectionIDs:R,treeDisabled:!0,treeVisible:(null==x?void 0:null===(n=x.chunk_strategy)||void 0===n?void 0:n.chunk_type)===B.x2.LevelChunk})}),(0,p.jsxs)(E.yC,{spinning:T||L,size:"large",wrapperClassName:"h-full !w-full grow rounded-r-[8px] overflow-hidden",childStyle:{height:"100%",flexGrow:1,width:"100%"},children:[(0,p.jsx)(eA,{documentData:{curDoc:x,curDocId:w,curFormatType:null==x?void 0:x.format_type,docOptions:q},filePreviewData:{showOriginalFile:A,fileUrl:null==x?void 0:x.preview_tos_url},documentActions:{onChangeDoc:m,onRenameDoc:v,onToggleOriginalFile:k,onResegment:()=>{var e,t,n,i=(null==x?void 0:x.source_type)===B.NZ.Document;null===(e=u.upload)||void 0===e||e.call(u,{type:i?N.Cm.TEXT_DOC:N.Cm.TEXT,opt:N.VP.RESEGMENT,doc_id:null!=w?w:"",page_mode:null!==(t=c.pageMode)&&void 0!==t?t:"",bot_id:null!==(n=c.botID)&&void 0!==n?n:""})},onUpdateFrequency:()=>W({updateInterval:null==x?void 0:x.update_interval,updateType:null==x?void 0:x.update_type}),onDelete:U,reloadDataset:o},customUIElements:{linkOriginUrlButton:a,fetchSliceButton:l}}),(0,p.jsxs)("div",{className:"flex h-[calc(100%-56px)] grow w-full",children:[(0,p.jsx)(eD,{fileType:null==x?void 0:x.type,fileUrl:(null==x?void 0:x.preview_tos_url)||"",visible:A}),(0,p.jsx)("div",{ref:d,className:Y()("w-full grow h-full overflow-auto","px-[16px] pt-[16px]"),children:(null==x?void 0:null===(i=x.chunk_strategy)||void 0===i?void 0:i.chunk_type)===B.x2.LevelChunk?(0,p.jsx)(eM,{isProcessing:_,documentId:w,levelSegments:I,selectionIDs:P,onLevelSegmentsChange:j,onLevelSegmentDelete:F}):(0,p.jsx)(eO,{loading:T,isProcessing:_,documentId:w,renderData:M,onContentChange:D,onAddChunk:()=>{O(),z()},onDeleteChunk:()=>{H()}})})]})]})]}),V,$]})},eN=n("937393"),eP=(0,f.createContext)({importKnowledgeMenuSourceFeatureRegistry:void 0}),eR=()=>(0,f.useContext)(eP),eL=n("522426"),ej=e=>{var{triggerComponent:t,onVisibleChange:n,children:i}=e;return(0,p.jsx)(E.v2,{clickToHide:!0,trigger:"click",position:"bottomRight",onVisibleChange:n,render:(0,p.jsx)(E.v2.SubMenu,{mode:"menu",className:eL.Z["create-opt-select-down"],children:i}),children:t})},eF=e=>{var{triggerComponent:t,onVisibleChange:n,onChange:i}=e,{importKnowledgeMenuSourceFeatureRegistry:r}=eR();return(0,p.jsx)(ej,{triggerComponent:t,onVisibleChange:n,children:null==r?void 0:r.entries().map(e=>{var[t,{Component:n}]=e;return(0,p.jsx)(n,{onClick:e=>null==i?void 0:i(e)},t)})})},eB=e=>{var t=null==e?void 0:e[0];return t?t.status===B._m.Processing?w.o.t("knowledge_add_content_processing_tips"):(null==t?void 0:t.slice_count)>=O.fj?w.o.t("kl2_002"):"":""},ez=e=>{var t;return(null==e?void 0:e.doc_count)>=O.by?w.o.t("kl2_003"):(null==e?void 0:null===(t=e.processing_file_id_list)||void 0===t?void 0:t.length)?w.o.t("knowledge_add_content_processing_tips"):""},eH=(e,t)=>{var n=null==e?void 0:e.format_type,i={[B.a5.Table]:()=>eB(t),default:()=>ez(e)};return n?(i[n]||i.default)():i.default()},eV=e=>{var{disabledTooltip:t,onSourceChange:n}=e,i=(0,g.PR)(e=>e.documentList),r=(0,g.PR)(e=>e.dataSetDetail),[o,s]=(0,f.useState)(!1),a=(0,g.EV)(),l=null!=t?t:eH(r,i),d=(0,eN.S)();return l?(0,p.jsx)(E.u,{content:l,arrowPointAtCenter:!1,position:"top",children:(0,p.jsx)(E.zx,{"data-testid":ex.w.SegmentDetailAddBtn,color:"hgltplus",disabled:!0,iconPosition:"right",icon:(0,p.jsx)(eT.Wdl,{className:"text-[12px]"}),children:w.o.t("knowledg_unit_add_segments")})}):(0,p.jsx)(eF,{onVisibleChange:e=>{s(e)},onChange:e=>{if(n){n(e);return}var t,o,s=null==r?void 0:r.format_type,l=null==i?void 0:null===(t=i[0])||void 0===t?void 0:t.document_id,c=(0,u._)({type:e},d);s===B.a5.Table&&l&&(c.opt=N.VP.INCREMENTAL,c.doc_id=l),null===(o=a.upload)||void 0===o||o.call(a,c)},triggerComponent:(0,p.jsx)(E.zx,{"data-testid":ex.w.SegmentDetailAddBtn,iconPosition:"right",icon:o?(0,p.jsx)(Q.uDC,{className:"text-[12px]"}):(0,p.jsx)(eT.Wdl,{className:"text-[12px]"}),children:w.o.t("knowledg_unit_add_segments")})})},eU=n("157728"),e$=n("328591"),eW=n("189284"),eq=n("379361"),eG={[B.a5.Table]:{icon:(0,p.jsx)(eT.J_i,{}),bgColor:"#35C566",suffixIcon:(0,p.jsx)(eT.plM,{}),suffixBgColor:"rgba(255,150,0,1)"},[B.a5.Text]:{icon:(0,p.jsx)(eT.rwS,{}),bgColor:"rgba(34, 136, 255, 1)",suffixIcon:(0,p.jsx)(eT.plM,{}),suffixBgColor:"rgba(255,150,0,1)"}},eK=e=>{var t,n,i,r,{formatType:o=B.a5.Text,hasSuffix:s,className:a}=e;return(0,p.jsxs)("div",{className:Y()(eq.Z["icon-with-suffix"],a),children:[(0,p.jsx)("div",{className:Y()("icon-with-suffix-common","icon"),style:{backgroundColor:"".concat(null==eG?void 0:null===(t=eG[o])||void 0===t?void 0:t.bgColor)},children:null==eG?void 0:null===(n=eG[o])||void 0===n?void 0:n.icon}),s?(0,p.jsx)("div",{className:Y()("icon-with-suffix-common","suffix"),style:{backgroundColor:"".concat(null==eG?void 0:null===(i=eG[o])||void 0===i?void 0:i.suffixBgColor)},children:null==eG?void 0:null===(r=eG[o])||void 0===r?void 0:r.suffixIcon}):null]})},eZ=e=>{var{formatType:t,sourceType:n,isDisconnect:i,className:r,iconSuffixClassName:o}=e;return n&&([B.NZ.Notion,B.NZ.GoogleDrive].includes(n)||(0,ey.$6)(n))?(0,p.jsx)(eK,{hasSuffix:!!i,formatType:t,className:o}):t===B.a5.Table?(0,p.jsx)(eT.Ov0,{className:r}):(0,p.jsx)(eT.r90,{className:r})},eY=n("848032"),eX=n("286144"),eJ=()=>{var e=(0,g.PR)(e=>e.photoFilterValue),t=(0,g.PR)(e=>e.setPhotoFilterValue);return(0,p.jsxs)("div",{className:eX.Z["photo-filter-tab"],children:[(0,p.jsx)("div",{"data-testid":ex.w.ImageAnnotationAllTab,onClick:()=>t(eY.X.All),className:e===eY.X.All?eX.Z["photo-filter-tab-item-active"]:eX.Z["photo-filter-tab-item"],children:w.o.t("knowledge-dataset-type-all")},eY.X.All),(0,p.jsx)(E.iz,{layout:"vertical",margin:"12px"}),(0,p.jsx)("div",{"data-testid":ex.w.ImageAnnotationAnnotationedTab,onClick:()=>t(eY.X.HasCaption),className:e===eY.X.HasCaption?eX.Z["photo-filter-tab-item-active"]:eX.Z["photo-filter-tab-item"],children:w.o.t("knowledge_photo_013")},eY.X.HasCaption),(0,p.jsx)(E.iz,{layout:"vertical",margin:"12px"}),(0,p.jsx)("div",{"data-testid":ex.w.ImageAnnotationUnAnnotationTab,onClick:()=>t(eY.X.NoCaption),className:e===eY.X.NoCaption?eX.Z["photo-filter-tab-item-active"]:eX.Z["photo-filter-tab-item"],children:w.o.t("knowledge_photo_014")},eY.X.NoCaption)]})},eQ=e=>{var t,n,i,r,{dataSetDetail:o,docInfo:s,progressMap:a={}}=e,l=null==o?void 0:o.format_type,d=(0,f.useMemo)(()=>{if(!s)return"";var e=P[null==s?void 0:s.update_type];return s.update_interval&&(e="".concat(w.o.t("datasets_segment_tag_updateFrequency",{num:s.update_interval}))),e},[s]);return(0,p.jsx)("div",{className:"flex pb-[4px]","data-testid":ex.w.UnitDetailTags,children:(0,p.jsxs)(E.T,{spacing:4,className:"[&_.semi-tag-content]:font-medium",children:[(null==o?void 0:o.all_file_size)?(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:(0,H.td)(parseInt(String(o.all_file_size)))}):null,l===B.a5.Table&&!!s&&(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:ei(s)}),l===B.a5.Table&&s&&(null==s?void 0:s.source_type)===B.NZ.Web?(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:d}):null,l===B.a5.Text&&!!(null==o?void 0:o.doc_count)&&(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:w.o.t("kl2_009",{num:null!==(i=null==o?void 0:o.doc_count)&&void 0!==i?i:0})}),l===B.a5.Image&&(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:w.o.t("dataset_detail_source_local")}),l===B.a5.Image&&!!(null==o?void 0:o.doc_count)&&(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:w.o.t("knowledge_photo_015",{num:(null==o?void 0:o.doc_count)||0})}),l!==B.a5.Image&&!!(null==o?void 0:o.doc_count)&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:w.o.t("datasets_segment_tag_segments",{num:null!==(r=null==o?void 0:o.slice_count)&&void 0!==r?r:0})}),(0,p.jsx)(E.Vp,{size:"mini",color:"primary",children:w.o.t("datasets_segment_card_hit",{num:null==o?void 0:o.hit_count})})]}),(null==o?void 0:o.storage_location)===B.Ac.OpenSearch?(0,p.jsx)(E.Vp,{size:"mini",color:"cyan",children:w.o.t("knowledge_es_001")}):null,!!(null==o?void 0:o.processing_file_id_list)&&!!(null==o?void 0:null===(t=o.processing_file_id_list)||void 0===t?void 0:t.length)&&(0,p.jsxs)(E.Vp,{size:"mini",color:"blue","data-testid":ex.w.UnitDetailTagsProcessing,children:[w.o.t("datasets_segment_tag_processing"),(null==s?void 0:s.format_type)===B.a5.Table&&(null==a?void 0:a[null==s?void 0:s.document_id])?"".concat(null==a?void 0:null===(n=a[null==s?void 0:s.document_id])||void 0===n?void 0:n.progress,"%"):""]}),l===B.a5.Table&&(null==s?void 0:s.status)===B._m.Failed&&(0,p.jsx)(E.Vp,{size:"mini",color:"red","data-testid":ex.w.UnitDetailTagsFailed,children:(null==s?void 0:s.status_descript)||w.o.t("dataset_process_fail")})]})})},e0=n("552639"),e1=e=>{var{datasetId:t,style:n,classNameItem:i}=e,{loading:r,data:o,run:s,error:a}=(0,b.Z)((0,v._)(function*(){return(yield S.MJ.GetDatasetRefBots({dataset_id:t})).ref_bots}),{onError:e=>{C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeGetDatasetRefDetail,error:e})},manual:!0});return((0,f.useEffect)(()=>{s()},[t]),a)?(0,p.jsx)("div",{children:w.o.t("knowledge_optimize_020")}):r?(0,p.jsx)(E.gb,{loading:r}):(0,p.jsx)("div",{className:e0.Z["related-bots-list"],children:null==o?void 0:o.map(e=>(0,p.jsxs)("div",{className:i||e0.Z["related-bots-list-item"],style:n,children:[(0,p.jsx)("div",{className:"related-bots-circle",children:"."}),(0,p.jsx)("div",{children:e.name})]},e.name))})};n("852497"),I.a5.Table,eT.J_i,eT.plM,I.a5.Text,eT.rwS,eT.plM,n("824113"),n("941415");var e2=n("427286"),e5=e=>{var t,{title:n,actionButtons:i,datasetDetail:r,docInfo:o,onBack:s,beforeBack:a,importKnowledgeSourceButton:l}=e,d=(0,g.PR)(e=>e.setSearchValue),c=(0,g.PR)(e=>e.dataSetDetail),h=(0,g.PR)(e=>e.canEdit),u=(0,g.kF)();(0,f.useEffect)(()=>()=>{d("")},[]);var m=(null==c?void 0:c.format_type)===B.a5.Image;return(0,p.jsxs)("div",{className:Y()("flex items-center justify-between shrink-0 h-[56px]",e2.Z.navbar),"data-testid":ex.w.KnowledgeAddContentNavBar,children:[(0,p.jsxs)("div",{className:e2.Z.brief,children:[(0,p.jsx)(E.hU,{color:"secondary",icon:(0,p.jsx)(Q.rmE,{className:"text-[16px]"}),iconPosition:"left",className:"".concat(e2.Z["back-icon"]," mr-[8px]"),onClick:()=>{null==a||a(),null==s||s()}}),(null==r?void 0:r.icon_url)?(0,p.jsx)(E.qE,{src:null==r?void 0:r.icon_url,shape:"square"}):(0,p.jsx)(eZ,{formatType:er(null!==(t=u.type)&&void 0!==t?t:N.Cm.TEXT),className:e2.Z["doc-icon-note"],iconSuffixClassName:"icon-with-suffix-overlay"}),(0,p.jsxs)("div",{className:"ml-[12px]",children:[(0,p.jsx)("p",{className:"text-[18px] font-medium",children:n}),!!r&&(0,p.jsx)(eQ,{dataSetDetail:r,docInfo:o})]})]}),(0,p.jsx)("div",{className:e2.Z.toolbar,children:(0,p.jsxs)(E.T,{spacing:12,children:[m?(0,p.jsx)(eJ,{}):null,h?l:null,i]})})]})},e3=n("399639"),e4=e=>{var t,n,i,r,{onChangeDataset:o,progressMap:s,hideBackButton:a,textConfigButton:l,tableConfigButton:d,importKnowledgeSourceButton:c,onBack:h}=e,m=(0,g.PR)(e=>e.dataSetDetail),b=(0,g.PR)(e=>e.canEdit),y=(0,g.PR)(e=>e.documentList),x=(0,eU.useNavigate)(),_=(0,g.kF)(),[C]=(0,eW.V)();var{node:A,edit:k}=(0,e$.Ej)({onOk:(t=(0,v._)(function*(e){var t,n,i,r,s;yield S.MJ.UpdateDataset({dataset_id:e.id,name:e.name,icon_uri:null===(t=e.icon_uri)||void 0===t?void 0:t[0].uid,description:e.description}),o((0,V._)((0,u._)({},m),{name:(null==e?void 0:e.name)||(null==m?void 0:m.name),description:(null==e?void 0:e.description)||(null==m?void 0:m.description),icon_uri:(null===(i=e.icon_uri)||void 0===i?void 0:null===(n=i.at(0))||void 0===n?void 0:n.uid)||(null==m?void 0:m.icon_uri),icon_url:(null===(s=e.icon_uri)||void 0===s?void 0:null===(r=s.at(0))||void 0===r?void 0:r.url)||(null==m?void 0:m.icon_url)}))}),function(e){return t.apply(this,arguments)})}),T=(null==m?void 0:m.format_type)===B.a5.Table,M=(null==m?void 0:m.format_type)===B.a5.Image,D=b&&!T&&!!(null==m?void 0:m.doc_count)&&!(null==m?void 0:null===(n=m.processing_file_id_list)||void 0===n?void 0:n.length)&&!M,O=null==y?void 0:y[0],I=(0,f.useMemo)(()=>O?et({format_type:B.a5.Table,source_type:null==O?void 0:O.source_type}):N.Cm.TABLE_API,[O]),P=((0,f.useMemo)(()=>I&&[N.Cm.TABLE_API,N.Cm.TABLE_GOOGLE_DRIVE,N.Cm.TABLE_FEISHU,N.Cm.TABLE_LARK].includes(I),[I])||b)&&T&&(null==y?void 0:y.length),R="project"===_.biz;return(0,p.jsxs)("div",{className:Y()("flex items-center justify-between shrink-0",R?"px-[16px] py-[12px]":"h-[56px]",e3.Z.brief),children:[(0,p.jsxs)("div",{className:e3.Z.info,children:[a?null:(0,p.jsx)(E.hU,{style:{display:"none"},color:"secondary",icon:(0,p.jsx)(Q.$1i,{className:"text-[16px]"}),iconPosition:"left",onClick:()=>{null==h||h(),x("/space/".concat(_.spaceID,"/library"))},className:"mr-[4px]"}),(0,p.jsx)("div",{className:e3.Z.icon,children:(null==m?void 0:m.icon_url)?(0,p.jsx)(E.qE,{src:null==m?void 0:m.icon_url,shape:"square",size:"default"}):(0,p.jsx)(eZ,{formatType:(null==m?void 0:m.format_type)||B.a5.Text,className:e3.Z["doc-icon-note"],iconSuffixClassName:"icon-with-suffix-overlay"})}),(0,p.jsxs)("div",{className:e3.Z.content,children:[(0,p.jsxs)("div",{className:"flex items-center gap-[3px]",children:[(0,p.jsx)(E.ZT.Text,{"data-testid":ex.w.SegmentDetailTitle,className:e3.Z.title,weight:500,ellipsis:{showTooltip:{opts:{content:null==m?void 0:m.name}}},children:null==m?void 0:m.name}),b?(0,p.jsx)(E.u,{content:w.o.t("datasets_segment_edit"),children:(0,p.jsx)(E.hU,{"data-testid":ex.w.SegmentDetailTitleEditIcon,size:"mini",style:{display:"none"},color:"secondary",icon:(0,p.jsx)(Q.JAz,{className:"text-[14px]"}),iconPosition:"left",wrapperClass:"text-[0] leading-none",className:"coz-fg-secondary",onClick:()=>{k({id:m.dataset_id||"",name:null==m?void 0:m.name,description:null==m?void 0:m.description,icon_uri:[{url:(null==m?void 0:m.icon_url)||"",uid:(null==m?void 0:m.icon_uri)||""}]})}})}):null,C["bot.data.knowledge_bots_count"]?(0,p.jsxs)("div",{className:e3.Z["bot-count"],children:[(0,p.jsx)("div",{className:e3.Z["bot-count-text"],children:w.o.t("knowledge_optimize_019",{n:null!==(i=null==m?void 0:m.bot_used_count)&&void 0!==i?i:0})}),!!(null==m?void 0:m.bot_used_count)&&(0,p.jsx)(E.u,{autoAdjustOverflow:!0,position:(null==m?void 0:m.bot_used_count)>2?"bottom":"top",content:(0,p.jsx)(e1,{datasetId:null!==(r=null==m?void 0:m.dataset_id)&&void 0!==r?r:"",classNameItem:e3.Z["bot-used-count"]}),children:(0,p.jsx)(Q.L03,{className:e3.Z["bot-count-icon"]})})]}):null]}),(0,p.jsx)(eQ,{dataSetDetail:m,docInfo:null==y?void 0:y[0],progressMap:s})]})]}),(0,p.jsx)("div",{children:(0,p.jsxs)(E.T,{spacing:10,children:[M?(0,p.jsx)(eJ,{}):null,D?l:null,P?d:null,b?c:null]})}),A]})},e6=e=>{var{progressMap:t,hideBackButton:n,importKnowledgeSourceButton:i}=e,{setDataSetDetail:r}=(0,g.PR)((0,m.N)(e=>({setDataSetDetail:e.setDataSetDetail})));return(0,p.jsx)(e4,(0,V._)((0,u._)({},e),{importKnowledgeSourceButton:null!=i?i:(0,p.jsx)(eV,{}),onChangeDataset:r,progressMap:t,hideBackButton:n}))},e8=e=>{var{title:t,icon:n,testId:i,value:r,onClick:o}=e;return(0,p.jsx)(E.v2.Item,{icon:null!=n?n:null,onClick:()=>{r&&o&&o.call(void 0,r)},"data-testid":i,children:t},r)},e7={Component:e=>{var{onClick:t}=e;return(0,p.jsx)(e8,{title:w.o.t("datasets_createFileModel_step1_LocalTitle"),icon:(0,p.jsx)(Q.da8,{className:"w-4 h-4"}),testId:"".concat(ex.w.SegmentDetailDropdownItem,".").concat(N.Cm.TEXT_DOC),value:N.Cm.TEXT_DOC,onClick:()=>t(N.Cm.TEXT_DOC)})}},e9={Component:e=>{var{onClick:t}=e;return(0,p.jsx)(e8,{title:w.o.t("datasets_createFileModel_step1_CustomTitle"),icon:(0,p.jsx)(Q.YRi,{className:"w-4 h-4"}),testId:"".concat(ex.w.SegmentDetailDropdownItem,".").concat(N.Cm.TEXT_CUSTOM),value:N.Cm.TEXT_CUSTOM,onClick:()=>t(N.Cm.TEXT_CUSTOM)})}},te={Component:e=>{var{onClick:t}=e;return(0,p.jsx)(e8,{title:w.o.t("datasets_createFileModel_step1_TabCustomTitle"),icon:(0,p.jsx)(Q.YRi,{className:"w-4 h-4"}),testId:"".concat(ex.w.SegmentDetailDropdownItem,".").concat(N.Cm.TABLE_CUSTOM),value:N.Cm.TABLE_CUSTOM,onClick:()=>t(N.Cm.TABLE_CUSTOM)})}},tt={Component:e=>{var{onClick:t}=e;return(0,p.jsx)(e8,{title:w.o.t("datasets_createFileModel_step1_TabLocalTitle"),icon:(0,p.jsx)(Q.da8,{className:"w-4 h-4"}),testId:"".concat(ex.w.SegmentDetailDropdownItem,".").concat(N.Cm.TABLE_DOC),value:N.Cm.TABLE_DOC,onClick:()=>t(N.Cm.TABLE_DOC)})}},tn={Component:e=>{var{onClick:t}=e;return(0,p.jsx)(e8,{title:w.o.t("knowledge_photo_002"),icon:(0,p.jsx)(Q.da8,{className:"w-4 h-4"}),testId:"".concat(ex.w.SegmentDetailDropdownItem,".").concat(N.Cm.IMAGE_FILE),value:N.Cm.IMAGE_FILE,onClick:()=>t(N.Cm.IMAGE_FILE)})}},ti=n("304194"),tr=e=>new ti.j({name:e});var to={importKnowledgeMenuSourceFeatureRegistry:((o=tr("import-knowledge-source-text-menu")).registerSome([{type:"text-local",module:e7},{type:"text-custom",module:e9}]),o)},ts=e=>(0,p.jsx)(eP.Provider,{value:to,children:(0,p.jsx)(K,(0,u._)({renderNavBar:t=>{var{statusInfo:n}=t;return(0,p.jsx)(e6,(0,u._)({progressMap:n.progressMap},e.navBarProps))},renderContent:t=>{var n,i,{dataActions:r,statusInfo:o}=t;return(0,p.jsx)(eI,{progressMap:o.progressMap,reload:r.refreshData,onChangeDocList:r.updateDocumentList,linkOriginUrlButton:null===(n=e.contentProps)||void 0===n?void 0:n.linkOriginUrlButton,fetchSliceButton:null===(i=e.contentProps)||void 0===i?void 0:i.fetchSliceButton})}},e.layoutProps))}),ta=n("512946"),tl=()=>{var e,t=(0,g.PR)(e=>e.documentList),n=null==t?void 0:null===(e=t[0])||void 0===e?void 0:e.document_id,{data:i,mutate:r,reload:o,loadMore:s,loading:a,loadingMore:l}=$({params:{document_id:n},reloadDeps:[n],target:null,onError:e=>{C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeGetSliceList,error:e}),E.FN.error(w.o.t("knowledge_document_view"))}});return{sliceListData:i,mutateSliceListData:r,reloadSliceList:o,loadMoreSliceList:s,isLoadingMoreSliceList:l,isLoadingSliceList:a}},td=(0,f.createContext)(null),tc=()=>{var e=(0,f.useContext)(td);if(!e)throw Error("useTableUI must be used within a TableUIProvider");return e},th=(0,f.createContext)(null),tu=()=>{var e=(0,f.useContext)(th);if(!e)throw Error("useTableData must be used within a TableDataProvider");return e},tp=(0,f.createContext)(null),tf=()=>{var e=(0,f.useContext)(tp);if(!e)throw Error("useTableActions must be used within a TableActionsProvider");return e},tm=n("461190"),tg=n("962289"),tv=n("594022"),tb=n("757208"),ty=e=>(0,p.jsx)(E.Vp,{color:"primary",className:"ml-[6px] text-xs",size:"mini",children:(0,ey.y8)(e.columnType)}),tx=e=>{try{var t;return null!==(t=tm._N.getTableWidthMap(e))&&void 0!==t?t:{}}catch(e){return console.log("getTableCacheWidthMap error",e),{}}},tw=e=>{var{sliceList:t,metaData:n=[],onEdit:i,onUpdate:r,onDelete:o,canEdit:s,tableKey:a}=e;try{var l=document.getElementsByClassName("knowledge-ide-base-slice-list-ui-content")[0],d=tx(a),c=l?l.offsetWidth-(s?397:259):1400,h=t.map(e=>{var{char_count:t,hit_count:n,status:i}=e,r={char_count:t,hit_count:n,status:i},o=(0,H.dj)(e.content);return Array.isArray(o)&&o.forEach(e=>{r[e.column_id]=e.value}),r}),f=c/n.length>200?c/n.length:200,m=n.map((e,n)=>{var i;return{dataIndex:e.id,title:(0,p.jsxs)("div",{className:"flex flex-row items-center",children:[(0,p.jsx)(E.ZT.Text,{className:"cursor-pointer",ellipsis:{showTooltip:{opts:{content:e.column_name}}},children:e.column_name}),e.is_semantic?(0,p.jsx)(E.Vp,{size:"mini",color:"green",className:"ml-2","data-testid":ex.w.TableLocalPreviewSemantic,children:w.o.t("knowledge_1226_001")}):null,e.column_type?(0,p.jsx)(ty,{columnType:e.column_type}):null]}),width:null!==(i=(0,tg.Z)(d,e.id||""))&&void 0!==i?i:f,render:(i,o,a)=>{var l=0===n&&a===t.length-1&&!!t[a].addId;if(e.column_type===tv.QD.Image){var d=(0,O.bp)(i);return(0,p.jsx)(tm.e0,{srcList:d,onChange:(t,n)=>{var i="";(t||n)&&(i='"));var s=(0,V._)((0,u._)({},o),{[null==e?void 0:e.id]:i});null==r||r(s,a)}})}var c=(null==o?void 0:o.status)===tb.OL.AuditFailed,h=()=>{var t;return(0,p.jsx)("div",{className:"w-full ".concat(c?"text-red-500":""),children:(0,p.jsx)(tm.EY,{dataIndex:e.id,value:i,record:o,index:a,isEditing:l,editable:s,validator:{validate:t=>!!e.is_semantic&&(!t||""===t),errorMsg:w.o.t("datasets_url_empty")},onBlur:(t=(0,v._)(function*(e,t){return yield null==r?void 0:r(t,a,e)}),function(e,n){return t.apply(this,arguments)})})})};return c?(0,p.jsx)(E.u,{content:w.o.t("knowledge_content_illegal_error_msg"),trigger:"hover",position:"top",getPopupContainer:()=>document.body,children:h()}):h()}}});return m.push({title:"",className:"not-resize-handle data-tags",resize:!1,render:(e,t,n)=>{var{char_count:i,hit_count:r}=t;return(0,p.jsxs)("div",{className:"flex gap-3",children:[(0,p.jsx)(tm.wn,{value:"".concat(null!=i?i:0," ").concat(w.o.t("datasets_segment_card_bit",{num:null!=i?i:0}))}),(0,p.jsx)(tm.wn,{value:w.o.t("datasets_segment_card_hit",{num:null!=r?r:0})})]})}}),s&&m.push({title:"",width:100,className:"not-resize-handle",resize:!1,render:(e,t,n)=>(0,p.jsx)(tm.E2,{record:t,index:n,editProps:{disabled:!1,onEdit:()=>{null==i||i(t,n)}},deleteProps:{disabled:!1,onDelete:()=>{null==o||o([n])}}})}),m.unshift({title:"",width:68,fixed:!0,resize:!1,className:"pl-0 text-sm not-resize-handle",render:(e,t,n)=>(0,p.jsx)("div",{className:"text-xs coz-fg-secondary",children:n+1})}),{data:h,columns:m}}catch(e){return console.log("transSliceList handler error",e),{data:[],columns:[]}}},t_=n("335740"),tS=()=>{var e=(0,g.PR)(e=>e.dataSetDetail),t=(0,g.PR)(e=>e.setDataSetDetail),{sliceListData:n}=tu(),{mutateSliceListData:i}=tf(),r=(0,g.PR)(e=>e.documentList),o=null==r?void 0:r[0],{createSlice:s}=G({onReload:r=>{var s,a,l,d,c,h,p=null!==(a=(null!==(s=null==n?void 0:n.list)&&void 0!==s?s:[]).filter(e=>!e.addId))&&void 0!==a?a:[],f=JSON.parse(null!==(l=r.content)&&void 0!==l?l:"{}"),m=(null!==(d=null==o?void 0:o.table_meta)&&void 0!==d?d:[]).reduce((e,t)=>{var n,i;return e.push({column_name:null!==(n=null==t?void 0:t.column_name)&&void 0!==n?n:"",column_id:null!==(i=null==t?void 0:t.id)&&void 0!==i?i:"",value:t.id?f[t.id]:""}),e},[]);p.push((0,V._)((0,u._)({},r),{content:JSON.stringify(m)})),i((0,V._)((0,u._)({},n),{total:Number(null!==(c=null==n?void 0:n.total)&&void 0!==c?c:"0"),list:p})),e&&t((0,V._)((0,u._)({},e),{slice_count:null!==(h=null==p?void 0:p.length)&&void 0!==h?h:0}))}});return{createSlice:s}},tC=e=>{var t,{openDeleteSliceModal:n,openTableSegmentModal:i}=e,r=(0,g.PR)(e=>e.documentList),{mutateSliceListData:o,setDelSliceIds:s,setCurIndex:a,setCurSliceId:l}=tf(),{createSlice:d}=tS(),{sliceListData:c}=tu(),{tableViewRef:h}=tc(),p=null==r?void 0:r[0],f=null==c?void 0:c.list,m=e=>{if(!!(null==p?void 0:p.document_id))try{return{document_id:p.document_id,raw_text:e}}catch(e){return console.log("error",e),null}};var b=(t=(0,v._)(function*(e,t,n){if(!!f){var i=(0,t_.Z)(c);try{var r,s=f[t].slice_id,a=Object.fromEntries(Object.entries(e).filter(e=>{var[t]=e;return!["tableViewKey","char_count","hit_count"].includes(t)})),l=[];null==p||null===(r=p.table_meta)||void 0===r||r.forEach(e=>{e.column_type===tv.QD.Image&&l.push(e.id)});var h=Object.fromEntries(Object.entries(a).map(e=>{var[t,n]=e;return l.includes(t)?[t,(0,O.Yw)(n)]:[t,n]})),g=(0,u._)({},h);delete g.status;var v=JSON.stringify(g);if(s)yield q(s,v,n);else if((yield m(v))&&d&&(null==p?void 0:p.document_id))try{yield d({document_id:p.document_id,raw_text:v})}catch(e){console.log("createSlice error:",e)}if(f)return!0}catch(e){throw console.log(e),o(i),Error(e)}}}),function(e,n,i){return t.apply(this,arguments)});return{deleteSlice:e=>{if(!!f){var t,i,r=e.filter(e=>!f[e].slice_id),a=r.map(e=>{var t;return null===(t=f[e])||void 0===t?void 0:t.addId}),l=e.filter(e=>!r.includes(e)).map(e=>f[e].slice_id).filter(Boolean);a.length&&l.length<=0&&(o((0,V._)((0,u._)({},c),{total:Number(null!==(i=null==c?void 0:c.total)&&void 0!==i?i:"0"),list:f.filter(e=>!a.includes(null==e?void 0:e.addId))})),null==h||null===(t=h.current)||void 0===t||t.resetSelected()),l.length&&(s(l),n())}},createSlice:m,modalEditSlice:(e,t)=>{var n,r;if(!!f&&!(t<0)&&!(t>=f.length))a(t),l((null===(n=f[t])||void 0===n?void 0:n.slice_id)||""),i((null===(r=f[t])||void 0===r?void 0:r.content)||"")},rowUpdateSliceData:b}},tA=()=>{var e,t=(0,g.PR)(e=>e.documentList),{sliceListData:n,curIndex:i,curSliceId:r}=tu(),{mutateSliceListData:o}=tf(),s=null==t?void 0:t[0];var{node:a,edit:l,fetchCreateTableSegment:d,fetchUpdateTableSegment:c}=(0,O.nV)({title:i>-1?(0,p.jsx)("div",{className:"slice-modal-title",children:w.o.t("datasets_segment_detailModel_title",{num:i+1})}):w.o.t("dataset_segment_content"),meta:(null==s?void 0:s.table_meta)||[],canEdit:!0,onSubmit:(e=(0,v._)(function*(e,t){e===O.wO.Create&&(null==s?void 0:s.document_id)?yield d(null==s?void 0:s.document_id,t):e===O.wO.Edit&&r&&(yield c(r,t))}),function(t,n){return e.apply(this,arguments)}),onFinish:(e,t)=>{if(e===O.wO.Create)E.FN.success({content:w.o.t("knowledge_tableview_03"),showClose:!1});else if(e===O.wO.Edit&&n){var r=JSON.stringify(t),s=n.list;s[i].content=r,s[i].status=tb.OL.FinishVectoring,o((0,V._)((0,u._)({},n),{list:s}))}}});return{tableSegmentModalNode:a,openTableSegmentModal:l,fetchCreateTableSegment:d,fetchUpdateTableSegment:c}},tE=()=>{var e=(0,g.PR)(e=>e.dataSetDetail),t=(0,g.PR)(e=>e.setDataSetDetail),n=(0,g.PR)(e=>e.documentList),{sliceListData:i,delSliceIds:r}=tu(),{tableViewRef:o}=tc(),{mutateSliceListData:s}=tf(),a=null==n?void 0:n[0],l=null==i?void 0:i.list,{node:d,delete:c}=(0,O.qS)({onDel:(0,v._)(function*(){try{if(yield W(r),!a)return;E.FN.success({content:w.o.t("Delete_success"),showClose:!1}),console.log("oldList",l);var n,d=(l||[]).filter(e=>{var t,n;return!r.includes(null!==(t=e.slice_id)&&void 0!==t?t:"")&&!r.includes(null!==(n=e.addId)&&void 0!==n?n:"")});s((0,V._)((0,u._)({},i),{list:d})),console.log("newList",d),null==o||null===(n=o.current)||void 0===n||n.resetSelected(),e&&"number"==typeof e.slice_count&&t((0,V._)((0,u._)({},e),{slice_count:e.slice_count>-1?Math.max(0,e.slice_count-((null==r?void 0:r.length)||0)):0}))}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeDeleteSlice,error:e})}})});return{deleteSliceModalNode:d,openDeleteSliceModal:c}},tk=e=>{var{increaseTableHeight:t,scrollTableBodyToBottom:n}=e,{sliceListData:i}=tu(),{mutateSliceListData:r}=tf();return{handleAddRow:()=>{t(56);var e,o,s,a=JSON.parse(null!==(o=null==i?void 0:null===(e=i.list[0])||void 0===e?void 0:e.content)&&void 0!==o?o:"[]"),l=null==a?void 0:a.map(e=>(0,V._)((0,u._)({},e),{value:"",char_count:0,hit_count:0}));r((0,V._)((0,u._)({},i),{total:Number(null!==(s=null==i?void 0:i.total)&&void 0!==s?s:"0"),list:null==i?void 0:i.list.concat([{content:JSON.stringify(l),addId:(0,J.x0)()}])})),n()}}},tT=()=>{var{tableViewRef:e,isShowAddBtn:t}=tc(),{sliceListData:n}=tu(),[i,r]=(0,f.useState)(0);return(0,f.useEffect)(()=>{var n,i=null==e?void 0:null===(n=e.current)||void 0===n?void 0:n.getTableHeight();i&&r(t?i:"100%")},[n,t,e]),{tableH:i,increaseTableHeight:e=>{r(Number(null!=i?i:"0")+e)}}},tM=()=>{var{sliceListData:e}=tu();return{scrollTableBodyToBottom:()=>{var t=document.querySelector(".table-view-box .semi-table-container>.semi-table-body");t&&(null==e?void 0:e.list.length)&&(t.scrollTop=(null==e?void 0:e.list.length)*56)}}},tD=()=>{var e=(0,g.DY)(e=>e.params.biz),t=(0,g.PR)(e=>e.documentList),n=null==t?void 0:t[0],{tableViewRef:i,isLoadingMoreSliceList:r,isLoadingSliceList:o}=tc(),{sliceListData:s}=tu(),a=null==s?void 0:s.list,{loadMoreSliceList:l}=tf(),d=!!(0,g.PR)(e=>e.canEdit),{deleteSliceModalNode:c,openDeleteSliceModal:h}=tE(),{tableSegmentModalNode:u,openTableSegmentModal:f}=tA(),{deleteSlice:m,rowUpdateSliceData:v,modalEditSlice:b}=tC({openDeleteSliceModal:h,openTableSegmentModal:f}),{tableH:y}=tT();if(!(null==a?void 0:a.length))return null;var x=null==n?void 0:n.document_id,{data:w,columns:_}=tw({sliceList:a,metaData:null==n?void 0:n.table_meta,onEdit:b,onDelete:m,onUpdate:v,canEdit:d,tableKey:x||""});return(0,p.jsxs)("div",{className:Y()(ta.Z["table-view-container-box"],"table-view-box"),style:{height:y},children:[(0,p.jsx)(tm.HA,{tableKey:x,ref:i,className:Y()("".concat(ta.Z["unit-table-view"]," ").concat(r?ta.Z["table-view-loading"]:""),"project"===e?ta.Z["table-preview-max"]:ta.Z["table-preview-secondary"]),resizable:!0,dataSource:w,loading:o,columns:_,rowSelect:d,isVirtualized:!0,rowOperation:d,scrollToBottom:()=>{!o&&!r&&l()},editProps:{onDelete:e=>m(e),onEdit:(e,t)=>{b(e,t)}}}),c,u]})},tO=()=>{var{isShowAddBtn:e}=tc(),t=(0,g.PR)(e=>e.documentList),n=null==t?void 0:t[0],{increaseTableHeight:i}=tT(),{scrollTableBodyToBottom:r}=tM(),{handleAddRow:o}=tk({increaseTableHeight:i,scrollTableBodyToBottom:r});return e?(0,p.jsx)("div",{className:ta.Z["add-row-btn"],children:(0,p.jsx)(E.zx,{disabled:(null==n?void 0:n.status)===B._m.Processing,"data-testid":ex.w.SegmentDetailContentAddRowBtn,color:"primary",size:"default",icon:(0,p.jsx)(Q.PwN,{}),onClick:o,children:w.o.t("knowledge_optimize_0010")})}):null},tI=()=>{var{sliceListData:e}=tu(),t=null==e?void 0:e.list;return(null==t?void 0:t.length)?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(tD,{}),(0,p.jsx)(tO,{})]}):(0,p.jsx)(tO,{})},tN=e=>{var t,{isReloading:n}=e,i=(0,f.useRef)(null),r=(0,f.useRef)(null),o=(0,f.useRef)(null),s=(0,g.PR)(e=>e.canEdit),a=null===(t=(0,g.PR)(e=>e.documentList))||void 0===t?void 0:t.filter(e=>e.document_id),[l,d]=(0,f.useState)(0),[c,h]=(0,f.useState)(""),[u,m]=(0,f.useState)([]),{sliceListData:v,mutateSliceListData:b,loadMoreSliceList:y,isLoadingSliceList:x,isLoadingMoreSliceList:_}=tl(),S=null==v?void 0:v.list,C=(0,f.useMemo)(()=>!!(s&&!(null==v?void 0:v.hasMore)&&(null==v?void 0:v.total)&&(null==v?void 0:v.total)<1e3),[s,v]),A=(0,f.useMemo)(()=>(null==a?!void 0:!a.length)&&!n||(null==v?void 0:v.ready)&&!(null==S?void 0:S.length)&&!(_||x),[v,a,n,_,x,S]);return(0,p.jsx)(td.Provider,{value:{tableViewRef:o,isLoadingMoreSliceList:_,isLoadingSliceList:x,isShowAddBtn:C},children:(0,p.jsx)(th.Provider,{value:{sliceListData:v||{list:[],total:0},curIndex:l,curSliceId:c,delSliceIds:u},children:(0,p.jsx)(tp.Provider,{value:{setCurIndex:d,setCurSliceId:h,setDelSliceIds:m,loadMoreSliceList:y,mutateSliceListData:b},children:(0,p.jsx)(E.Ar.Content,{ref:i,className:Y()(ta.Z["slice-list-ui-content"],"knowledge-ide-base-slice-list-ui-content"),children:(0,p.jsxs)(E.yC,{spinning:x,wrapperClassName:ta.Z.spin,size:"large",style:{width:"100%",height:"100%"},children:[(null==S?void 0:S.length)?(0,p.jsx)("div",{ref:r,className:ta.Z["slice-list-table"],children:(0,p.jsx)(tI,{})}):null,A&&!x?(0,p.jsx)("div",{className:ta.Z["empty-content"],children:(0,p.jsx)(E.ub,{size:"large",icon:(0,p.jsx)(eT.s9d,{style:{width:150,height:"100%"}}),title:w.o.t("dataset_segment_empty_desc")})}):null]})})})})})},tP=n("704794"),tR=e=>{var{children:t}=e,[n,i]=(0,f.useState)(!1);return(0,p.jsx)(E.v2,{clickToHide:!0,keepDOM:!0,trigger:"click",position:"bottomRight",onVisibleChange:i,render:(0,p.jsx)(E.v2.SubMenu,{mode:"menu",className:tP.Z["table-config-menu-down"],children:t}),children:(0,p.jsx)(E.zx,{className:tP.Z["action-btn"],"data-testid":ex.w.SegmentDetailSystemBtn,icon:n?(0,p.jsx)(Q.uDC,{className:"text-[12px]"}):(0,p.jsx)(Q.Wdl,{className:"text-[12px]"}),iconPosition:"right",color:"primary",style:{minWidth:"45px",padding:"6px 6px 6px 8px"},children:(0,p.jsx)(Q.qBd,{})})})},tL=e=>{var{knowledgeTableConfigMenuContributes:t,onChangeDocList:n}=e,i=(0,g.PR)(e=>e.documentList),r=null==i?void 0:i[0],o=(0,g.PR)(e=>e.canEdit),{reload:s}=F();return t?(0,p.jsx)(tR,{children:o?null==t?void 0:t.entries().map(e=>{var[t,{Component:i}]=e;return(0,p.jsx)(i,{documentInfo:r,onChangeDocList:n,reload:s},t)}):null}):null},tj=e=>new ti.j({name:e}),tF={Component:e=>{var{documentInfo:t}=e,n=(0,g.EV)();return void 0!==t.update_type&&t.update_type!==B.$o.NoUpdate?null:(0,p.jsx)(E.v2.Item,{onClick:()=>{var e,i;null===(e=n.upload)||void 0===e||e.call(n,{type:"table",opt:N.VP.RESEGMENT,doc_id:null!==(i=null==t?void 0:t.document_id)&&void 0!==i?i:""})},children:w.o.t("knowledge_segment_config_table")})}};var tB=((s=tj("knowledge-ide-table-local-config-menu")).registerSome([{type:"configuration-table-structure",module:tF}]),s),tz=e=>(0,p.jsx)(tL,(0,V._)((0,u._)({},e),{knowledgeTableConfigMenuContributes:tB}));var tH=((a=tj("knowledge-ide-table-custom-config-menu")).registerSome([{type:"configuration-table-structure",module:tF}]),a),tV=e=>(0,p.jsx)(tL,(0,V._)((0,u._)({},e),{knowledgeTableConfigMenuContributes:tH})),tU=e=>{var t=(0,g.PR)(e=>{var t;return null===(t=e.documentList)||void 0===t?void 0:t[0]}),n=(0,f.useMemo)(()=>t?et({format_type:B.a5.Table,source_type:null==t?void 0:t.source_type}):N.Cm.TABLE_API,[t]);return n===N.Cm.TABLE_CUSTOM?(0,p.jsx)(tV,(0,u._)({},e)):n===N.Cm.TABLE_DOC?(0,p.jsx)(tz,(0,u._)({},e)):null};var t$={importKnowledgeMenuSourceFeatureRegistry:((l=tr("import-knowledge-source-table-menu")).registerSome([{type:"table-local",module:tt},{type:"table-custom",module:te}]),l)},tW=e=>(0,p.jsx)(eP.Provider,{value:t$,children:(0,p.jsx)(K,(0,u._)({renderNavBar:t=>{var{statusInfo:n,dataActions:i}=t;return(0,p.jsx)(e6,(0,u._)({progressMap:n.progressMap,tableConfigButton:(0,p.jsx)(tU,{onChangeDocList:i.updateDocumentList})},e.navBarProps))},renderContent:t=>{var{dataActions:n,statusInfo:i}=t;return(0,p.jsx)(tN,(0,u._)({reload:n.refreshData,onChangeDocList:n.updateDocumentList,isReloading:i.isReloading},e.contentProps))}},e.layoutProps))}),tq=n("479886"),tG=n.n(tq),tK=n("775699"),tZ=n("997700"),tY=n("815605"),tX=n("34018"),tJ=e=>{var t,{currentValue:n,document_id:i,disable:r,onChange:o,onProgress:s}=e;var a=(t=(0,v._)(function*(){var e,t=(e=(0,v._)(function*(){s(!0);try{var e=yield S.MJ.ExtractPhotoCaption({document_id:i});e.caption&&o(e.caption)}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeGeneratePhotoCaption,error:e})}finally{s(!1)}}),function(){return e.apply(this,arguments)});if(!n){yield t();return}tK.M5.warning({className:tX.Z["confirm-modal"],closeIcon:(0,p.jsx)(eT.bho,{}),title:w.o.t("knowledge_photo_021"),content:w.o.t("knowledge_photo_022"),icon:(0,p.jsx)(eT.xAI,{}),cancelText:w.o.t("Cancel"),okText:w.o.t("Confirm"),okButtonProps:{theme:"solid",type:"warning"},onOk:()=>{t()}})}),function(){return t.apply(this,arguments)});return(0,p.jsx)(tK.u,{content:w.o.t("knowledge_photo_020"),children:(0,p.jsx)(tK._3,{icon:(0,p.jsx)(tK.JO,{svg:(0,p.jsx)(tY.r,{color:r?"rgba(28, 31, 35, 0.35)":"#4D53E8"})}),className:"absolute !bottom-[8px] !left-[12px]",onClick:a,disabled:r})})},tQ=n("888122"),t0=e=>{var t,n,{photo:i={},photoList:r=[],canEdit:o=!1,setCurrentPhotoId:s,reload:a,progressMap:l,onCancel:d,onSubmit:c}=e,[h,u]=(0,f.useState)(!1),[m,g]=(0,f.useState)(!1),[b,x]=(0,f.useState)(!1),[_,A]=(0,f.useState)(""),{document_id:E,status:k}=i,T=r.findIndex(e=>e.document_id===E),M=(null===(n=l[E||""])||void 0===n?void 0:n.status)||k,D=M===B._m.Processing||M===B._m.Failed||!o;(0,f.useEffect)(()=>{h&&A(i.caption)},[h,E]);var O=(t=(0,v._)(function*(){if(D){u(!1);return}null==c||c(),x(!0);try{yield S.MJ.UpdatePhotoCaption({document_id:E,caption:_}),a(),x(!1),u(!1)}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeUpdatePhotoCaption,error:e}),x(!1)}}),function(){return t.apply(this,arguments)});return{node:(0,p.jsx)(tK.M5,{visible:h,onCancel:()=>{u(!1),null==d||d()},centered:!0,title:w.o.t("knowledge_photo_019"),width:792,onOk:O,okButtonProps:{disabled:D,loading:b},children:(0,p.jsxs)("div",{className:tQ.Z["modal-content"],children:[(0,p.jsxs)("div",{className:tQ.Z["photo-large"],children:[(0,p.jsx)(tK.Ee,{height:300,src:i.url}),T<1?null:(0,p.jsx)(tK.hU,{icon:(0,p.jsx)(tK.JO,{svg:(0,p.jsx)(tZ.r,{})}),className:tQ.Z["arrow-button"],style:{left:"24px"},onClick:()=>{var{document_id:e}=r[T-1];s(e)}}),-1===T||T===r.length-1?null:(0,p.jsx)(tK.hU,{icon:(0,p.jsx)(tK.JO,{rotate:180,svg:(0,p.jsx)(tZ.r,{})}),className:tQ.Z["arrow-button"],style:{right:"24px"},onClick:()=>{var{document_id:e}=r[T+1];s(e)}})]}),(0,p.jsxs)("div",{className:tQ.Z["photo-caption-textarea"],children:[(0,p.jsx)(tK.yC,{spinning:m,children:(0,p.jsx)(tK.Kx,{maxCount:2e3,maxLength:2e3,placeholder:w.o.t("knowledge_photo_026"),value:_,onChange:e=>A(e),disabled:D})}),(0,p.jsx)(tJ,{currentValue:_,document_id:E||"",disable:D,onChange:A,onProgress:g})]})]})}),open:()=>{u(!0)}}},t1=(e,t)=>{var n,i,{datasetID:r,searchValue:o,filterPhotoType:s}=e;var a=(n=(0,v._)(function*(e,t){try{var n=yield S.MJ.ListPhoto({page:null!=e?e:1,size:null!=t?t:O.by,dataset_id:r,filter:{keyword:o,has_caption:s===eY.X.HasCaption||s!==eY.X.NoCaption&&void 0}});return{list:n.photo_infos||[],total:n.total||0}}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgePhotoList,error:e})}}),function(e,t){return n.apply(this,arguments)});return(0,U.Z)((i=(0,v._)(function*(e){return a(e?Math.ceil(e.list.length/20)+1:1,20)}),function(e){return i.apply(this,arguments)}),(0,u._)({manual:!0},t))},t2=n("99057"),t5=e=>{var{progressMap:t}=e,[n,i]=(0,eU.useSearchParams)(),r=(0,g.kF)().first_auto_open_edit_document_id,[o,s]=(0,f.useState)(""),[a,l]=(0,f.useState)(""),d=(0,g.PR)(e=>e.dataSetDetail),c=(0,g.PR)(e=>e.canEdit),h=(0,g.PR)(e=>e.searchValue),u=(0,g.PR)(e=>e.photoFilterValue),m=(0,f.useRef)(null),{data:b,loading:x,loadingMore:_,reloadAsync:A,noMore:E}=t1({datasetID:null==d?void 0:d.dataset_id,filterPhotoType:u,searchValue:h},{isNoMore:e=>(null==e?void 0:e.list.length)>=(null==e?void 0:e.total),target:m}),k=null==b?void 0:b.list,T=null==k?void 0:k.find(e=>e.document_id===r),M=null==k?void 0:k.filter(e=>e.status!==B._m.AuditFailed),D=null==M?void 0:M.find(e=>e.document_id===o),O=()=>{i(e=>(e.delete("action_type"),e))},{node:I,open:N}=t0({photo:D,progressMap:t,photoList:M,canEdit:!!c,setCurrentPhotoId:s,reload:A,onCancel:()=>{O()},onSubmit:()=>{O()}});return(0,f.useEffect)(()=>{if(null==d?void 0:d.dataset_id){var e,t;A(),null===(t=m.current)||void 0===t||null===(e=t.scrollTo)||void 0===e||e.call(t,{top:0,behavior:"smooth"})}},[h,u,null==d?void 0:d.dataset_id]),(0,f.useEffect)(()=>{T&&(r&&s(r),N())},[r,T]),(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)("div",{className:t2.Z["photo-list"],ref:m,children:[(0,p.jsx)(tK.yC,{spinning:x,wrapperClassName:t2.Z["photo-list-spin"],childStyle:{height:"100%",width:"100%"},children:(null==k?void 0:k.length)<=0?(0,p.jsx)(tK.YZ,{empty:{icon:(0,p.jsx)(eT.s9d,{}),title:w.o.t("query_data_empty")}}):(0,p.jsx)(tK.um,{spacing:12,className:t2.Z["card-group"],children:null==k?void 0:k.map(e=>{var n,i,{url:r,document_id:o,name:d,update_time:h,caption:u,status:f}=e,m=(null===(n=t[o])||void 0===n?void 0:n.status)||f,g=(null===(i=t[o])||void 0===i?void 0:i.caption)||u,b="string"==typeof g&&!!g,x=()=>{s(o),N()},_=a===o,E=f===B._m.AuditFailed;return(0,p.jsx)(tK.Zb,{cover:E?(0,p.jsxs)("div",{className:t2.Z["prohibit-cover"],children:[(0,p.jsx)(eT.qy1,{size:"extra-small"}),(0,p.jsx)("p",{children:w.o.t("knowledge_photo_illegal_error_msg")})]}):(0,p.jsx)(tK.Ee,{src:r,width:222,preview:!1,onClick:x,className:t2.Z["card-cover"]}),headerLine:!1,bodyStyle:{padding:"12px 16px"},className:Y()(t2.Z.card,E?t2.Z["card-disabled"]:""),children:(0,p.jsxs)("div",{onMouseEnter:()=>{l(o)},onMouseLeave:()=>{l("")},className:t2.Z["card-content"],children:[(0,p.jsx)(tK.ZT.Text,{className:t2.Z["photo-name"],ellipsis:{showTooltip:!0},children:d}),(0,p.jsx)(tK.ZT.Paragraph,{className:t2.Z["photo-description"],ellipsis:{showTooltip:!0,rows:2},style:{color:b?"rgba(29, 28, 35, 0.6)":"rgba(255, 178, 51, 1)"},children:E?(0,p.jsx)("span",{children:w.o.t("knowledge_content_illegal_error_msg")}):m===B._m.Failed?(0,p.jsx)("span",{className:t2.Z["failed-tag"],children:w.o.t("dataset_process_fail")}):m===B._m.Processing?(0,p.jsx)("span",{className:t2.Z["processing-tag"],children:w.o.t("datasets_segment_tag_processing")}):b?g:w.o.t("knowledge_photo_016")}),(0,p.jsxs)("div",{className:t2.Z["card-footer"],children:[(0,p.jsx)(tK.ZT.Text,{className:t2.Z["create-time"],children:tG().unix(h).format("YYYY-MM-DD HH:mm")}),_&&c?(0,p.jsxs)(tK.T,{spacing:12,children:[(0,p.jsx)(tK.u,{content:w.o.t("Edit"),children:(0,p.jsx)(tK._3,{icon:(0,p.jsx)(eT.yl5,{}),disabled:E,onClick:x})}),(0,p.jsx)(tK.u,{content:w.o.t("Delete"),children:(0,p.jsx)(tK._3,{icon:(0,p.jsx)(eT.WDf,{}),onClick:()=>{tK.M5.error({className:t2.Z["confirm-modal"],closeIcon:(0,p.jsx)(eT.bho,{}),title:w.o.t("kl2_007"),content:w.o.t("dataset_detail_table_deleteModel_description"),icon:(0,p.jsx)(eT.rPP,{}),cancelText:w.o.t("Cancel"),okText:w.o.t("Delete"),okButtonProps:{type:"danger"},onOk:(0,v._)(function*(){try{yield S.MJ.DeleteDocument({document_ids:[o]}),yield A()}catch(e){C.s5.errorEvent(C.xW.KNOWLEDGE,{eventName:y.b.KnowledgeDeleteDocument,error:e})}})})}})})]}):null]})]})},o)})})}),(0,p.jsx)("div",{className:t2.Z.footer,children:!E&&(0,p.jsx)(tK.yC,{spinning:_,tip:w.o.t("loading"),wrapperClassName:t2.Z.spin})})]}),I]})};var t3={importKnowledgeMenuSourceFeatureRegistry:((d=tr("import-knowledge-source-image-menu")).register({type:"image-local",module:tn}),d)},t4=e=>(0,p.jsx)(eP.Provider,{value:t3,children:(0,p.jsx)(K,(0,u._)({renderNavBar:t=>{var{statusInfo:n}=t;return(0,p.jsx)(e6,(0,u._)({progressMap:n.progressMap},e.navBarProps))},renderContent:t=>{var{statusInfo:n}=t;return(0,p.jsx)(t5,(0,u._)({progressMap:n.progressMap},e.contentProps))}},e.layoutProps))}),t6=e=>{var{dataSetDetail:{format_type:t}={}}=T();return t===B.a5.Text?(0,p.jsx)(ts,(0,u._)({},e)):t===B.a5.Table?(0,p.jsx)(tW,(0,u._)({},e)):t===B.a5.Image?(0,p.jsx)(t4,(0,u._)({},e)):null},t8=n("207729"),t7=e=>{var{biz:t,renderKnowledgeIDE:n}=e,[i,r]=(0,f.useState)(""),{modal:o,open:s,close:a}=(0,ey.od)({hideOkButton:!0,hideCancelButton:!0,showCloseIcon:!1,closable:!1,fullScreen:!0,footer:null,className:t8.Z["knowledge-preview-modal"]});return{node:o((0,p.jsx)("div",{className:t8.Z["knowledge-preview-modal-content"],children:(0,p.jsx)(g.S9,{params:{datasetID:i,biz:t},resourceNavigate:{},children:n({onClose:a})})})),open:e=>{r(e),s()},close:a}},t9=n("30961"),ne=n("730274"),nt=n("402635"),nn=(e,t)=>{var n,[i,r]=(0,f.useState)();var o=(n=(0,v._)(function*(){try{var{data:e}=yield S.pr.GetDraftBotInfoAgw({bot_id:t});r(null!=e?e:{})}catch(e){console.error(e)}}),function(){return n.apply(this,arguments)});return(0,f.useEffect)(()=>{e&&t&&o()},[e,t]),i};var ni=(c=(0,v._)(function*(e){var{botId:t,agentId:n,dataset:i,botInfo:r,updatedDatasetList:o,spaceId:s}=e;if((null==r?void 0:r.bot_info.bot_mode)===ne.J4.SingleMode)yield S.pr.UpdateDraftBotInfoAgw({bot_info:{bot_id:t,knowledge:(0,V._)((0,u._)({},i),{knowledge_info:o})}});else{var a,l,d=null==r?void 0:null===(l=r.bot_info)||void 0===l?void 0:null===(a=l.agents)||void 0===a?void 0:a.find(e=>e.agent_id===n);(null==d?void 0:d.agent_id)&&(yield S.pr.UpdateAgentV2((0,V._)((0,u._)({},d),{current_version:d.update_type===ne.ZF.AutoUpdate?"0":d.current_version,id:null==d?void 0:d.agent_id,space_id:s,bot_id:t,knowledge:(0,V._)((0,u._)({},i),{knowledge_info:o})})))}}),function(e){return c.apply(this,arguments)}),nr=(e,t,n)=>{var i,r,o=[],s=[];return s="dataset"in e?null!==(i=null==e?void 0:e.dataset)&&void 0!==i?i:[]:null!==(r=null==e?void 0:e.knowledge_info)&&void 0!==r?r:[],o=t===eY.U.REMOVE?null==s?void 0:s.filter(e=>e.id!==n.dataset_id):[...s,{name:n.name,id:n.dataset_id}]};var no=(h=(0,v._)(function*(e){var{botInfo:t,botId:n,agentId:i,dataSetDetail:r={},dataset:o,actionType:s,spaceId:a,updateSuccess:l}=e,d=nr(o,s,r);yield ni((0,V._)((0,u._)({},{spaceId:a,botId:n,agentId:i,updatedDatasetList:d,dataset:o}),{botInfo:t})),l()}),function(e){return h.apply(this,arguments)}),ns=(e,t)=>{var n,i,r,o,s,a;return t?null!==(s=null==e?void 0:null===(o=e.bot_info)||void 0===o?void 0:null===(r=o.agents)||void 0===r?void 0:null===(i=r.find(e=>e.agent_id===t))||void 0===i?void 0:i.knowledge)&&void 0!==s?s:{}:null!==(a=null==e?void 0:null===(n=e.bot_info)||void 0===n?void 0:n.knowledge)&&void 0!==a?a:{}},na=e=>{var t,{dataSetDetail:n}=e,[i,r]=(0,f.useState)(!1),{jump:o}=(0,t9.oB)(),{spaceID:s,botID:a,agentID:l,actionType:d}=(0,g.kF)(),c=nn(s,a),h=ns(c,null!=l?l:""),u=()=>{E.FN.success(w.o.t(d===eY.U.REMOVE?"bot_edit_dataset_removed_toast":"bot_edit_dataset_added_toast",{dataset_name:n.name})),o(t9.cJ.KNOWLEDGE__BACK__BOT,{spaceID:s,botID:a,mode:n.storage_location===B.Ac.Douyin?"douyin":"bot"})};var m=(t=(0,v._)(function*(){r(!0);try{yield no({botInfo:c,botId:null!=a?a:"",agentId:null!=l?l:"",dataSetDetail:n,dataset:h,actionType:null!=d?d:eY.U.ADD,spaceId:null!=s?s:"",updateSuccess:u})}catch(e){console.error(e)}finally{r(!1)}}),function(){return t.apply(this,arguments)});return(0,p.jsxs)(E.zx,{loading:i,disabled:(null==n?void 0:n.status)===nt._z.DatasetForbid,onClick:m,children:[d===eY.U.REMOVE&&(null==n?void 0:n.storage_location)===B.Ac.Douyin?w.o.t("dy_avatar_resource_delete"):null,d===eY.U.REMOVE&&(null==n?void 0:n.storage_location)!==B.Ac.Douyin?w.o.t("kl2_014"):null,d!==eY.U.REMOVE&&(null==n?void 0:n.storage_location)===B.Ac.Douyin?w.o.t("dy_avatar_resource_add"):null,d!==eY.U.REMOVE&&(null==n?void 0:n.storage_location)!==B.Ac.Douyin?w.o.t("kl2_013"):null]})},nl=n("616426"),nd=e=>{var{disabledTooltip:t}=e,n=(0,nl.mm)(),{documentList:i,dataSetDetail:r}=(0,g.PR)((0,m.N)(e=>({documentList:e.documentList,dataSetDetail:e.dataSetDetail}))),o=(0,g.kF)(),s=(0,_.rY)(e=>e.space.id);return(0,p.jsx)(eV,{disabledTooltip:t,onSourceChange:e=>{var t;n(eo({spaceID:s,datasetID:null==r?void 0:r.dataset_id,docID:null==i?void 0:null===(t=i[0])||void 0===t?void 0:t.document_id,formatType:null==r?void 0:r.format_type,type:e,pageMode:"modal",botId:o.botID,actionType:eY.U.ADD}))}})},nc=e=>{var{onBack:t}=e,[n,i]=(0,f.useState)(!1),{spaceID:r,agentID:o,botID:s,actionType:a}=(0,g.kF)(),{dataSetDetail:l}=(0,g.PR)((0,m.N)(e=>({dataSetDetail:e.dataSetDetail}))),{jump:d}=(0,t9.oB)(),c=nn(r,s),h=ns(c,null!=o?o:""),u=(0,f.useMemo)(()=>{var e=[];return"dataset"in h&&(e=((null==h?void 0:h.dataset)||[]).map(e=>{var t;return null!==(t=e.id)&&void 0!==t?t:""})),"knowledge_info"in h&&(e=((null==h?void 0:h.knowledge_info)||[]).map(e=>{var t;return null!==(t=e.id)&&void 0!==t?t:""})),!e.includes((null==l?void 0:l.dataset_id)||"")},[h,null==l?void 0:l.dataset_id]),p=()=>{d(t9.cJ.KNOWLEDGE__BACK__BOT,{spaceID:r,botID:s,mode:(null==l?void 0:l.storage_location)===B.Ac.Douyin?"douyin":"bot"})},b=()=>{t?null==t||t():p()},y=()=>{E.FN.success(w.o.t(a===eY.U.REMOVE?"bot_edit_dataset_removed_toast":"bot_edit_dataset_added_toast",{dataset_name:null==l?void 0:l.name})),p()};return()=>{u?E.u_.confirm({title:w.o.t("bot_ide_knowledge_confirm_title"),content:(null==l?void 0:l.storage_location)===B.Ac.Douyin?w.o.t("dy_avatar_resource_add_tip"):w.o.t("bot_ide_knowledge_confirm_content"),okText:w.o.t("bot_ide_knowledge_confirm_ok"),cancelText:w.o.t("bot_ide_knowledge_confirm_cancel"),confirmLoading:n,onOk:(0,v._)(function*(){i(!0);try{yield no({botInfo:c,botId:null!=s?s:"",agentId:null!=o?o:"",dataSetDetail:l,dataset:h,actionType:null!=a?a:eY.U.ADD,spaceId:null!=r?r:"",updateSuccess:y})}catch(e){console.error(e)}finally{i(!1),b()}}),onCancel:()=>{b()}}):b()}},nh=e=>{var{onBack:t,importKnowledgeSourceButton:n}=e,{dataSetDetail:i,documentList:r}=(0,g.PR)((0,m.N)(e=>({dataSetDetail:e.dataSetDetail,documentList:e.documentList}))),o=nc({onBack:t});return(0,p.jsx)(e5,{title:null==i?void 0:i.name,onBack:t,datasetDetail:i,docInfo:null==r?void 0:r[0],actionButtons:(0,p.jsx)(na,{dataSetDetail:i},null==i?void 0:i.dataset_id),importKnowledgeSourceButton:null!=n?n:(0,p.jsx)(nd,{}),beforeBack:o})},nu=e=>(0,p.jsx)(t6,(0,V._)((0,u._)({},e),{layoutProps:{renderNavBar:t=>{var{statusInfo:n}=t;return(0,p.jsx)(nh,(0,u._)({progressMap:n.progressMap},e.navBarProps))}}})),np=e=>(0,p.jsx)(t6,(0,u._)({},e)),nf=e=>(0,p.jsx)(e6,(0,V._)((0,u._)({},e),{hideBackButton:!0})),nm=e=>(0,p.jsx)(t6,(0,V._)((0,u._)({},e),{layoutProps:{className:"coz-bg-max border border-solid coz-stroke-primary",renderNavBar:t=>{var{statusInfo:n}=t;return(0,p.jsx)(nf,(0,u._)({progressMap:n.progressMap},e.navBarProps))}}})),ng=e=>{var{onBack:t,actionButtons:n}=e,{dataSetDetail:i,documentList:r}=(0,g.PR)((0,m.N)(e=>({dataSetDetail:e.dataSetDetail,documentList:e.documentList})));return(0,p.jsx)(e5,{title:null==i?void 0:i.name,onBack:t,datasetDetail:i,docInfo:null==r?void 0:r[0],actionButtons:n})},nv=e=>(0,p.jsx)(t6,(0,V._)((0,u._)({},e),{layoutProps:{renderNavBar:t=>{var{statusInfo:n}=t;return(0,p.jsx)(ng,(0,u._)({progressMap:n.progressMap},e.navBarProps))}}})),nb=e=>t7((0,V._)((0,u._)({},e),{renderKnowledgeIDE:t=>{var{onClose:n}=t;return(0,p.jsx)(nv,(0,V._)((0,u._)({},e),{navBarProps:(0,V._)((0,u._)({},e.navBarProps),{onBack:n})}))}}))},936731:function(e,t,n){n.d(t,{v:function(){return i.v}});var i=n(888461)},888461:function(e,t,n){n.d(t,{v:function(){return h}});var i=n(151064),r=n(455069),o=n(252237),s=n.n(o),a=n(385038),l=n(659596),d=n(561119),c=n(105452),h=e=>{var{className:t,style:n,mainText:o,subText:h,percent:u=10,percentFormat:p,avatar:f,status:m,actions:g,tipText:v=""}=e;return(0,i.jsxs)("div",{className:s()(c.Z["progress-wrap"],"flex justify-between relative mb-[8px]",m===d.N.Failed?c.Z["processing-failed"]:"",m===d.N.Processing?c.Z.processing:"",t),style:n,children:[(0,i.jsx)("div",{className:s()(c.Z.content,"process-progress-item-content","max-w-[calc(100%-100px)]"),children:(0,i.jsxs)("div",{className:s()("flex items-center",c.Z.info),children:[f,(0,i.jsxs)("div",{className:s()("pl-[10px] max-w-full"),children:[(0,i.jsx)("div",{className:c.Z["main-text"],children:(0,i.jsx)(l.ZT.Text,{"data-dtestid":"".concat(a.w.CreateUnitListProgressName,".").concat(o),className:"coz-fg-primary text-14px",ellipsis:{showTooltip:{opts:{content:o}}},children:o})}),(0,i.jsxs)("div",{className:c.Z["sub-text"],children:[(0,i.jsx)("div",{className:c.Z.desc,children:h}),v?(0,i.jsx)("div",{className:c.Z["tip-desc"],children:v}):null]})]})]})}),(0,i.jsx)("div",{className:s()(c.Z.right,"process-progress-item-right"),children:m===d.N.Processing?(0,i.jsx)("span",{className:c.Z.percent,children:p||"".concat(u,"%")}):(0,i.jsx)("div",{className:s()(c.Z.actions,"process-progress-item-actions"),children:Array.isArray(g)?(0,i.jsx)(l.T,{spacing:"tight",children:g.map((e,t)=>(0,i.jsx)(r.Fragment,{children:e},t))}):null})}),m===d.N.Processing?(0,i.jsx)("div",{className:c.Z.progress,style:{width:"".concat(u,"%")}}):null]},o)}},270917:function(e,t,n){n.d(t,{p:()=>z});var i,r=n("808549"),o=n("120454"),s=n("473980"),a=n("151064"),l=n("455069"),d=n("252237"),c=n.n(d),h=n("763055"),u=n("263825"),p=n("385038"),f=n("336205"),m=n("873183"),g=n("659596"),v=n("528751"),b=n("537714"),y=n("695673"),x=n("900539"),w=e=>e.substring(0,e.lastIndexOf(".")),_=(e,t)=>{var n;return null==e?void 0:null===(n=e[t])||void 0===n?void 0:n.name},S=e=>e.reduce((e,t)=>(e[t.uid||""]=t,e),{}),C=(e,t)=>e.filter(e=>null==t?void 0:t.find(t=>{var n;return t.uri===(null==e?void 0:null===(n=e.response)||void 0===n?void 0:n.upload_uri)})),A=(e,t)=>{var n,i,r,o;return{type:(0,x.mD)((null==e?void 0:null===(n=e.response)||void 0===n?void 0:n.upload_uri)||e.name),uri:null==e?void 0:null===(i=e.response)||void 0===i?void 0:i.upload_uri,url:null==e?void 0:null===(r=e.response)||void 0===r?void 0:r.upload_url,name:(null!==(o=null==t?void 0:t.filename)&&void 0!==o?o:w(e.name)).slice(0,y.I1),size:e.size,status:e.status,percent:e.percent||0,fileInstance:e.fileInstance,uid:e.uid,validateMessage:e.validateMessage||""}},E=e=>e.filter(e=>!(!e.shouldUpload&&e.status===b.Dm.VALIDATE_FAIL)).map((t,n)=>A(t,{filename:_(e,n)})),k=(e,t)=>{var n=S(t);return e.filter(e=>{var t=n[e.uid||""];return!!t.shouldUpload||t.status!==b.Dm.VALIDATE_FAIL||!1}).map((e,i)=>{var o=n[e.uid||""],s=_(t,i);return(0,r._)({},e,A(o,{filename:s}))})},T=n("44172"),M=e=>{var t=(0,x.mD)(e.name)||"unknown",n={unknown:T.dd3,pdf:T.t1r,text:T.mBV,docx:T.yA0}[t]||T.dd3;return(0,a.jsx)(n,{})},D=n("825955"),O=n("745474"),I=n("458620"),N=n("727914"),P=n("178385"),R=n("382534"),L=n("274971");var j=(i=(0,D._)(function*(e){var{onSuccess:t,onError:n,onProgress:i,file:r}=e;try{var{name:o,fileInstance:s}=r;if(s){var a=(0,L.mD)(o),l=yield(0,L.y3)(s),d=yield R.nA.UploadFile({file_head:{file_type:a,biz_type:P.ym.BIZ_BOT_DATASET},data:l},{onUploadProgress:e=>{var t,n=null==r?void 0:r.status,o=null==r?void 0:r.response;if(n!==b.Dm.SUCCESS&&n!==b.Dm.UPLOAD_FAIL&&n!==b.Dm.VALIDATE_FAIL&&(null==o?!void 0:!o.upload_url)){var{total:a,loaded:l}=e;void 0!==a&&l{var t,{maxSizeMB:i}=e;return t=(0,D._)(function*(e){var t={fileInstance:e.file.fileInstance,status:e.file.status,validateMessage:e.file.validateMessage,shouldUpload:!0,autoRemove:!1},{fileInstance:s}=e.file;if(!s)return(0,o._)((0,r._)({},t),{status:b.Dm.UPLOAD_FAIL,shouldUpload:!1});var a=i||v.G2;if(s.size>1048576*a)return g.FN.warning({showClose:!1,content:f.o.t("file_too_large",{max_size:"".concat(a,"MB")})}),(0,o._)((0,r._)({},t),{shouldUpload:!1,status:b.Dm.VALIDATE_FAIL,validateMessage:f.o.t("file_too_large",{max_size:"".concat(a,"MB")})});if("pdf"===(0,L.mD)(s.name).toLowerCase())try{var{getDocument:l,initPdfJsWorker:d}=yield n.e("7841").then(n.bind(n,187394));d();var c=yield(0,L.JD)(s);if((yield l({data:c}).promise).numPages>v.XC)return g.FN.warning({showClose:!1,content:f.o.t("atasets_createpdf_over250")}),{shouldUpload:!1,status:b.Dm.VALIDATE_FAIL}}catch(e){if(O.s5.errorEvent(O.xW.KNOWLEDGE,{eventName:I.b.KnowledgeParseFile,error:e}),(null==e?void 0:e.name)==="PasswordException")return g.FN.error({showClose:!1,content:f.o.t("pdf_encrypted")}),{shouldUpload:!1,status:b.Dm.VALIDATE_FAIL}}return t}),function(e){return t.apply(this,arguments)}},B=n("928589"),z=e=>{var{unitList:t,onFinish:n,setUnitList:i,showIllustration:d=!0,multiple:b=!0,maxSizeMB:y=v.G2}=e,x=(0,s._)(e,["unitList","onFinish","setUnitList","showIllustration","multiple","maxSizeMB"]),{limit:w}=x,[_,S]=(0,l.useState)([]);(0,l.useEffect)(()=>{t.length<_.length&&S(C(_,t))},[t.length]);var A=(0,l.useCallback)(()=>{g.FN.warning({showClose:!1,content:f.o.t("knowledge_upload_format_error")})},[]),T=(0,u.hJ)(),D=(0,u.S2)(e=>{S(e.fileList),i(E(e.fileList))},T),O=(0,u.S2)(()=>{n(k(t,_))},T),I=(0,l.useMemo)(()=>t.length>=w,[t,w]),N=F({maxSizeMB:y});return(0,a.jsx)(g.gq,(0,o._)((0,r._)({draggable:!0,"data-testid":p.w.UploadUnitFile,multiple:b,fileList:_,disabled:I,previewFile:M,onAcceptInvalid:A,beforeUpload:N,customRequest:j,onChange:D,onSuccess:O,dragIcon:(0,a.jsx)(m.Isu,{className:B.Z["upload-icon"]})},x),{className:c()(B.Z.upload,x.className),children:t.length>=w&&d?(0,a.jsxs)("div",{className:B.Z["create-enough-file"],onClick:e=>e.stopPropagation(),children:[(0,a.jsx)(h.ns,{className:B.Z.picture}),(0,a.jsx)("div",{className:B.Z.text,children:f.o.t("knowledge_1218_001",{MaxDocs:w})})]}):null}))}},47522:function(e,t,n){n.d(t,{vL:()=>p,k1:()=>u,Zq:()=>h,nC:()=>i.n,G8:()=>c});var i=n("735997"),r=n("151064"),o=n("695673"),s=n("385038"),a=n("336205"),l=n("873183"),d=n("659596");function c(e){return(0,r.jsx)("div",{"data-dtestid":"".concat(s.w.LocalUploadListFileSize,".").concat(e.name),className:"coz-fg-secondary text-12px",children:null==e?void 0:e.size})}function h(e){var{index:t,record:n,params:i}=e,{onChange:o,unitList:s,onDelete:c}=i;return(0,r.jsx)(d.u,{spacing:12,content:a.o.t("Delete"),position:"top",children:(0,r.jsx)(d.hU,{color:"secondary",icon:(0,r.jsx)(l.dVD,{className:"text-14px"}),iconPosition:"left",size:"small",onClick:()=>{o(s.filter((e,n)=>t!==n)),"function"==typeof c&&(null==c||c(n,t))}})})}function u(e){var t,{index:n,record:i,params:s}=e,{onChange:c,unitList:h}=s,{node:u,open:p}=(0,o.i0)({name:null!==(t=null==i?void 0:i.name)&&void 0!==t?t:"",onOk:e=>{var t=[...h];t[n].name=e,c(t)}});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(d.u,{spacing:12,content:a.o.t("Edit"),position:"top",children:(0,r.jsx)(d.hU,{color:"secondary",icon:(0,r.jsx)(l.JAz,{className:"text-14px"}),iconPosition:"left",size:"small",onClick:()=>p()})}),u]})}function p(e){var{index:t,record:n,params:i}=e;if(i.disableRetry)return null;var{onRetry:o}=i;return(0,r.jsx)(d.u,{spacing:12,content:a.o.t("datasets_unit_update_retry"),position:"top",children:(0,r.jsx)(d.hU,{color:"secondary",icon:(0,r.jsx)(l.mxP,{className:"text-14px"}),iconPosition:"left",size:"small",onClick:()=>{null==o||o(n,t)}})})}n("274971"),n("237365")},735997:function(e,t,n){n.d(t,{n:function(){return u}});var i=n(808549),r=n(120454),o=n(151064);n(455069);var s=n(385038),a=n(336205),l=n(888461),d=n(561119),c=n(237365),h=(e,t,n)=>e===d.N.Failed?(0,o.jsx)("div",{"data-dtestid":"".concat(s.w.CreateUnitListProgressName,".","subText"),className:"text-12px",children:t||a.o.t("datasets_unit_upload_fail")}):n,u=e=>{var{unitList:t=[],getColumns:n}=e;return 0===t.length?null:(0,o.jsx)("div",{className:"upload-container",children:t.map((e,t)=>{var u=(0,c.Z)(null==e?void 0:e.status),p=(null==e?void 0:e.statusDescript)||"",{subText:f,actions:m,formatType:g}=n?n(e,t):{};return(0,o.jsx)(l.v,{mainText:e.name||"--",subText:h(u,p,f),tipText:(0,o.jsx)("span",{"data-dtestid":"".concat(s.w.LocalUploadListStatus,".").concat(e.name),children:u===d.N.Failed?p||a.o.t("datasets_unit_upload_fail"):a.o.t("datasets_unit_upload_success")}),status:u,avatar:(0,c.a)((0,r._)((0,i._)({},e),{formatType:g})),actions:m,percent:e.percent||10},e.uid)})})}},237365:function(e,t,n){n.d(t,{Z:function(){return c},a:function(){return d}});var i=n(151064),r=n(537714),o=n(280053),s=n(775699),a=n(44172),l=n(561119),d=e=>{var{type:t,formatType:n,url:r}=e;return n===o.a5.Image&&["jpg","jpeg","png","webp"].includes(t)?(0,i.jsx)(s.Ee,{src:r,width:24,height:24,style:{borderRadius:"4px",marginRight:"12px",flexShrink:0}}):"md"===t?(0,i.jsx)(a.s7F,{}):"pdf"===t?(0,i.jsx)(a.I2v,{}):"docx"===t?(0,i.jsx)(a.KHq,{}):"txt"===t?(0,i.jsx)(a.KNN,{}):"xlsx"===t||"xltx"===t||"xls"===t?(0,i.jsx)(a.$lV,{}):"csv"===t?(0,i.jsx)(a.tsT,{}):n===o.a5.Table?(0,i.jsx)(a.LAr,{}):(0,i.jsx)(a.Hnk,{})},c=e=>e===r.Dm.UPLOADING||e===r.Dm.VALIDATING||e===r.Dm.WAIT||e===o.Vq.Handling||e===r.Ao.EntityStatusProcess?l.N.Processing:e===r.Dm.SUCCESS||e===o.Vq.Finish||e===r.Ao.EntityStatusSuccess?l.N.Complete:e===r.Dm.VALIDATE_FAIL||e===r.Dm.UPLOAD_FAIL||e===o.Vq.Failed||e===r.Ao.EntityStatusFail?l.N.Failed:l.N.Processing},861445:function(e,t,n){n.d(t,{O7:function(){return i},WT:function(){return a},Yg:function(){return r},xT:function(){return o}});var i=100,r=3e3,o=[".xls",".xlsx",".csv"],s={DOUYIN:{acceptFileTypes:[".pdf",".txt",".doc",".docx"],fileFormatString:"PDF、TXT、DOC、DOCX",addUnitMaxLimit:100},DEFAULT:{acceptFileTypes:[".pdf",".txt",".docx",".md"],fileFormatString:"PDF、TXT、DOCX、MD",addUnitMaxLimit:300}},a=e=>e&&s[e]||s.DEFAULT},116497:function(e,t,n){n.d(t,{G2:function(){return o},XC:function(){return s},ge:function(){return r}});var i,r=((i={})[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.THREE=3]="THREE",i[i.SEVEN=7]="SEVEN",i[i.THIRTY=30]="THIRTY",i),o=1e3,s=5e3},528751:function(e,t,n){n.d(t,{pL:()=>a,O7:()=>o.O7,Q:()=>c,ge:()=>p.ge,hD:()=>d,XC:()=>p.XC,z2:()=>h,DU:()=>l,c3:()=>s,v1:()=>u.v,Px:()=>u.P,G2:()=>p.G2,Yg:()=>o.Yg});var i,r,o=n("861445");var s=((i={}).ERROR="error",i.LOADING="loading",i.NORMAL="normal",i),a=50,l=30;var d=((r={}).SHEET="sheet_id",r.KEY_START_ROW="header_line_idx",r.DATA_START_ROW="start_line_idx",r),c={sheet_id:0,header_line_idx:0,start_line_idx:1},h={sheet_id:0,header_line_idx:0,start_line_idx:0},u=n("461334"),p=n("116497")},461334:function(e,t,n){n.d(t,{P:function(){return s},v:function(){return a}});var i=n(336205),r=n(288391),o=()=>({[r.IB.LINE_BREAK]:i.o.t("datasets_Custom_segmentID_linebreak"),[r.IB.LINE_BREAK2]:i.o.t("datasets_Custom_segmentID_2linebreak"),[r.IB.CN_PERIOD]:i.o.t("datasets_Custom_segmentID_cnperiod"),[r.IB.CN_EXCLAMATION]:i.o.t("datasets_Custom_segmentID_cn_exclamation"),[r.IB.EN_PERIOD]:i.o.t("datasets_Custom_segmentID_enperiod"),[r.IB.EN_EXCLAMATION]:i.o.t("datasets_Custom_segmentID_en_exclamation"),[r.IB.CN_QUESTION]:i.o.t("datasets_Custom_segmentID_cn_question"),[r.IB.EN_QUESTION]:i.o.t("datasets_Custom_segmentID_en_question"),[r.IB.CUSTOM]:i.o.t("datasets_Custom_segmentID_custom")}),s=()=>Object.entries(o()).map(e=>{var[t,n]=e;return{value:t,label:n}}),a={separator:{type:r.IB.LINE_BREAK,customValue:"###"},maxTokens:800,preProcessRules:[],overlap:10}},771242:function(e,t,n){n.d(t,{nC:function(){return o.nC},p:function(){return r.p},uA:function(){return i.uA},vS:function(){return s.v},zP:function(){return i.zP}}),n(528751);var i=n(274971),r=n(270917),o=n(47522),s=n(936731);n(237365)},561119:function(e,t,n){n.d(t,{N:function(){return r}});var i,r=((i={})[i.Processing=0]="Processing",i[i.Complete=1]="Complete",i[i.Failed=2]="Failed",i)},288391:function(e,t,n){n.d(t,{IB:function(){return l},OX:function(){return s},dV:function(){return a}});var i,r,o,s=((i={})[i.AUTO=0]="AUTO",i[i.CUSTOM=1]="CUSTOM",i[i.LEVEL=2]="LEVEL",i);var a=((r={}).REMOVE_SPACES="remove_extra_spaces",r.REMOVE_EMAILS="remove_urls_emails",r);var l=((o={}).LINE_BREAK="\n",o.LINE_BREAK2="\n\n",o.CN_PERIOD="。",o.CN_EXCLAMATION="!",o.EN_PERIOD=".",o.EN_EXCLAMATION="!",o.CN_QUESTION="?",o.EN_QUESTION="?",o.CUSTOM="custom",o)},900539:function(e,t,n){n.d(t,{As:function(){return C},BD:function(){return k},JD:function(){return S},V1:function(){return E},l$:function(){return y},mD:function(){return w},mZ:function(){return A},td:function(){return x},te:function(){return g},uA:function(){return b},wV:function(){return m},y3:function(){return _},zP:function(){return v}});var i=n(808549),r=n(120454),o=n(962289),s=n(22916),a=n(745474),l=n(537714),d=n(458620),c=n(336205),h=n(727914),u=n(280053),p=n(659596),f=n(528751),m=e=>{var{unitList:t,data:n,fileInstance:o,index:s}=e;return n?t.map((e,t)=>s===t?(0,r._)((0,i._)({},e),{uri:n.upload_uri||"",status:l.Dm.SUCCESS,percent:100,fileInstance:o}):e):t};function g(e){var t=e.filter(e=>e.status===u._m.Failed);t.length&&a.s5.errorEvent(a.xW.KNOWLEDGE,{eventName:d.b.KnowledgeGetTaskProgress,error:new h.sH(d.b.KnowledgeGetTaskProgress,"".concat(d.b.KnowledgeGetTaskProgress,": get progress fail. ").concat(JSON.stringify(t))),meta:{failIds:t}})}function v(e){return e.length>0&&e.every(e=>e.progress===f.O7||e.status===u._m.Failed)}var b=e=>{e.current&&(clearTimeout(e.current),e.current=void 0)};function y(){var e=(0,s.kF)();return(0,o.Z)(e,"opt",l.VP.ADD)}function x(){var e=(0,s.kF)();return(0,o.Z)(e,"docID",void 0)}var w=e=>{var t=e.lastIndexOf(".");return e.slice(t+1).toLowerCase()},_=e=>new Promise((t,n)=>{var i=new FileReader;i.onload=e=>{var i,r=null===(i=e.target)||void 0===i?void 0:i.result;if(!r||"string"!=typeof r){n(new h.sH("getBase64","file read invalid"));return}t(r.replace(/^.*?,/,""))},i.onerror=()=>{p.FN.error(c.o.t("read_file_failed_please_retry")),n(new h.sH("getBase64","file read fail"))},i.onabort=()=>{n(new h.sH("getBase64","file read abort"))},i.readAsDataURL(e)}),S=e=>new Promise((t,n)=>{var i=new FileReader;i.onload=e=>{var i;(null===(i=e.target)||void 0===i?void 0:i.result)?t(new Uint8Array(e.target.result)):n(new h.sH("getUint8Array","file read invalid"))},i.readAsArrayBuffer(e)});function C(e,t){var n=e.filter(e=>e.status===u._m.Failed);n.length>0&&a.s5.errorEvent(a.xW.KNOWLEDGE,{eventName:t,error:new h.sH(t,"".concat(t,": fail document_ids are ").concat(JSON.stringify(n))),meta:{failDocumentIds:n}})}var A=e=>c.o.t("knowledge_add_unit_process_notice"),E=(e,t)=>e===l.VP.RESEGMENT&&t&&[l.Cm.TABLE_GOOGLE_DRIVE,l.Cm.TABLE_FEISHU].includes(t),k=e=>e===l.VP.INCREMENTAL},274971:function(e,t,n){n.d(t,{wO:()=>i.wO,hd:()=>i.hd,l$:()=>r.l$,VR:()=>o.VR,V1:()=>r.V1,y3:()=>r.y3,mZ:()=>r.mZ,mD:()=>r.mD,zP:()=>r.zP,JD:()=>r.JD,td:()=>r.td,As:()=>r.As,UQ:()=>s,te:()=>r.te,wV:()=>r.wV,BD:()=>r.BD,OP:()=>i.OP,uA:()=>r.uA});var i=n("690612"),r=n("900539"),o=n("417062");function s(e){return!1}n("888711")},690612:function(e,t,n){n.d(t,{OP:function(){return a},bp:function(){return l},hd:function(){return s},wO:function(){return c}});var i=n(962289),r=n(336205),o=n(528751),s=e=>({[o.ge.ZERO]:r.o.t("datasets_frequencyModal_frequency_noUpdate"),[o.ge.ONE]:r.o.t("datasets_frequencyModal_frequency_day",{num:1}),[o.ge.THREE]:r.o.t("datasets_frequencyModal_frequency_day",{num:3}),[o.ge.SEVEN]:r.o.t("datasets_frequencyModal_frequency_day",{num:7}),[o.ge.THIRTY]:r.o.t("datasets_frequencyModal_frequency_day",{num:30})})[e],a=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=!0,i="";return e?(/["'`\\]+/g.test(e)&&(n=!1,i=r.o.t("knowledge_tableStructure_field_errLegally")),["_knowledge_slice_id"].includes(e)&&(n=!1,i=r.o.t("knowledge_tableStructure_errSystemField")),{valid:n,errorMsg:i}):{valid:!1,errorMsg:t}},l=e=>{if(!e)return[];var t=e.match(/]+src\s*=\s*['"]([^'"]+)['"][^>]*>/g),n=[];if(t)for(var i=0;iObject.values(o.hD).includes(e),c=e=>{var t={sheet_id:"",header_line_idx:"",start_line_idx:""};return Object.keys(e).reduce((t,n)=>(d(n)&&(t[n]=String((0,i.Z)(e,n))),t),t),t}},417062:function(e,t,n){n.d(t,{VR:function(){return a}});var i=n(280053),r=n(461334),o=n(288391),s=e=>e.chunk_type===i.x2.CustomChunk?o.OX.CUSTOM:e.chunk_type===i.x2.LevelChunk?o.OX.LEVEL:o.OX.AUTO,a=e=>{if(e&&Object.keys(e)&&(null==e?void 0:e.chunk_strategy))try{var t=(null==e?void 0:e.chunk_strategy)||{},n=[];return t.remove_extra_spaces&&n.push(o.dV.REMOVE_SPACES),t.remove_urls_emails&&n.push(o.dV.REMOVE_EMAILS),{docInfo:e,segmentMode:s(null==e?void 0:e.chunk_strategy),segmentRule:{separator:t.separator?l(t.separator):r.v.separator,maxTokens:t.max_tokens?Number(t.max_tokens):r.v.maxTokens,preProcessRules:n,overlap:t.overlap?Number(t.overlap):r.v.overlap}}}catch(e){}},l=e=>(function(e){var t=[];for(var[,n]of Object.entries(e))n!==e.CUSTOM&&t.push(n);return t})(o.IB).indexOf(e)>-1?{type:e}:{type:o.IB.CUSTOM,customValue:e}},888711:function(e,t,n){n.d(t,{Y:function(){return o}});var i=n(537714),r=n(288391),o=(e,t)=>{if(e===r.OX.CUSTOM){var n=(null==t?void 0:t.maxTokens)||0,o=null==t?void 0:t.separator,s=(null==o?void 0:o.type)===r.IB.CUSTOM&&!(null==o?void 0:o.customValue);if(0===n||s||"number"!=typeof t.overlap||Number.isNaN(t.overlap))return i.xZ.DISABLE}return i.xZ.ENABLE}},883156:function(e,t,n){n.r(t),n.d(t,{KnowledgePreviewPage:function(){return u}});var i=n(808549),r=n(120454),o=n(151064),s=n(157728),a=n(517465),l=n.n(a),d=n(22916),c=n(153696),h=n(214942),u=()=>{var e,t,n,a,u,p,{dataset_id:f,space_id:m}=(0,s.useParams)(),g=new URLSearchParams(window.location.search),v={datasetID:null!=f?f:"",spaceID:null!=m?m:"",type:g.get("type"),opt:g.get("opt"),docID:null!==(e=g.get("doc_id"))&&void 0!==e?e:"",pageMode:g.get("page_mode"),biz:g.get("biz"),botID:null!==(t=g.get("bot_id"))&&void 0!==t?t:"",workflowID:null!==(n=g.get("workflow_id"))&&void 0!==n?n:"",agentID:null!==(a=g.get("agent_id"))&&void 0!==a?a:"",actionType:g.get("action_type"),first_auto_open_edit_document_id:null!==(u=g.get("first_auto_open_edit_document_id"))&&void 0!==u?u:"",create:null!==(p=g.get("create"))&&void 0!==p?p:""},b=(0,s.useNavigate)(),y=(0,h.rY)(e=>e.space.id);return(0,o.jsx)(d.S9,{params:(0,r._)((0,i._)({},v),{spaceID:y}),resourceNavigate:{toResource:(e,t,n,i)=>b("/space/".concat(v.spaceID,"/").concat(e,"/").concat(t,"?").concat(l().stringify(n)),i),upload:(e,t)=>b("/space/".concat(v.spaceID,"/knowledge/").concat(v.datasetID,"/upload?").concat(l().stringify(e)),t)},children:"agentIDE"===v.biz?(0,o.jsx)(c.PD,{}):"workflow"===v.biz?(0,o.jsx)(c.BZ,{}):"project"===v.biz?(0,o.jsx)(c.f5,{}):(0,o.jsx)(c.Y5,{})})}},852497:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(988955),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},34018:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(849016),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},704794:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(275554),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},427286:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(239427),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},399639:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(420974),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},522426:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(442146),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},888122:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(710505),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},286144:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(613498),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},941415:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(963731),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},552639:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(762642),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},379361:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(501893),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},99057:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(223812),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},512946:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(528878),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},523865:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(593171),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},207729:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(53280),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},105452:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(136965),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},928589:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(238205),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),t.Z=m.Z&&m.Z.locals?m.Z.locals:void 0},541269:function(e,t,n){e.exports=n.p+"static/image/delete-operation-en.44b1f340.png"},193604:function(e,t,n){e.exports=n.p+"static/image/delete-operation.97fc5d6f.png"},127139:function(e,t,n){e.exports=n.p+"static/image/level-operation.423f9b14.png"},615739:function(e,t,n){e.exports=n.p+"static/image/merge-operation-en.76af0b44.png"},728901:function(e,t,n){e.exports=n.p+"static/image/merge-operation.d9654306.png"},997700:function(e,t,n){n.d(t,{r:function(){return s}});var i=n(808549),r=n(120454),o=n(151064);n(455069);var s=e=>(0,o.jsx)("svg",(0,r._)((0,i._)({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 16 16"},e),{children:(0,o.jsx)("path",{d:"M10.862 1.528c.26.26.26.683 0 .943L5.333 8l5.529 5.528a.667.667 0 1 1-.943.943L4.391 8.942a1.333 1.333 0 0 1 0-1.885l5.528-5.529c.26-.26.683-.26.943 0",style:{fillOpacity:1}})}))},815605:function(e,t,n){n.d(t,{r:function(){return s}});var i=n(808549),r=n(120454),o=n(151064);n(455069);var s=e=>(0,o.jsxs)("svg",(0,r._)((0,i._)({xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",viewBox:"0 0 16 16"},e),{children:[(0,o.jsx)("path",{d:"M12.437 6.333h.98a5.67 5.67 0 0 0-10.835 0H1.2a7.003 7.003 0 0 1 13.6 0h1.096c.058 0 .104.049.104.109a.1.1 0 0 1-.03.076l-1.693 1.768a.15.15 0 0 1-.22 0l-1.693-1.768a.11.11 0 0 1 0-.153.1.1 0 0 1 .073-.032M3.563 9.667h-.98a5.67 5.67 0 0 0 10.835 0H14.8a7.003 7.003 0 0 1-13.6 0H.104a.1.1 0 0 1-.074-.032.11.11 0 0 1 0-.153l1.693-1.768a.15.15 0 0 1 .22 0l1.693 1.768c.02.02.03.048.03.076 0 .06-.046.109-.103.109",style:{fill:"currentColor",fillOpacity:1}}),(0,o.jsx)("path",{d:"M8.677 5H7.34L5 11h1.344l.683-1.656h1.906L9.677 11H11zM8.62 8H7.372l.638-1.68z",style:{fill:"currentColor",fillOpacity:1}})]}))},988955:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".icon-with-suffix-QBfq59{margin-right:12px;position:relative}.icon-with-suffix-QBfq59 .icon-with-suffix-common{flex-shrink:0;justify-content:center;align-items:center;display:flex}.icon-with-suffix-QBfq59 .icon{border-radius:4px;width:24px;height:24px;top:0;left:0}.icon-with-suffix-QBfq59 .suffix{z-index:1;border-radius:2.667px;width:12px;height:12px;position:absolute;top:16px;left:16px}",""]),s.locals={"icon-with-suffix":"icon-with-suffix-QBfq59",iconWithSuffix:"icon-with-suffix-QBfq59"},t.Z=s},849016:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".confirm-modal-As1dCu .semi-modal-header{margin-bottom:16px}.confirm-modal-As1dCu .semi-modal-header .semi-modal-icon-wrapper{margin-right:8px}.confirm-modal-As1dCu .semi-modal-header .semi-modal-confirm-title-text{color:#1d1c23}.confirm-modal-As1dCu .semi-modal-header .semi-button:hover{background-color:rgba(46,46,56,.08)}.confirm-modal-As1dCu .semi-modal-body{margin:0;padding:16px 0}.confirm-modal-As1dCu .semi-modal-body .semi-modal-confirm-content{color:#1d1c23}.confirm-modal-As1dCu .semi-modal-footer button{min-width:96px;margin-left:16px}",""]),s.locals={"confirm-modal":"confirm-modal-As1dCu",confirmModal:"confirm-modal-As1dCu"},t.Z=s},275554:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".table-config-menu-down-GEmwUR{padding:4px;font-size:12px}.table-config-menu-down-GEmwUR .dropdown-item-line-t6ygSI{width:100%;height:1px;margin:4px 0}.table-config-menu-down-GEmwUR .semi-dropdown-menu{padding:4px}.table-config-menu-down-GEmwUR .semi-dropdown-item{min-width:126px;height:32px!important;padding:8px 16px!important}.dropdown-item-link-QPqIvO{font-size:12px;color:var(--coz-fg-hglt)!important}.dropdown-item-link-QPqIvO .semi-dropdown-item-icon{margin-right:4px}.dropdown-item-link-icon-lWRikC svg{width:12px;height:12px}.dropdown-item-link-icon-lWRikC .semi-dropdown-item-icon{margin-right:0}.action-btn-right-hH8YBX{padding:4px}.action-btn-fdSY1M .semi-button-content-left{align-items:center;margin-right:4px;display:flex}",""]),s.locals={"table-config-menu-down":"table-config-menu-down-GEmwUR",tableConfigMenuDown:"table-config-menu-down-GEmwUR","dropdown-item-line":"dropdown-item-line-t6ygSI",dropdownItemLine:"dropdown-item-line-t6ygSI","dropdown-item-link":"dropdown-item-link-QPqIvO",dropdownItemLink:"dropdown-item-link-QPqIvO","dropdown-item-link-icon":"dropdown-item-link-icon-lWRikC",dropdownItemLinkIcon:"dropdown-item-link-icon-lWRikC","action-btn-right":"action-btn-right-hH8YBX",actionBtnRight:"action-btn-right-hH8YBX","action-btn":"action-btn-fdSY1M",actionBtn:"action-btn-fdSY1M"},t.Z=s},239427:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".navbar-fu6Hc8 .brief-q_Wf9k{color:var(--coz-fg-primary);align-items:center;display:flex}.navbar-fu6Hc8 .brief-q_Wf9k .semi-avatar{border:.5px solid var(--coz-stroke-primary);background:0 0;border-radius:8px;margin-right:8px}.navbar-fu6Hc8 .back-icon-fJthmP{padding:8px!important}.navbar-fu6Hc8 .toolbar-zPJKvF{height:-moz-fit-content;align-items:center;gap:12px;height:fit-content;display:flex}.doc-icon-note-O7kQD6>svg{width:36px;height:36px}.doc-icon-note-O7kQD6>svg>path{fill:null}",""]),s.locals={navbar:"navbar-fu6Hc8",brief:"brief-q_Wf9k","back-icon":"back-icon-fJthmP",backIcon:"back-icon-fJthmP",toolbar:"toolbar-zPJKvF","doc-icon-note":"doc-icon-note-O7kQD6",docIconNote:"doc-icon-note-O7kQD6"},t.Z=s},420974:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".brief-avPHHU .info-UEZJMK{align-items:center;height:40px;display:flex}.brief-avPHHU .icon-JZZB0l{width:36px;height:36px}.brief-avPHHU .icon-JZZB0l .semi-avatar{border:.5px solid var(--coz-stroke-primary);background:0 0;border-radius:9px;width:36px;height:36px}.brief-avPHHU .content-kLh6l2{flex-grow:1;margin-left:8px;overflow:hidden}.brief-avPHHU .bot-count-Ni79sf{color:rgba(29,28,36,.35);align-items:center;width:220px;font-size:12px;line-height:16px;display:flex}.brief-avPHHU .bot-count-text-S_PzMm{margin-right:4px}.brief-avPHHU .bot-count-icon-Q6mXK_{cursor:pointer;width:14px;height:14px;margin-top:1px}.brief-avPHHU .bot-count-icon-Q6mXK_ path{fill:#c6cacd}.brief-avPHHU .action-right-s4qfdQ{margin-left:auto}.brief-avPHHU .tags-dmJmCa{margin-top:5px}.brief-avPHHU .title-wf6R5G{max-width:800px;color:var(--coz-fg-plus);font-size:14px;font-weight:500;line-height:20px}.brief-avPHHU .description-_mYZEb{color:var(--light-usage-text-color-text-1,rgba(28,29,35,.8));text-overflow:ellipsis;margin-top:6px;font-size:14px;font-style:normal;font-weight:700;line-height:22px;overflow:hidden}.brief-avPHHU .semi-tag-blue-light{color:var(--light-color-brand-brand-6,#304cdb);background:var(--light-color-brand-brand-1,#d9e2ff)}.brief-avPHHU .semi-button{padding:8px 12px}.brief-avPHHU .icon-with-suffix-overlay .icon{width:36px;height:36px}.brief-avPHHU .icon-with-suffix-overlay .icon [role=img]>svg{width:24px;height:24px}.brief-avPHHU .icon-with-suffix-overlay .icon [role=img]>svg>path{fill:null}.brief-avPHHU .icon-with-suffix-overlay .suffix{width:18px;height:18px;top:27px;left:27px}.brief-avPHHU .icon-with-suffix-overlay .suffix [role=img]>svg{width:12px;height:12px}.brief-avPHHU .icon-with-suffix-overlay .suffix [role=img]>svg>path{fill:null}.doc-icon-note-Y4yDu5{border-radius:8px}.doc-icon-note-Y4yDu5>svg{width:36px;height:36px}.doc-icon-note-Y4yDu5>svg>path{fill:null}.bot-used-count-fXTy0d{display:flex}.bot-used-count-fXTy0d .related-bots-circle{margin-top:-5px;margin-right:4px;font-size:16px}",""]),s.locals={brief:"brief-avPHHU",info:"info-UEZJMK",icon:"icon-JZZB0l",content:"content-kLh6l2","bot-count":"bot-count-Ni79sf",botCount:"bot-count-Ni79sf","bot-count-text":"bot-count-text-S_PzMm",botCountText:"bot-count-text-S_PzMm","bot-count-icon":"bot-count-icon-Q6mXK_",botCountIcon:"bot-count-icon-Q6mXK_","action-right":"action-right-s4qfdQ",actionRight:"action-right-s4qfdQ",tags:"tags-dmJmCa",title:"title-wf6R5G",description:"description-_mYZEb","doc-icon-note":"doc-icon-note-Y4yDu5",docIconNote:"doc-icon-note-Y4yDu5","bot-used-count":"bot-used-count-fXTy0d",botUsedCount:"bot-used-count-fXTy0d"},t.Z=s},442146:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".hidden-tooltip-kwAPQ0{display:none}.create-opt-select-down-EJVjaX .semi-dropdown-item{min-width:126px}",""]),s.locals={"hidden-tooltip":"hidden-tooltip-kwAPQ0",hiddenTooltip:"hidden-tooltip-kwAPQ0","create-opt-select-down":"create-opt-select-down-EJVjaX",createOptSelectDown:"create-opt-select-down-EJVjaX"},t.Z=s},710505:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".photo-list-PfbhEP{flex-direction:column;height:calc(100vh - 170px);padding:0 24px;display:flex;overflow:auto}.photo-list-PfbhEP .photo-list-spin-mKDCXA{flex:1}.footer-AAJ1oJ{flex-direction:column;align-items:center;padding:12px 0;display:flex}.footer-AAJ1oJ .spin-YxKm6O{width:100%;height:60px;font-size:14px}.card-group-M1g_rk{margin-bottom:25px}.card-qmchij{cursor:auto;border-radius:8px;width:222px;height:258px}.card-qmchij:hover{box-shadow:0 2px 14px rgba(0,0,0,.08)}.card-qmchij .semi-card-cover{justify-content:center;align-items:center;height:142px;display:flex;overflow:hidden}.card-disabled-b2Dimh .semi-card-cover{background:var(--Light-usage-fill---color-fill-0,rgba(46,46,57,.04));border-radius:var(--default,8px)var(--default,8px)0 0}.card-disabled-b2Dimh .semi-card-cover svg{width:32px;height:32px}.card-cover-mTOaAP{cursor:pointer;border-radius:8px 8px 0 0}.card-cover-mTOaAP img{min-height:142px}.prohibit-cover-lrRjvJ{color:var(--Light-usage-text---color-text-3,rgba(29,28,36,.35));text-align:center;text-overflow:ellipsis;font-size:12px;line-height:16px;overflow:hidden}.card-content-ufQcx9{flex-direction:column;gap:8px;display:flex}.card-content-ufQcx9 .photo-name-gZHgc8{color:#1d1c23;font-weight:600;line-height:20px}.card-content-ufQcx9 .photo-description-SpZevy{height:32px;font-size:12px;line-height:16px}.card-content-ufQcx9 .photo-description-SpZevy .failed-tag-oahTUD{color:#db2e13;background-color:#ffe0d2;border-radius:4px;padding:0 6px}.card-content-ufQcx9 .photo-description-SpZevy .processing-tag-l3fWA2{color:#304cdb;background-color:#d9e2ff;border-radius:4px;padding:0 6px}.card-footer-gNXvbn{justify-content:space-between;align-items:center;height:24px;display:flex}.card-footer-gNXvbn .create-time-YuhPtq{color:rgba(28,29,35,.35);font-size:12px;line-height:16px}.confirm-modal-r2MpdF .semi-modal-header{margin-bottom:16px}.confirm-modal-r2MpdF .semi-modal-header .semi-modal-icon-wrapper{margin-right:8px}.confirm-modal-r2MpdF .semi-modal-header .semi-modal-confirm-title-text{color:#1d1c23}.confirm-modal-r2MpdF .semi-modal-header .semi-button:hover{background-color:rgba(46,46,56,.08)}.confirm-modal-r2MpdF .semi-modal-body{margin:0;padding:16px 0}.confirm-modal-r2MpdF .semi-modal-body .semi-modal-confirm-content{color:#1d1c23}.confirm-modal-r2MpdF .semi-modal-footer button{min-width:96px;margin-left:16px}.modal-content-yDnEgG{flex-direction:column;gap:20px;width:100%;display:flex}.modal-content-yDnEgG .photo-large-AsXhSu{justify-content:center;align-items:center;display:flex;position:relative}.modal-content-yDnEgG .photo-large-AsXhSu .arrow-button-qggctu{color:#1d1c23;background-color:rgba(255,255,255,.5);border:none;border-radius:26px;width:48px;height:48px;padding:12px;transition:all .3s;position:absolute;top:126px;box-shadow:0 0 4px rgba(0,0,0,.2),0 0 1px rgba(0,0,0,.2)}.modal-content-yDnEgG .photo-large-AsXhSu .arrow-button-qggctu:hover{color:#4d53e8;background-color:rgba(255,255,255,.8)}.modal-content-yDnEgG .photo-caption-textarea-TM9Ujd{position:relative}.modal-content-yDnEgG .photo-caption-textarea-TM9Ujd .semi-input-textarea-counter{height:40px}.modal-content-yDnEgG .photo-caption-textarea-TM9Ujd .ai-generate-button-dyd1W_{position:absolute;bottom:8px;left:12px}.modal-content-yDnEgG .photo-caption-textarea-TM9Ujd>span{display:inline!important}",""]),s.locals={"photo-list":"photo-list-PfbhEP",photoList:"photo-list-PfbhEP","photo-list-spin":"photo-list-spin-mKDCXA",photoListSpin:"photo-list-spin-mKDCXA",footer:"footer-AAJ1oJ",spin:"spin-YxKm6O","card-group":"card-group-M1g_rk",cardGroup:"card-group-M1g_rk",card:"card-qmchij","card-disabled":"card-disabled-b2Dimh",cardDisabled:"card-disabled-b2Dimh","card-cover":"card-cover-mTOaAP",cardCover:"card-cover-mTOaAP","prohibit-cover":"prohibit-cover-lrRjvJ",prohibitCover:"prohibit-cover-lrRjvJ","card-content":"card-content-ufQcx9",cardContent:"card-content-ufQcx9","photo-name":"photo-name-gZHgc8",photoName:"photo-name-gZHgc8","photo-description":"photo-description-SpZevy",photoDescription:"photo-description-SpZevy","failed-tag":"failed-tag-oahTUD",failedTag:"failed-tag-oahTUD","processing-tag":"processing-tag-l3fWA2",processingTag:"processing-tag-l3fWA2","card-footer":"card-footer-gNXvbn",cardFooter:"card-footer-gNXvbn","create-time":"create-time-YuhPtq",createTime:"create-time-YuhPtq","confirm-modal":"confirm-modal-r2MpdF",confirmModal:"confirm-modal-r2MpdF","modal-content":"modal-content-yDnEgG",modalContent:"modal-content-yDnEgG","photo-large":"photo-large-AsXhSu",photoLarge:"photo-large-AsXhSu","arrow-button":"arrow-button-qggctu",arrowButton:"arrow-button-qggctu","photo-caption-textarea":"photo-caption-textarea-TM9Ujd",photoCaptionTextarea:"photo-caption-textarea-TM9Ujd","ai-generate-button":"ai-generate-button-dyd1W_",aiGenerateButton:"ai-generate-button-dyd1W_"},t.Z=s},613498:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".photo-filter-tab-JuIw2Q{display:flex}.photo-filter-tab-item-kIEeYi{cursor:pointer;color:rgba(29,28,35,.6);height:14px;font-weight:600;line-height:20px}.photo-filter-tab-item-active-mu4FU4{cursor:pointer;color:#4d53e8;height:14px;font-weight:600;line-height:20px}",""]),s.locals={"photo-filter-tab":"photo-filter-tab-JuIw2Q",photoFilterTab:"photo-filter-tab-JuIw2Q","photo-filter-tab-item":"photo-filter-tab-item-kIEeYi",photoFilterTabItem:"photo-filter-tab-item-kIEeYi","photo-filter-tab-item-active":"photo-filter-tab-item-active-mu4FU4",photoFilterTabItemActive:"photo-filter-tab-item-active-mu4FU4"},t.Z=s},963731:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".header-ukEVpj{padding-bottom:32px}.breadcrumb-PoJGjA{align-items:center;display:flex}",""]),s.locals={header:"header-ukEVpj",breadcrumb:"breadcrumb-PoJGjA"},t.Z=s},762642:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".related-bots-list-e4SMfM{min-width:20px;min-height:20px;max-height:396px;font-weight:500;line-height:20px;overflow:scroll}.related-bots-list-item-AdE7cE{display:flex}.related-bots-list-e4SMfM .related-bots-circle{margin-top:-4px;margin-right:4px;font-size:18px}",""]),s.locals={"related-bots-list":"related-bots-list-e4SMfM",relatedBotsList:"related-bots-list-e4SMfM","related-bots-list-item":"related-bots-list-item-AdE7cE",relatedBotsListItem:"related-bots-list-item-AdE7cE"},t.Z=s},501893:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".icon-with-suffix-agqPVZ{margin-right:12px;position:relative}.icon-with-suffix-agqPVZ .icon-with-suffix-common{flex-shrink:0;justify-content:center;align-items:center;display:flex}.icon-with-suffix-agqPVZ .icon{border-radius:4px;width:24px;height:24px;top:0;left:0}.icon-with-suffix-agqPVZ .suffix{z-index:1;border-radius:2.667px;width:12px;height:12px;position:absolute;top:16px;left:16px}",""]),s.locals={"icon-with-suffix":"icon-with-suffix-agqPVZ",iconWithSuffix:"icon-with-suffix-agqPVZ"},t.Z=s},223812:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".photo-list-LOOtT7{flex-direction:column;height:calc(100vh - 170px);padding:0 24px;display:flex;overflow:auto}.photo-list-LOOtT7 .photo-list-spin-kd3R2W{flex:1}.footer-MvKZhp{flex-direction:column;align-items:center;padding:12px 0;display:flex}.footer-MvKZhp .spin-UIOUrj{width:100%;height:60px;font-size:14px}.card-group-rWg9iG{margin-bottom:25px}.card-LCMg4i{cursor:auto;border-radius:8px;width:222px;height:258px}.card-LCMg4i:hover{box-shadow:0 2px 14px rgba(0,0,0,.08)}.card-LCMg4i .semi-card-cover{justify-content:center;align-items:center;height:142px;display:flex;overflow:hidden}.card-disabled-dlKa9B .semi-card-cover{background:var(--Light-usage-fill---color-fill-0,rgba(46,46,57,.04));border-radius:var(--default,8px)var(--default,8px)0 0}.card-disabled-dlKa9B .semi-card-cover svg{width:32px;height:32px}.card-cover-o_0201{cursor:pointer;border-radius:8px 8px 0 0}.card-cover-o_0201 img{min-height:142px}.prohibit-cover-ppuEY6{color:var(--Light-usage-text---color-text-3,rgba(29,28,36,.35));text-align:center;text-overflow:ellipsis;font-size:12px;line-height:16px;overflow:hidden}.card-content-NpmC_l{flex-direction:column;gap:8px;display:flex}.card-content-NpmC_l .photo-name-jgYlvC{color:#1d1c23;font-weight:600;line-height:20px}.card-content-NpmC_l .photo-description-_F7pR4{height:32px;font-size:12px;line-height:16px}.card-content-NpmC_l .photo-description-_F7pR4 .failed-tag-Cf3WT5{color:#db2e13;background-color:#ffe0d2;border-radius:4px;padding:0 6px}.card-content-NpmC_l .photo-description-_F7pR4 .processing-tag-DssWtK{color:#304cdb;background-color:#d9e2ff;border-radius:4px;padding:0 6px}.card-footer-ZWk5X8{justify-content:space-between;align-items:center;height:24px;display:flex}.card-footer-ZWk5X8 .create-time-ObsLER{color:rgba(28,29,35,.35);font-size:12px;line-height:16px}.confirm-modal-pL5KBf .semi-modal-header{margin-bottom:16px}.confirm-modal-pL5KBf .semi-modal-header .semi-modal-icon-wrapper{margin-right:8px}.confirm-modal-pL5KBf .semi-modal-header .semi-modal-confirm-title-text{color:#1d1c23}.confirm-modal-pL5KBf .semi-modal-header .semi-button:hover{background-color:rgba(46,46,56,.08)}.confirm-modal-pL5KBf .semi-modal-body{margin:0;padding:16px 0}.confirm-modal-pL5KBf .semi-modal-body .semi-modal-confirm-content{color:#1d1c23}.confirm-modal-pL5KBf .semi-modal-footer button{min-width:96px;margin-left:16px}.modal-content-QW1JYU{flex-direction:column;gap:20px;width:100%;display:flex}.modal-content-QW1JYU .photo-large-r9exiY{justify-content:center;align-items:center;display:flex;position:relative}.modal-content-QW1JYU .photo-large-r9exiY .arrow-button-iulTT_{color:#1d1c23;background-color:rgba(255,255,255,.5);border:none;border-radius:26px;width:48px;height:48px;padding:12px;transition:all .3s;position:absolute;top:126px;box-shadow:0 0 4px rgba(0,0,0,.2),0 0 1px rgba(0,0,0,.2)}.modal-content-QW1JYU .photo-large-r9exiY .arrow-button-iulTT_:hover{color:#4d53e8;background-color:rgba(255,255,255,.8)}.modal-content-QW1JYU .photo-caption-textarea-iFazLB{position:relative}.modal-content-QW1JYU .photo-caption-textarea-iFazLB .semi-input-textarea-counter{height:40px}.modal-content-QW1JYU .photo-caption-textarea-iFazLB .ai-generate-button-MlLJI2{position:absolute;bottom:8px;left:12px}.modal-content-QW1JYU .photo-caption-textarea-iFazLB>span{display:inline!important}",""]),s.locals={"photo-list":"photo-list-LOOtT7",photoList:"photo-list-LOOtT7","photo-list-spin":"photo-list-spin-kd3R2W",photoListSpin:"photo-list-spin-kd3R2W",footer:"footer-MvKZhp",spin:"spin-UIOUrj","card-group":"card-group-rWg9iG",cardGroup:"card-group-rWg9iG",card:"card-LCMg4i","card-disabled":"card-disabled-dlKa9B",cardDisabled:"card-disabled-dlKa9B","card-cover":"card-cover-o_0201",cardCover:"card-cover-o_0201","prohibit-cover":"prohibit-cover-ppuEY6",prohibitCover:"prohibit-cover-ppuEY6","card-content":"card-content-NpmC_l",cardContent:"card-content-NpmC_l","photo-name":"photo-name-jgYlvC",photoName:"photo-name-jgYlvC","photo-description":"photo-description-_F7pR4",photoDescription:"photo-description-_F7pR4","failed-tag":"failed-tag-Cf3WT5",failedTag:"failed-tag-Cf3WT5","processing-tag":"processing-tag-DssWtK",processingTag:"processing-tag-DssWtK","card-footer":"card-footer-ZWk5X8",cardFooter:"card-footer-ZWk5X8","create-time":"create-time-ObsLER",createTime:"create-time-ObsLER","confirm-modal":"confirm-modal-pL5KBf",confirmModal:"confirm-modal-pL5KBf","modal-content":"modal-content-QW1JYU",modalContent:"modal-content-QW1JYU","photo-large":"photo-large-r9exiY",photoLarge:"photo-large-r9exiY","arrow-button":"arrow-button-iulTT_",arrowButton:"arrow-button-iulTT_","photo-caption-textarea":"photo-caption-textarea-iFazLB",photoCaptionTextarea:"photo-caption-textarea-iFazLB","ai-generate-button":"ai-generate-button-MlLJI2",aiGenerateButton:"ai-generate-button-MlLJI2"},t.Z=s},528878:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".slice-list-ui-content-VE1Ks8{flex:1;padding:0;overflow:auto}.empty-content-hSEdb3{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:5%;display:flex}.slice-modal-title-deFHLH{align-items:center;display:flex}.slice-modal-title-deFHLH .tag-ulO3Oq{margin-left:6px}.serial-number-text-MEY475{color:var(--coz-fg-secondary);font-size:12px}.unit-table-view-LM0GNh .serial-number-MdUFix{color:var(--coz-fg-secondary);padding-left:0!important;font-size:14px!important}.unit-table-view-LM0GNh .coz-tag{font-weight:400}.unit-table-view-LM0GNh .data-tags{min-width:173px}.unit-table-view-LM0GNh .semi-table-wrapper{margin-top:0!important}.slice-article-Df4Vlr{background-color:var(--coz-bg-plus);border:1px solid var(--coz-stroke-primary);border-radius:8px;flex-direction:column;height:calc(100% - 24px);padding:0 16px;display:flex;position:relative;overflow-y:auto}.slice-article-Df4Vlr .slice-article-content-V3Myrr{padding:12px 2px}.text-slice-toolbar-DD6QGy{z-index:10;background-color:var(--coz-bg-plus);border-bottom:1px solid var(--coz-stroke-primary);justify-content:space-between;align-items:center;padding:12px 0;display:flex;position:-webkit-sticky;position:sticky;top:0}.text-slice-toolbar-DD6QGy .content-left-slot-jXmfcZ{flex-direction:row;align-items:center;display:flex}.doc-tag-wrapper-hTLn1f{margin-left:12px}.menu_wrapper-J2iQwg{border-radius:8px!important}.menu-nMVcXa{width:160px;padding:4px}.menu-nMVcXa .semi-dropdown-item{border-radius:6px;height:32px;padding:8px;font-size:12px}.menu-nMVcXa .semi-icon>svg{width:14px;height:14px}.menu-nMVcXa .semi-dropdown-item-disabled>.semi-dropdown-item-icon{opacity:.3}.slice-list-table-OqGaMi{grid-gap:16px;grid-auto-rows:min-content;height:100%;overflow-y:hidden}.table-view-container-box-CMafE6{max-height:calc(100% - 51px)}.add-row-btn-PO8xGH{align-items:center;height:48px;margin-top:8px;display:flex}.spin-UIuwHk .semi-spin-wrapper{position:absolute}.spin-UIuwHk .semi-tabs-content{padding:0}.spin-UIuwHk .semi-spin-children{height:100%}.doc-selector-dropdown-hu2A7U .option-prefix-icon{margin-right:8px}.doc-selector-dropdown-hu2A7U .semi-select-option{cursor:pointer;box-sizing:border-box;word-break:break-word;border-radius:4px;flex-wrap:nowrap;align-items:center;padding:8px 16px;font-size:12px;font-weight:400;line-height:16px;display:flex;position:relative}.doc-selector-dropdown-hu2A7U,.doc-selector-V3vBo8{text-overflow:ellipsis;white-space:nowrap;max-width:723px;overflow:hidden}.doc-selector-dropdown-hu2A7U .semi-input-wrapper{min-width:256px;width:100%!important}.doc-selector-V3vBo8 .semi-input-wrapper{min-width:256px;width:100%!important}.doc-selector-dropdown-hu2A7U .coz-select-option-item.selected .doc-name-item{font-weight:500}.doc-selector-V3vBo8 .coz-select-option-item.selected .doc-name-item{font-weight:500}.doc-option-Qk83IG{max-width:603px;color:var(--coz-fg-primary);flex-direction:row;justify-content:center;align-items:center;display:flex}.doc-name-dtld2X{color:var(--coz-fg-primary);flex:1;margin:0 8px;font-size:14px;font-weight:400;line-height:20px;display:flex;overflow:hidden}.doc-name-selected-rmPTCo{font-weight:500}.doc-name-prev-FWvfSa{text-overflow:ellipsis;white-space:nowrap;flex:1;display:inline-block;overflow:hidden}.borderless-filter-render-qmRxW0{align-items:center;display:flex;overflow:hidden}.borderless-filter-render-qmRxW0 .borderless-filter-text-NTuVI2{color:#1c1f23;text-overflow:ellipsis;white-space:nowrap;font-weight:600}.filter-icon-Yg9iLS{margin-bottom:-2px;margin-left:2px}.doc-selector-trigger-f6FWiu{cursor:pointer;height:32px;color:var(--coz-fg-primary);border-radius:8px;align-items:center;padding:0 12px;font-size:14px;display:flex}.doc-selector-trigger-f6FWiu:hover{background-color:var(--coz-mg-secondary-pressed,rgba(6,7,9,.14))}.doc-selector-trigger-label-dwB705{font-weight:600}.doc-selector-trigger-icon-l3_Oav{cursor:pointer;border-radius:6px;justify-content:center;align-items:center;width:24px;height:24px;display:flex}.doc-selector-trigger-icon-l3_Oav:hover{background-color:var(--coz-mg-secondary-pressed)}.edit-doc-name-container-title-WPYjDu{color:var(--coz-fg-plus);margin-bottom:12px;font-size:14px;font-weight:600;line-height:20px}.edit-doc-name-container-input-bMJAk0{padding-bottom:12px}.edit-doc-name-container-input-error-eEy95C{color:var(--coz-fg-hglt-red);padding:2px 8px 0;font-size:12px;line-height:16px}.table-preview-max-xAlOVp .table-wrapper .semi-table-tbody>.semi-table-row{background-color:#fff!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-thead>.semi-table-row>.semi-table-row-head{background-color:#fff!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-tbody>.semi-table-row>.semi-table-cell-fixed-left{background-color:#fff!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-thead>.semi-table-row>.semi-table-row-head.semi-table-cell-fixed-left:before{background-color:#fff!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-tbody>.semi-table-row>.semi-table-cell-fixed-right{background-color:#fff!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-thead>.semi-table-row>.semi-table-row-head.semi-table-cell-fixed-right:before{background-color:#fff!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-tbody .semi-table-row:hover>.semi-table-row-cell{background-color:#f2f3f7!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-tbody .semi-table-row-selected .semi-table-row-cell{background:#d8dbfb!important}.table-preview-max-xAlOVp .table-wrapper .semi-table-tbody .semi-table-row-selected .semi-table-column-selection{background:#d8dbfb!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-tbody>.semi-table-row{background-color:#fcfcff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-thead>.semi-table-row>.semi-table-row-head{background-color:#fcfcff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-tbody>.semi-table-row>.semi-table-cell-fixed-left{background-color:#fcfcff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-thead>.semi-table-row>.semi-table-row-head.semi-table-cell-fixed-left:before{background-color:#fcfcff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-tbody>.semi-table-row>.semi-table-cell-fixed-right{background-color:#fcfcff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-thead>.semi-table-row>.semi-table-row-head.semi-table-cell-fixed-right:before{background-color:#fcfcff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-tbody .semi-table-row:hover>.semi-table-row-cell{background-color:#eff0f7!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-tbody .semi-table-row-selected .semi-table-row-cell{background:#d9ddff!important}.table-preview-secondary-K5pwRw .table-wrapper .semi-table-tbody .semi-table-row-selected .semi-table-column-selection{background:#d9ddff!important}",""]),s.locals={"slice-list-ui-content":"slice-list-ui-content-VE1Ks8",sliceListUiContent:"slice-list-ui-content-VE1Ks8","empty-content":"empty-content-hSEdb3",emptyContent:"empty-content-hSEdb3","slice-modal-title":"slice-modal-title-deFHLH",sliceModalTitle:"slice-modal-title-deFHLH",tag:"tag-ulO3Oq","serial-number-text":"serial-number-text-MEY475",serialNumberText:"serial-number-text-MEY475","unit-table-view":"unit-table-view-LM0GNh",unitTableView:"unit-table-view-LM0GNh","serial-number":"serial-number-MdUFix",serialNumber:"serial-number-MdUFix","slice-article":"slice-article-Df4Vlr",sliceArticle:"slice-article-Df4Vlr","slice-article-content":"slice-article-content-V3Myrr",sliceArticleContent:"slice-article-content-V3Myrr","text-slice-toolbar":"text-slice-toolbar-DD6QGy",textSliceToolbar:"text-slice-toolbar-DD6QGy","content-left-slot":"content-left-slot-jXmfcZ",contentLeftSlot:"content-left-slot-jXmfcZ","doc-tag-wrapper":"doc-tag-wrapper-hTLn1f",docTagWrapper:"doc-tag-wrapper-hTLn1f",menu_wrapper:"menu_wrapper-J2iQwg",menuWrapper:"menu_wrapper-J2iQwg",menu:"menu-nMVcXa","slice-list-table":"slice-list-table-OqGaMi",sliceListTable:"slice-list-table-OqGaMi","table-view-container-box":"table-view-container-box-CMafE6",tableViewContainerBox:"table-view-container-box-CMafE6","add-row-btn":"add-row-btn-PO8xGH",addRowBtn:"add-row-btn-PO8xGH",spin:"spin-UIuwHk","doc-selector-dropdown":"doc-selector-dropdown-hu2A7U",docSelectorDropdown:"doc-selector-dropdown-hu2A7U","doc-selector":"doc-selector-V3vBo8",docSelector:"doc-selector-V3vBo8","doc-option":"doc-option-Qk83IG",docOption:"doc-option-Qk83IG","doc-name":"doc-name-dtld2X",docName:"doc-name-dtld2X","doc-name-selected":"doc-name-selected-rmPTCo",docNameSelected:"doc-name-selected-rmPTCo","doc-name-prev":"doc-name-prev-FWvfSa",docNamePrev:"doc-name-prev-FWvfSa","borderless-filter-render":"borderless-filter-render-qmRxW0",borderlessFilterRender:"borderless-filter-render-qmRxW0","borderless-filter-text":"borderless-filter-text-NTuVI2",borderlessFilterText:"borderless-filter-text-NTuVI2","filter-icon":"filter-icon-Yg9iLS",filterIcon:"filter-icon-Yg9iLS","doc-selector-trigger":"doc-selector-trigger-f6FWiu",docSelectorTrigger:"doc-selector-trigger-f6FWiu","doc-selector-trigger-label":"doc-selector-trigger-label-dwB705",docSelectorTriggerLabel:"doc-selector-trigger-label-dwB705","doc-selector-trigger-icon":"doc-selector-trigger-icon-l3_Oav",docSelectorTriggerIcon:"doc-selector-trigger-icon-l3_Oav","edit-doc-name-container-title":"edit-doc-name-container-title-WPYjDu",editDocNameContainerTitle:"edit-doc-name-container-title-WPYjDu","edit-doc-name-container-input":"edit-doc-name-container-input-bMJAk0",editDocNameContainerInput:"edit-doc-name-container-input-bMJAk0","edit-doc-name-container-input-error":"edit-doc-name-container-input-error-eEy95C",editDocNameContainerInputError:"edit-doc-name-container-input-error-eEy95C","table-preview-max":"table-preview-max-xAlOVp",tablePreviewMax:"table-preview-max-xAlOVp","table-preview-secondary":"table-preview-secondary-K5pwRw",tablePreviewSecondary:"table-preview-secondary-K5pwRw"},t.Z=s},593171:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".slice-list-ui-content-xVeVXX{flex:1;padding:0;overflow:auto}.empty-content-TqsLW4{justify-content:center;align-items:center;width:100%;height:100%;padding-bottom:5%;display:flex}.slice-modal-title-O3C6yc{align-items:center;display:flex}.slice-modal-title-O3C6yc .tag-cZtBWK{margin-left:6px}.serial-number-text-t5hyMb{color:var(--coz-fg-secondary);font-size:12px}.unit-table-view-S2xco7{background-color:rgba(var(--coze-bg-3),var(--coze-bg-3-alpha))!important}.unit-table-view-S2xco7 .serial-number-qxAnTi{color:var(--coz-fg-secondary);padding-left:0!important;font-size:14px!important}.unit-table-view-S2xco7 .coz-tag{font-weight:400}.unit-table-view-S2xco7 .data-tags{min-width:173px}.unit-table-view-S2xco7 .semi-table-wrapper{margin-top:0!important}.slice-article-FZqkTB{background-color:var(--coz-bg-plus);border:1px solid var(--coz-stroke-primary);border-radius:8px;flex-direction:column;height:calc(100% - 24px);padding:0 16px;display:flex;position:relative;overflow-y:auto}.slice-article-FZqkTB .slice-article-content-jpUNf4{padding:12px 2px}.text-slice-toolbar-PqXFwR{z-index:10;background-color:var(--coz-bg-plus);border-bottom:1px solid var(--coz-stroke-primary);justify-content:space-between;align-items:center;padding:12px 0;display:flex;position:-webkit-sticky;position:sticky;top:0}.text-slice-toolbar-PqXFwR .content-left-slot-nha3hW{flex-direction:row;align-items:center;display:flex}.doc-tag-wrapper-zWE9kv{margin-left:4px}.doc-tag-wrapper-zWE9kv .semi-tag-content{font-weight:500}.menu_wrapper-A128jg{border-radius:8px!important}.menu-i3PLQQ{width:160px;padding:4px}.menu-i3PLQQ .semi-dropdown-item{border-radius:6px;height:32px;padding:8px;font-size:12px}.menu-i3PLQQ .semi-icon>svg{width:14px;height:14px}.menu-i3PLQQ .semi-dropdown-item-disabled>.semi-dropdown-item-icon{opacity:.3}.slice-list-table-xemkOt{grid-gap:16px;grid-auto-rows:min-content;height:100%;padding:0 24px 13px;overflow-y:hidden}.table-view-container-box-he4GUQ{max-height:calc(100% - 51px)}.add-row-btn-YCTzVQ{align-items:center;height:48px;margin-top:8px;display:flex}.spin-cAHWNj .semi-spin-wrapper{position:absolute}.spin-cAHWNj .semi-tabs-content{padding:0}.spin-cAHWNj .semi-spin-children{height:100%}.doc-selector-dropdown-xnIzKp .option-prefix-icon{margin-right:8px}.doc-selector-dropdown-xnIzKp .semi-select-option{cursor:pointer;box-sizing:border-box;word-break:break-word;border-radius:4px;flex-wrap:nowrap;align-items:center;padding:8px 16px;font-size:12px;font-weight:400;line-height:16px;display:flex;position:relative}.doc-selector-dropdown-xnIzKp,.doc-selector-o57wpi{text-overflow:ellipsis;white-space:nowrap;opacity:1;max-width:723px;overflow:hidden}.doc-selector-dropdown-xnIzKp .semi-input-wrapper{min-width:256px;width:100%!important}.doc-selector-o57wpi .semi-input-wrapper{min-width:256px;width:100%!important}.doc-selector-dropdown-xnIzKp .coz-select-option-item.selected .doc-name-item{font-weight:500}.doc-selector-o57wpi .coz-select-option-item.selected .doc-name-item{font-weight:500}.doc-option-I5gL57{max-width:603px;color:var(--coz-fg-primary);flex-direction:row;justify-content:center;align-items:center;display:flex}.doc-name-IqEeLN{color:var(--coz-fg-primary);flex:1;margin:0 8px;font-size:14px;font-weight:400;line-height:20px;display:flex;overflow:hidden}.doc-name-selected-g28FPB{font-weight:500}.doc-name-prev-vrmvry{text-overflow:ellipsis;white-space:nowrap;flex:1;display:inline-block;overflow:hidden}.borderless-filter-render-rgTtVw{align-items:center;display:flex;overflow:hidden}.borderless-filter-render-rgTtVw .borderless-filter-text-n3oW7S{color:#1c1f23;text-overflow:ellipsis;white-space:nowrap;font-weight:600}.filter-icon-Yh58nw{margin-bottom:-2px;margin-left:2px}.doc-selector-trigger-ovSmYd{cursor:pointer;height:32px;color:var(--coz-fg-primary);border-radius:8px;align-items:center;gap:4px;font-size:14px;display:flex}.doc-selector-trigger-ovSmYd:hover{cursor:default}.doc-selector-trigger-icon-PYNEP7{cursor:pointer;border-radius:6px;justify-content:center;align-items:center;width:24px;height:24px;display:flex}.doc-selector-trigger-icon-PYNEP7:hover{background-color:var(--coz-mg-secondary-pressed)}.edit-doc-name-container-title-oVxtLs{color:var(--coz-fg-plus);margin-bottom:12px;font-size:14px;font-weight:600;line-height:20px}.edit-doc-name-container-input-YkQ2Jt{padding-bottom:12px}.edit-doc-name-container-input-error-TSZR_4{color:var(--coz-fg-hglt-red);padding:2px 8px 0;font-size:12px;line-height:16px}",""]),s.locals={"slice-list-ui-content":"slice-list-ui-content-xVeVXX",sliceListUiContent:"slice-list-ui-content-xVeVXX","empty-content":"empty-content-TqsLW4",emptyContent:"empty-content-TqsLW4","slice-modal-title":"slice-modal-title-O3C6yc",sliceModalTitle:"slice-modal-title-O3C6yc",tag:"tag-cZtBWK","serial-number-text":"serial-number-text-t5hyMb",serialNumberText:"serial-number-text-t5hyMb","unit-table-view":"unit-table-view-S2xco7",unitTableView:"unit-table-view-S2xco7","serial-number":"serial-number-qxAnTi",serialNumber:"serial-number-qxAnTi","slice-article":"slice-article-FZqkTB",sliceArticle:"slice-article-FZqkTB","slice-article-content":"slice-article-content-jpUNf4",sliceArticleContent:"slice-article-content-jpUNf4","text-slice-toolbar":"text-slice-toolbar-PqXFwR",textSliceToolbar:"text-slice-toolbar-PqXFwR","content-left-slot":"content-left-slot-nha3hW",contentLeftSlot:"content-left-slot-nha3hW","doc-tag-wrapper":"doc-tag-wrapper-zWE9kv",docTagWrapper:"doc-tag-wrapper-zWE9kv",menu_wrapper:"menu_wrapper-A128jg",menuWrapper:"menu_wrapper-A128jg",menu:"menu-i3PLQQ","slice-list-table":"slice-list-table-xemkOt",sliceListTable:"slice-list-table-xemkOt","table-view-container-box":"table-view-container-box-he4GUQ",tableViewContainerBox:"table-view-container-box-he4GUQ","add-row-btn":"add-row-btn-YCTzVQ",addRowBtn:"add-row-btn-YCTzVQ",spin:"spin-cAHWNj","doc-selector-dropdown":"doc-selector-dropdown-xnIzKp",docSelectorDropdown:"doc-selector-dropdown-xnIzKp","doc-selector":"doc-selector-o57wpi",docSelector:"doc-selector-o57wpi","doc-option":"doc-option-I5gL57",docOption:"doc-option-I5gL57","doc-name":"doc-name-IqEeLN",docName:"doc-name-IqEeLN","doc-name-selected":"doc-name-selected-g28FPB",docNameSelected:"doc-name-selected-g28FPB","doc-name-prev":"doc-name-prev-vrmvry",docNamePrev:"doc-name-prev-vrmvry","borderless-filter-render":"borderless-filter-render-rgTtVw",borderlessFilterRender:"borderless-filter-render-rgTtVw","borderless-filter-text":"borderless-filter-text-n3oW7S",borderlessFilterText:"borderless-filter-text-n3oW7S","filter-icon":"filter-icon-Yh58nw",filterIcon:"filter-icon-Yh58nw","doc-selector-trigger":"doc-selector-trigger-ovSmYd",docSelectorTrigger:"doc-selector-trigger-ovSmYd","doc-selector-trigger-icon":"doc-selector-trigger-icon-PYNEP7",docSelectorTriggerIcon:"doc-selector-trigger-icon-PYNEP7","edit-doc-name-container-title":"edit-doc-name-container-title-oVxtLs",editDocNameContainerTitle:"edit-doc-name-container-title-oVxtLs","edit-doc-name-container-input":"edit-doc-name-container-input-YkQ2Jt",editDocNameContainerInput:"edit-doc-name-container-input-YkQ2Jt","edit-doc-name-container-input-error":"edit-doc-name-container-input-error-TSZR_4",editDocNameContainerInputError:"edit-doc-name-container-input-error-TSZR_4"},t.Z=s},53280:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".slice-list-ui-content-L9KLpT{flex:1;padding:0;overflow:auto}.spin-Q0odqv .semi-spin-wrapper{position:absolute}.spin-Q0odqv .semi-tabs-content{padding:0}.spin-Q0odqv .semi-spin-children{height:100%}.column-type-IcxQp1{margin-left:6px}.list-empty-b8mCfm{justify-content:center;align-items:center;width:100%;height:100%;display:flex}.loading-more-yNQNzu{color:rgba(28,31,35,.6);grid-column:1/-1;justify-content:center;align-items:center;width:100%;height:38px;margin-top:16px;font-size:14px;line-height:20px;display:flex}.header-eHQ57a{padding-bottom:32px}.breadcrumb-d3myjD{align-items:center;display:flex}.btn-icon-icfPg7>svg{width:16px;height:16px}.btn-icon-icfPg7>svg>path{fill:#3370ff}.disable-icon-SYUjJE>svg{width:16px;height:16px}.disable-icon-SYUjJE>svg>path{fill:var(--semi-color-disabled-text)}.doc-icon-QggiXA>svg{width:36px;height:36px}.doc-icon-QggiXA>svg>path{fill:null}.doc-icon-note-n1SWI6>svg{width:36px;height:36px}.doc-icon-note-n1SWI6>svg>path{fill:null}.icon-size-16-Q4sXsY>svg{width:16px;height:16px}.icon-size-16-Q4sXsY>svg>path{fill:null}.slice-list-eRZByx{grid-gap:16px;grid-template-columns:repeat(auto-fill,minmax(322px,1fr));grid-auto-rows:min-content;padding:0 24px 13px;display:grid;overflow-y:auto}.table-view-title-NgkVNw{flex-direction:row;align-items:center;display:flex}.table-view-title-content-nEGR27{cursor:pointer}.table-view-title-NgkVNw .semantic-tag-rqq0qD{margin-left:8px}.slice-list-table-hnnMUa{grid-gap:16px;grid-auto-rows:min-content;height:100%;padding:0 24px 13px;overflow-y:hidden}.slice-modal-title-iEO_rO{align-items:center;display:flex}.slice-modal-title-iEO_rO .tag-LJGKDL{margin-left:6px}.slice-article-hrU1dy{background-color:#fff;border:1px solid rgba(29,28,35,.12);border-radius:8px;flex-direction:column;height:calc(100% - 24px);margin:0 24px;padding:12px 100px;display:flex;position:relative;overflow-y:auto}@media (min-width:1600px){.slice-list-eRZByx{grid-template-columns:repeat(4,minmax(322px,1fr))}}.brief-Z2AtWY{border-bottom:1px solid #e7e7e7;justify-content:space-between;align-items:center;padding:0 24px 15px;display:flex}.brief-Z2AtWY .info-muisfz{align-items:center;display:flex}.brief-Z2AtWY .edit-icon-DIdxSl{color:rgba(29,28,35,.6)}.brief-Z2AtWY .avatar-kgPzhZ{flex-grow:0;flex-shrink:0;width:48px;height:48px}.brief-Z2AtWY .content-Q1mvQl{flex-grow:1;margin-left:18px;overflow:hidden}.brief-Z2AtWY .action-right-QWqsgm{margin-left:auto}.brief-Z2AtWY .tags-Xad1oz{margin-top:5px}.brief-Z2AtWY .title-mOAWII{max-width:800px;color:var(--light-usage-text-color-text-0,#1c1d23);margin-right:5px;font-size:20px;font-weight:600;line-height:28px}.brief-Z2AtWY .description-owXLbP{color:var(--light-usage-text-color-text-1,rgba(28,29,35,.8));text-overflow:ellipsis;margin-top:6px;font-size:14px;font-style:normal;font-weight:700;line-height:22px;overflow:hidden}.brief-Z2AtWY .semi-tag-blue-light{color:var(--light-color-brand-brand-6,#304cdb);background:var(--light-color-brand-brand-1,#d9e2ff)}.brief-Z2AtWY .semi-button{padding:8px 12px}.brief-Z2AtWY .icon-with-suffix-overlay .icon{width:36px;height:36px}.brief-Z2AtWY .icon-with-suffix-overlay .icon [role=img]>svg{width:24px;height:24px}.brief-Z2AtWY .icon-with-suffix-overlay .icon [role=img]>svg>path{fill:null}.brief-Z2AtWY .icon-with-suffix-overlay .suffix{width:18px;height:18px;top:27px;left:27px}.brief-Z2AtWY .icon-with-suffix-overlay .suffix [role=img]>svg{width:12px;height:12px}.brief-Z2AtWY .icon-with-suffix-overlay .suffix [role=img]>svg>path{fill:null}.slice-search-gmKvc3{justify-content:space-between;align-items:center;padding:28px 24px 20px;display:flex}.slice-search-gmKvc3 .search-input-ejxco2{border-radius:8px;width:255px}.slice-search-gmKvc3 .slice-title-Cgh6ws{color:var(--light-usage-text-color-text-0,#1c1d23);font-size:18px;font-weight:600;line-height:24px}.slice-search-gmKvc3 .semi-button-primary.semi-button-borderless{color:var(--light-color-grey-grey-9,#1c1d23)}.slice-search-gmKvc3 .semi-button-primary.semi-button-light{color:var(--light-color-grey-grey-9,#1c1d23)}.slice-search-gmKvc3 .input-prefix-EX2voJ{padding:0 8px 0 16px}.hidden-tooltip-wsZVVa{display:none}.data-render-K5tMhb{gap:12px;display:flex}.serial-number-text-Z5u29Y{color:var(--coz-fg-secondary);font-size:12px}.unit-table-view-MPCL5Q .serial-number-S3TWyD{padding-left:0!important;font-size:14px!important}.unit-table-view-MPCL5Q .data-tags{min-width:173px}.menu-va7NEB{width:176px;padding:4px}.menu-va7NEB{color:#1c1d23}.menu-va7NEB .semi-dropdown-item{border-radius:6px;padding:5px 8px;font-size:12px}.menu-va7NEB .semi-icon>svg{height:14px}.menu-va7NEB .semi-dropdown-item-disabled>.semi-dropdown-item-icon{opacity:.3}.knowledge-preview-modal-DNIVjM .semi-modal-content{padding:0;max-height:100vh!important}.knowledge-preview-modal-DNIVjM .semi-modal-body{padding:0!important}.knowledge-preview-modal-DNIVjM .semi-modal-body-wrapper{margin:0}.knowledge-preview-modal-DNIVjM .semi-modal-body-wrapper{height:100%}.knowledge-preview-modal-DNIVjM .semi-modal-body{height:100%}.knowledge-preview-modal-DNIVjM .semi-modal-body>div{height:100%}.text-render-container-qrhcgL{width:100%}.warning-jHykM_ .text-content{color:#ff2500}",""]),s.locals={"slice-list-ui-content":"slice-list-ui-content-L9KLpT",sliceListUiContent:"slice-list-ui-content-L9KLpT",spin:"spin-Q0odqv","column-type":"column-type-IcxQp1",columnType:"column-type-IcxQp1","list-empty":"list-empty-b8mCfm",listEmpty:"list-empty-b8mCfm","loading-more":"loading-more-yNQNzu",loadingMore:"loading-more-yNQNzu",header:"header-eHQ57a",breadcrumb:"breadcrumb-d3myjD","btn-icon":"btn-icon-icfPg7",btnIcon:"btn-icon-icfPg7","disable-icon":"disable-icon-SYUjJE",disableIcon:"disable-icon-SYUjJE","doc-icon":"doc-icon-QggiXA",docIcon:"doc-icon-QggiXA","doc-icon-note":"doc-icon-note-n1SWI6",docIconNote:"doc-icon-note-n1SWI6","icon-size-16":"icon-size-16-Q4sXsY",iconSize16:"icon-size-16-Q4sXsY","slice-list":"slice-list-eRZByx",sliceList:"slice-list-eRZByx","table-view-title":"table-view-title-NgkVNw",tableViewTitle:"table-view-title-NgkVNw","table-view-title-content":"table-view-title-content-nEGR27",tableViewTitleContent:"table-view-title-content-nEGR27","semantic-tag":"semantic-tag-rqq0qD",semanticTag:"semantic-tag-rqq0qD","slice-list-table":"slice-list-table-hnnMUa",sliceListTable:"slice-list-table-hnnMUa","slice-modal-title":"slice-modal-title-iEO_rO",sliceModalTitle:"slice-modal-title-iEO_rO",tag:"tag-LJGKDL","slice-article":"slice-article-hrU1dy",sliceArticle:"slice-article-hrU1dy",brief:"brief-Z2AtWY",info:"info-muisfz","edit-icon":"edit-icon-DIdxSl",editIcon:"edit-icon-DIdxSl",avatar:"avatar-kgPzhZ",content:"content-Q1mvQl","action-right":"action-right-QWqsgm",actionRight:"action-right-QWqsgm",tags:"tags-Xad1oz",title:"title-mOAWII",description:"description-owXLbP","slice-search":"slice-search-gmKvc3",sliceSearch:"slice-search-gmKvc3","search-input":"search-input-ejxco2",searchInput:"search-input-ejxco2","slice-title":"slice-title-Cgh6ws",sliceTitle:"slice-title-Cgh6ws","input-prefix":"input-prefix-EX2voJ",inputPrefix:"input-prefix-EX2voJ","hidden-tooltip":"hidden-tooltip-wsZVVa",hiddenTooltip:"hidden-tooltip-wsZVVa","data-render":"data-render-K5tMhb",dataRender:"data-render-K5tMhb","serial-number-text":"serial-number-text-Z5u29Y",serialNumberText:"serial-number-text-Z5u29Y","unit-table-view":"unit-table-view-MPCL5Q",unitTableView:"unit-table-view-MPCL5Q","serial-number":"serial-number-S3TWyD",serialNumber:"serial-number-S3TWyD",menu:"menu-va7NEB","knowledge-preview-modal":"knowledge-preview-modal-DNIVjM",knowledgePreviewModal:"knowledge-preview-modal-DNIVjM","text-render-container":"text-render-container-qrhcgL",textRenderContainer:"text-render-container-qrhcgL",warning:"warning-jHykM_"},t.Z=s},136965:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".progress-wrap-aG7E1c{background:var(--coz-mg-card);border:1px solid var(--coz-stroke-primary);border-radius:var(--default,8px);align-self:stretch;align-items:center;gap:10px;padding:8px 10px;display:flex;overflow:hidden}.progress-wrap-aG7E1c .content-oMctjI{z-index:1}.progress-wrap-aG7E1c .progress-rFtZNC{background:linear-gradient(rgba(148,152,247,.44),rgba(255,255,255,0));position:absolute;top:0;bottom:0;left:0}.progress-wrap-aG7E1c .info-HxV9yH .main-text-MMJMjm{color:var(--coz-fg-primary);font-size:14px;line-height:20px}.progress-wrap-aG7E1c .info-HxV9yH .sub-text-fLSQkk{color:var(--coz-fg-secondary);font-size:12px;line-height:16px}.progress-wrap-aG7E1c .info-HxV9yH .desc-perJT2{display:block}.progress-wrap-aG7E1c .info-HxV9yH .tip-desc-zJnp5I{display:none}.progress-wrap-aG7E1c .info-HxV9yH .semi-image{margin-right:0!important}.progress-wrap-aG7E1c:hover .info-HxV9yH .desc-perJT2{display:none}.progress-wrap-aG7E1c:hover .info-HxV9yH .tip-desc-zJnp5I{display:block}.progress-wrap-aG7E1c.processing-failed-Ngh1Ak{border:1px solid var(--coz-stroke-hglt-red)}.progress-wrap-aG7E1c.processing-failed-Ngh1Ak .sub-text-fLSQkk{color:var(--coz-fg-hglt-red)!important}.progress-wrap-aG7E1c.processing-EXtgs8:hover .info-HxV9yH .desc-perJT2{display:block}.progress-wrap-aG7E1c.processing-EXtgs8:hover .info-HxV9yH .tip-desc-zJnp5I{display:none}.progress-wrap-aG7E1c .right-d4B8Yg{z-index:2}.progress-wrap-aG7E1c .percent-_hawuy{color:var(--coz-fg-primary);text-align:right;text-overflow:ellipsis;font-size:14px;font-style:normal;font-weight:400;line-height:20px}.progress-wrap-aG7E1c .actions-iVWvwU{display:none}.progress-wrap-aG7E1c:hover .actions-iVWvwU{display:block}",""]),s.locals={"progress-wrap":"progress-wrap-aG7E1c",progressWrap:"progress-wrap-aG7E1c",content:"content-oMctjI",progress:"progress-rFtZNC",info:"info-HxV9yH","main-text":"main-text-MMJMjm",mainText:"main-text-MMJMjm","sub-text":"sub-text-fLSQkk",subText:"sub-text-fLSQkk",desc:"desc-perJT2","tip-desc":"tip-desc-zJnp5I",tipDesc:"tip-desc-zJnp5I","processing-failed":"processing-failed-Ngh1Ak",processingFailed:"processing-failed-Ngh1Ak",processing:"processing-EXtgs8",right:"right-d4B8Yg",percent:"percent-_hawuy",actions:"actions-iVWvwU"},t.Z=s},238205:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,".upload-si61kX{width:100%}.upload-si61kX .semi-upload-drag-area{background-color:var(--coz-mg-card);border-radius:8px;height:202px}.upload-si61kX .semi-upload-drag-area:hover{border-radius:var(--default,8px)}.upload-si61kX .semi-upload-drag-area.semi-upload-drag-area-legal{border-radius:var(--default,8px)}.upload-si61kX .semi-upload-drag-area-sub-text{color:var(--coz-fg-dim)}.upload-si61kX .semi-button-with-icon-only{border-radius:4px}.upload-si61kX .semi-upload-file-list{display:none}.upload-icon-iaQIvU{width:32px;height:32px}.create-enough-file-gKQjYO{cursor:not-allowed;flex-direction:column;justify-content:center;align-items:center;width:100%;height:100%;display:flex}.create-enough-file-gKQjYO .picture-rutWZA{width:122px;height:122px;margin-bottom:14px}.create-enough-file-gKQjYO .text-fu7IXG{color:rgba(28,31,35,.6);font-size:12px;line-height:16px}",""]),s.locals={upload:"upload-si61kX","upload-icon":"upload-icon-iaQIvU",uploadIcon:"upload-icon-iaQIvU","create-enough-file":"create-enough-file-gKQjYO",createEnoughFile:"create-enough-file-gKQjYO",picture:"picture-rutWZA",text:"text-fu7IXG"},t.Z=s},315631:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,":root{--react-pdf-annotation-layer:1;--annotation-unfocused-field-background:url(\"data:image/svg+xml;charset=UTF-8,\");--input-focus-border-color:Highlight;--input-focus-outline:1px solid Canvas;--input-unfocused-border-color:transparent;--input-disabled-border-color:transparent;--input-hover-border-color:black;--link-outline:none}@media screen and (forced-colors:active){:root{--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 .textWidgetAnnotation input:required{outline:1.5px solid selecteditem}.annotationLayer .textWidgetAnnotation textarea:required{outline:1.5px solid selecteditem}.annotationLayer .buttonWidgetAnnotation.checkBox input:required{outline:1.5px solid selecteditem}.annotationLayer .buttonWidgetAnnotation.radioButton input:required{outline:1.5px solid selecteditem}.annotationLayer .choiceWidgetAnnotation select:required{outline:1.5px solid selecteditem}.annotationLayer .linkAnnotation:hover{-webkit-backdrop-filter:invert();backdrop-filter:invert()}}.annotationLayer{pointer-events:none;transform-origin:0 0;z-index:3;position:absolute;top:0;left:0}.annotationLayer[data-main-rotation=\"90\"] .norotate{transform:rotate(270deg)translate(-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 canvas{width:100%;height:100%;position:absolute}.annotationLayer section{text-align:initial;pointer-events:auto;box-sizing:border-box;transform-origin:0 0;margin:0;position:absolute}.annotationLayer .linkAnnotation{outline:var(--link-outline)}.annotationLayer .linkAnnotation:not(.does-not-exist)>a,.annotationLayer .buttonWidgetAnnotation.pushButton>a{width:100%;height:100%;font-size:1em;position:absolute;top:0;left:0}.annotationLayer .linkAnnotation:not(.does-not-exist)>a:hover,.annotationLayer .buttonWidgetAnnotation.pushButton>a:hover{opacity:.2;background:#ff0;box-shadow:0 2px 10px #ff0}.annotationLayer .textAnnotation img{cursor:pointer;width:100%;height:100%;position:absolute;top:0;left:0}.annotationLayer .textWidgetAnnotation input,.annotationLayer .textWidgetAnnotation textarea,.annotationLayer .choiceWidgetAnnotation select,.annotationLayer .buttonWidgetAnnotation.checkBox input,.annotationLayer .buttonWidgetAnnotation.radioButton input{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;vertical-align:top;width:100%;height:100%;margin:0}.annotationLayer .textWidgetAnnotation input:required{outline:1.5px solid red}.annotationLayer .textWidgetAnnotation textarea:required{outline:1.5px solid red}.annotationLayer .buttonWidgetAnnotation.checkBox input:required{outline:1.5px solid red}.annotationLayer .buttonWidgetAnnotation.radioButton input:required{outline:1.5px solid red}.annotationLayer .choiceWidgetAnnotation select: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 .textWidgetAnnotation input[disabled],.annotationLayer .textWidgetAnnotation textarea[disabled],.annotationLayer .choiceWidgetAnnotation select[disabled],.annotationLayer .buttonWidgetAnnotation.checkBox input[disabled],.annotationLayer .buttonWidgetAnnotation.radioButton input[disabled]{border:2px solid var(--input-disabled-border-color);cursor:not-allowed;background:0 0}.annotationLayer .textWidgetAnnotation input:hover,.annotationLayer .textWidgetAnnotation textarea:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .buttonWidgetAnnotation.checkBox input:hover,.annotationLayer .buttonWidgetAnnotation.radioButton input:hover{border:2px solid var(--input-hover-border-color)}.annotationLayer .textWidgetAnnotation input:hover,.annotationLayer .textWidgetAnnotation textarea:hover,.annotationLayer .choiceWidgetAnnotation select:hover,.annotationLayer .buttonWidgetAnnotation.checkBox input:hover{border-radius:2px}.annotationLayer .textWidgetAnnotation input:focus,.annotationLayer .textWidgetAnnotation textarea:focus,.annotationLayer .choiceWidgetAnnotation select:focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline);background:0 0;border-radius:2px}.annotationLayer .buttonWidgetAnnotation.checkBox :focus,.annotationLayer .buttonWidgetAnnotation.radioButton :focus{background-color:transparent;background-image:none}.annotationLayer .buttonWidgetAnnotation.checkBox :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline);border-radius:2px}.annotationLayer .buttonWidgetAnnotation.radioButton :focus{border:2px solid var(--input-focus-border-color);outline:var(--input-focus-outline)}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after,.annotationLayer .buttonWidgetAnnotation.radioButton input:checked:before{content:\"\";background-color:canvastext;display:block;position:absolute}.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:before,.annotationLayer .buttonWidgetAnnotation.checkBox input:checked:after{width:1px;height:80%;left:45%}.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%;width:50%;height:50%;top:20%;left:30%}.annotationLayer .textWidgetAnnotation input.comb{padding-left:2px;padding-right:0;font-family:monospace}.annotationLayer .textWidgetAnnotation input.comb:focus{width:103%}.annotationLayer .buttonWidgetAnnotation.checkBox input,.annotationLayer .buttonWidgetAnnotation.radioButton input{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;appearance:none}.annotationLayer .popupTriggerArea{width:100%;height:100%}.annotationLayer .fileAttachmentAnnotation .popupTriggerArea{position:absolute}.annotationLayer .popupWrapper{font-size:calc(9px*var(--scale-factor));width:100%;min-width:calc(180px*var(--scale-factor));pointer-events:none;position:absolute}.annotationLayer .popup{max-width:calc(180px*var(--scale-factor));box-shadow:0 calc(2px*var(--scale-factor))calc(5px*var(--scale-factor))#888;border-radius:calc(2px*var(--scale-factor));padding:calc(6px*var(--scale-factor));margin-left:calc(5px*var(--scale-factor));cursor:pointer;font:message-box;white-space:normal;word-wrap:break-word;pointer-events:auto;background-color:#ff9;position:absolute}.annotationLayer .popup>*{font-size:calc(9px*var(--scale-factor))}.annotationLayer .popup h1{display:inline-block}.annotationLayer .popupDate{margin-left:calc(5px*var(--scale-factor));display:inline-block}.annotationLayer .popupContent{margin-top:calc(2px*var(--scale-factor));padding-top:calc(2px*var(--scale-factor));border-top:1px solid #333}.annotationLayer .richText>*{white-space:pre-wrap;font-size:calc(9px*var(--scale-factor))}.annotationLayer .highlightAnnotation,.annotationLayer .underlineAnnotation,.annotationLayer .squigglyAnnotation,.annotationLayer .strikeoutAnnotation,.annotationLayer .freeTextAnnotation,.annotationLayer .lineAnnotation svg line,.annotationLayer .squareAnnotation svg rect,.annotationLayer .circleAnnotation svg ellipse,.annotationLayer .polylineAnnotation svg polyline,.annotationLayer .polygonAnnotation svg polygon,.annotationLayer .caretAnnotation,.annotationLayer .inkAnnotation svg polyline,.annotationLayer .stampAnnotation,.annotationLayer .fileAttachmentAnnotation{cursor:pointer}.annotationLayer section svg{width:100%;height:100%;position:absolute;top:0;left:0}.annotationLayer .annotationTextContent{opacity:0;color:transparent;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;pointer-events:none;width:100%;height:100%;position:absolute}.annotationLayer .annotationTextContent span{width:100%;display:inline-block}",""]),t.Z=s},145518:function(e,t,n){var i=n(125161),r=n.n(i),o=n(404442),s=n.n(o)()(r());s.push([e.id,':root{--react-pdf-text-layer:1;--highlight-bg-color:#b400aa;--highlight-selected-bg-color:#006400}@media screen and (forced-colors:active){:root{--highlight-bg-color:Highlight;--highlight-selected-bg-color:ButtonText}}[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)translate(-100%)}.textLayer{text-align:initial;-webkit-text-size-adjust:none;-moz-text-size-adjust:none;-ms-text-size-adjust:none;text-size-adjust:none;forced-color-adjust:none;transform-origin:0 0;z-index:2;line-height:1;position:absolute;top:0;bottom:0;left:0;right:0;overflow:hidden}.textLayer span,.textLayer br{color:transparent;white-space:pre;cursor:text;transform-origin:0 0;margin:0;position:absolute}.textLayer span.markedContent{height:0;top:0}.textLayer .highlight{background-color:var(--highlight-bg-color);border-radius:4px;margin:-1px;padding:1px}.textLayer .highlight.appended{position:initial}.textLayer .highlight.begin{border-radius:4px 0 0 4px}.textLayer .highlight.end{border-radius:0 4px 4px 0}.textLayer .highlight.middle{border-radius:0}.textLayer .highlight.selected{background-color:var(--highlight-selected-bg-color)}.textLayer br::-moz-selection{background:0 0}.textLayer br::selection{background:0 0}.textLayer .endOfContent{z-index:-1;cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;position:absolute;top:100%;bottom:0;left:0;right:0}.textLayer .endOfContent.active{top:0}.hiddenCanvasElement{width:0;height:0;display:none;position:absolute;top:0;left:0}',""]),t.Z=s},887869:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(315631),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},107440:function(e,t,n){var i=n(407821),r=n.n(i),o=n(472772),s=n.n(o),a=n(395245),l=n.n(a),d=n(297998),c=n.n(d),h=n(646576),u=n.n(h),p=n(606121),f=n.n(p),m=n(145518),g={};g.styleTagTransform=f(),g.setAttributes=c(),g.insert=l().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=u(),r()(m.Z,g),m.Z&&m.Z.locals&&m.Z.locals},453203:function(e,t,n){n.d(t,{ML:()=>e8,P1:()=>K,hj:()=>eg,NB:()=>tn,x2:()=>e9,zK:()=>te,S0:()=>tt,qv:()=>eB,Cf:()=>e7,vc:()=>ec,Nl:()=>$,nU:()=>X,EG:()=>eq,K9:()=>ti});var i,r=n("871738"),o=n("661763"),s=n("132308"),a=n("153737"),l=n("240554");let d=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function c(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("backward",e):!(n.parentOffset>0))?n:null}let h=(e,t,n)=>{let i=c(e,n);if(!i)return!1;let o=v(i);if(!o){let n=i.blockRange(),r=n&&(0,l.k9)(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let s=o.nodeBefore;if(O(e,o,t,-1))return!0;if(0==i.parent.content.size&&(m(s,"end")||r.qv.isSelectable(s)))for(let n=i.depth;;n--){let d=(0,l.dR)(e.doc,i.before(n),i.after(n),a.p2.empty);if(d&&d.slice.size1)break}return!!s.isAtom&&o.depth==i.depth-1&&(t&&t(e.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0)},u=(e,t,n)=>{let i=c(e,n);if(!i)return!1;let r=v(i);return!!r&&f(e,r,t)},p=(e,t,n)=>{let i=b(e,n);if(!i)return!1;let r=w(i);return!!r&&f(e,r,t)};function f(e,t,n){let i=t.nodeBefore,o=t.pos-1;for(;!i.isTextblock;o--){if(i.type.spec.isolating)return!1;let e=i.lastChild;if(!e)return!1;i=e}let s=t.nodeAfter,d=t.pos+1;for(;!s.isTextblock;d++){if(s.type.spec.isolating)return!1;let e=s.firstChild;if(!e)return!1;s=e}let c=(0,l.dR)(e.doc,o,d,a.p2.empty);if(!c||c.from!=o||c instanceof l.Pu&&c.slice.size>=d-o)return!1;if(n){let t=e.tr.step(c);t.setSelection(r.Bs.create(t.doc,o)),n(t.scrollIntoView())}return!0}function m(e,t,n=!1){for(let i=e;i;i="start"==t?i.firstChild:i.lastChild){if(i.isTextblock)return!0;if(n&&1!=i.childCount)break}return!1}let g=(e,t,n)=>{let{$head:i,empty:o}=e.selection,s=i;if(!o)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):i.parentOffset>0)return!1;s=v(i)}let a=s&&s.nodeBefore;return!!(a&&r.qv.isSelectable(a))&&(t&&t(e.tr.setSelection(r.qv.create(e.doc,s.pos-a.nodeSize)).scrollIntoView()),!0)};function v(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function b(e,t){let{$cursor:n}=e.selection;return n&&(t?t.endOfTextblock("forward",e):!(n.parentOffset{let i=b(e,n);if(!i)return!1;let o=w(i);if(!o)return!1;let s=o.nodeAfter;if(O(e,o,t,1))return!0;if(0==i.parent.content.size&&(m(s,"start")||r.qv.isSelectable(s))){let n=(0,l.dR)(e.doc,i.before(),i.after(),a.p2.empty);if(n&&n.slice.size{let{$head:i,empty:o}=e.selection,s=i;if(!o)return!1;if(i.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):i.parentOffset=0;t--){let n=e.node(t);if(e.index(t)+1{let n=e.selection,i=n instanceof r.qv,o;if(i){if(n.node.isTextblock||!(0,l.Mn)(e.doc,n.from))return!1;o=n.from}else if(null==(o=(0,l.GJ)(e.doc,n.from,-1)))return!1;if(t){let n=e.tr.join(o);i&&n.setSelection(r.qv.create(n.doc,o-e.doc.resolve(o).nodeBefore.nodeSize)),t(n.scrollIntoView())}return!0},S=(e,t)=>{let n=e.selection,i;if(n instanceof r.qv){if(n.node.isTextblock||!(0,l.Mn)(e.doc,n.to))return!1;i=n.to}else if(null==(i=(0,l.GJ)(e.doc,n.to,1)))return!1;return t&&t(e.tr.join(i).scrollIntoView()),!0},C=(e,t)=>{let{$from:n,$to:i}=e.selection,r=n.blockRange(i),o=r&&(0,l.k9)(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)},A=(e,t)=>{let{$head:n,$anchor:i}=e.selection;return!!(n.parent.type.spec.code&&n.sameParent(i))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function E(e){for(let t=0;t{let{$head:n,$anchor:i}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(i))return!1;let o=n.node(-1),s=n.indexAfter(-1),a=E(o.contentMatchAt(s));if(!a||!o.canReplaceWith(s,s,a))return!1;if(t){let i=n.after(),o=e.tr.replaceWith(i,i,a.createAndFill());o.setSelection(r.Y1.near(o.doc.resolve(i),1)),t(o.scrollIntoView())}return!0},T=(e,t)=>{let n=e.selection,{$from:i,$to:o}=n;if(n instanceof r.C1||i.parent.inlineContent||o.parent.inlineContent)return!1;let s=E(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!i.parentOffset&&o.index(){let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if((0,l.Ax)(e.doc,i))return t&&t(e.tr.split(i).scrollIntoView()),!0}let i=n.blockRange(),r=i&&(0,l.k9)(i);return null!=r&&(t&&t(e.tr.lift(i,r).scrollIntoView()),!0)};let D=(e,t)=>{let{$from:n,to:i}=e.selection,o,s=n.sharedDepth(i);return 0!=s&&(o=n.before(s),t&&t(e.tr.setSelection(r.qv.create(e.doc,o))),!0)};function O(e,t,n,i){var o,s,d;let c,h,u,p=t.nodeBefore,f=t.nodeAfter,g,v,b=p.type.spec.isolating||f.type.spec.isolating;if(!b&&(o=e,s=t,d=n,c=s.nodeBefore,h=s.nodeAfter,u=s.index(),c&&h&&c.type.compatibleContent(h.type)&&(!c.content.size&&s.parent.canReplace(u-1,u)?(d&&d(o.tr.delete(s.pos-c.nodeSize,s.pos).scrollIntoView()),!0):!!(s.parent.canReplace(u,u+1)&&(h.isTextblock||(0,l.Mn)(o.doc,s.pos)))&&(d&&d(o.tr.join(s.pos).scrollIntoView()),!0))))return!0;let y=!b&&t.parent.canReplace(t.index(),t.index()+1);if(y&&(g=(v=p.contentMatchAt(p.childCount)).findWrapping(f.type))&&v.matchType(g[0]||f.type).validEnd){if(n){let i=t.pos+f.nodeSize,r=a.HY.empty;for(let e=g.length-1;e>=0;e--)r=a.HY.from(g[e].create(null,r));r=a.HY.from(p.copy(r));let o=e.tr.step(new l.FC(t.pos-1,i,t.pos,i,new a.p2(r,1,0),g.length,!0)),s=o.doc.resolve(i+2*g.length);s.nodeAfter&&s.nodeAfter.type==p.type&&(0,l.Mn)(o.doc,s.pos)&&o.join(s.pos),n(o.scrollIntoView())}return!0}let x=f.type.spec.isolating||i>0&&b?null:r.Y1.findFrom(t,1),w=x&&x.$from.blockRange(x.$to),_=w&&(0,l.k9)(w);if(null!=_&&_>=t.depth)return n&&n(e.tr.lift(w,_).scrollIntoView()),!0;if(y&&m(f,"start",!0)&&m(p,"end")){let i=p,r=[];for(;r.push(i),!i.isTextblock;){;i=i.lastChild}let o=f,s=1;for(;!o.isTextblock;o=o.firstChild)s++;if(i.canReplace(i.childCount,i.childCount,o.content)){if(n){let i=a.HY.empty;for(let e=r.length-1;e>=0;e--)i=a.HY.from(r[e].copy(i));n(e.tr.step(new l.FC(t.pos-r.length,t.pos+f.nodeSize,t.pos+s,t.pos+f.nodeSize-s,new a.p2(i,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function I(e){return function(t,n){let i=t.selection,o=e<0?i.$from:i.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return!!o.node(s).isTextblock&&(n&&n(t.tr.setSelection(r.Bs.create(t.doc,e<0?o.start(s):o.end(s)))),!0)}}let N=I(-1),P=I(1);function R(e,t=null){return function(n,i){let r=!1;for(let i=0;i{if(r)return!1;if(!(!i.isTextblock||i.hasMarkup(e,t))){if(i.type==e)r=!0;else{let t=n.doc.resolve(o),i=t.index();r=t.parent.canReplaceWith(i,i+1,e)}}})}if(!r)return!1;if(i){let r=n.tr;for(let i=0;i{let{$from:n,$to:i}=e.selection;if(e.selection instanceof r.qv&&e.selection.node.isBlock)return!!(n.parentOffset&&(0,l.Ax)(e.doc,n.pos))&&(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],s,a,d=!1,c=!1;for(let e=n.depth;;e--){if(n.node(e).isBlock){d=n.end(e)==n.pos+(n.depth-e),c=n.start(e)==n.pos-(n.depth-e),a=E(n.node(e-1).contentMatchAt(n.indexAfter(e-1)));let t=void 0;o.unshift(t||(d&&a?{type:a}:null)),s=e;break}if(1==e)return!1;o.unshift(null)}let h=e.tr;(e.selection instanceof r.Bs||e.selection instanceof r.C1)&&h.deleteSelection();let u=h.mapping.map(n.pos),p=(0,l.Ax)(h.doc,u,o.length,o);if(!p&&(o[0]=a?{type:a}:null,p=(0,l.Ax)(h.doc,u,o.length,o)),!p)return!1;if(h.split(u,o.length,o),!d&&c&&n.node(s).type!=a){let e=h.mapping.map(n.before(s)),t=h.doc.resolve(e);a&&n.node(s-1).canReplaceWith(t.index(),t.index()+1,a)&&h.setNodeMarkup(h.mapping.map(n.before(s)),a)}return t&&t(h.scrollIntoView()),!0}),"Mod-Enter":k,Backspace:j,"Mod-Backspace":j,"Shift-Backspace":j,Delete:F,"Mod-Delete":F,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new r.C1(e.doc))),!0)},z={"Ctrl-h":B.Backspace,"Alt-Backspace":B["Mod-Backspace"],"Ctrl-d":B.Delete,"Ctrl-Alt-Backspace":B["Mod-Delete"],"Alt-Delete":B["Mod-Delete"],"Alt-d":B["Mod-Delete"],"Ctrl-a":N,"Ctrl-e":P};for(let e in B)z[e]=B[e];"undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"==typeof os||!os.platform||os.platform();function H(e){let{state:t,transaction:n}=e,{selection:i}=n,{doc:r}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return i},get doc(){return r},get tr(){return i=n.selection,r=n.doc,o=n.storedMarks,n}}}class V{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:n}=this,{view:i}=t,{tr:r}=n,o=this.buildProps(r);return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,(...e)=>{let n=t(...e)(o);return!r.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(r),n}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:n,editor:i,state:r}=this,{view:o}=i,s=[],a=!!e,l=e||r.tr,d={...Object.fromEntries(Object.entries(n).map(([e,n])=>[e,(...e)=>{let i=this.buildProps(l,t),r=n(...e)(i);return s.push(r),d}])),run:()=>(!a&&t&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(l),s.every(e=>!0===e))};return d}createCan(e){let{rawCommands:t,state:n}=this,i=e||n.tr,r=this.buildProps(i,!1);return{...Object.fromEntries(Object.entries(t).map(([e,t])=>[e,(...e)=>t(...e)({...r,dispatch:void 0})])),chain:()=>this.createChain(i,!1)}}buildProps(e,t=!0){let{rawCommands:n,editor:i,state:r}=this,{view:o}=i,s={tr:e,editor:i,view:o,state:H({state:r,transaction:e}),dispatch:t?()=>void 0:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(n).map(([e,t])=>[e,(...e)=>t(...e)(s)]))}};return s}}class U{constructor(){this.callbacks={}}on(e,t){return!this.callbacks[e]&&(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let n=this.callbacks[e];return n&&n.forEach(e=>e.apply(this,t)),this}off(e,t){let n=this.callbacks[e];return n&&(t?this.callbacks[e]=n.filter(e=>e!==t):delete this.callbacks[e]),this}once(e,t){let n=(...i)=>{this.off(e,n),t.apply(this,i)};return this.on(e,n)}removeAllListeners(){this.callbacks={}}}function $(e,t,n){return void 0===e.config[t]&&e.parent?$(e.parent,t,n):"function"==typeof e.config[t]?e.config[t].bind({...n,parent:e.parent?$(e.parent,t,n):null}):e.config[t]}function W(e){let t=e.filter(e=>"extension"===e.type),n=e.filter(e=>"node"===e.type);return{baseExtensions:t,nodeExtensions:n,markExtensions:e.filter(e=>"mark"===e.type)}}function q(e){let t=[],{nodeExtensions:n,markExtensions:i}=W(e),r=[...n,...i],o={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return e.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage,extensions:r},i=$(e,"addGlobalAttributes",n);if(!!i)i().forEach(e=>{e.types.forEach(n=>{Object.entries(e.attributes).forEach(([e,i])=>{t.push({type:n,name:e,attribute:{...o,...i}})})})})}),r.forEach(e=>{let n={name:e.name,options:e.options,storage:e.storage},i=$(e,"addAttributes",n);if(!!i)Object.entries(i()).forEach(([n,i])=>{let r={...o,...i};"function"==typeof(null==r?void 0:r.default)&&(r.default=r.default()),(null==r?void 0:r.isRequired)&&(null==r?void 0:r.default)===void 0&&delete r.default,t.push({type:e.name,name:n,attribute:r})})}),t}function G(e,t){if("string"==typeof e){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function K(...e){return e.filter(e=>!!e).reduce((e,t)=>{let n={...e};return Object.entries(t).forEach(([e,t])=>{if(!n[e]){n[e]=t;return}if("class"===e){let i=t?String(t).split(" "):[],r=n[e]?n[e].split(" "):[],o=i.filter(e=>!r.includes(e));n[e]=[...r,...o].join(" ")}else if("style"===e){let i=t?t.split(";").map(e=>e.trim()).filter(Boolean):[],r=n[e]?n[e].split(";").map(e=>e.trim()).filter(Boolean):[],o=new Map;r.forEach(e=>{let[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),i.forEach(e=>{let[t,n]=e.split(":").map(e=>e.trim());o.set(t,n)}),n[e]=Array.from(o.entries()).map(([e,t])=>`${e}: ${t}`).join("; ")}else n[e]=t}),n},{})}function Z(e,t){return t.filter(t=>t.type===e.type.name).filter(e=>e.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(e.attrs)||{}:{[t.name]:e.attrs[t.name]}).reduce((e,t)=>K(e,t),{})}function Y(e){return"function"==typeof e}function X(e,t,...n){if(Y(e))return t?e.bind(t)(...n):e(...n);return e}function J(e,t){return"style"in e?e:{...e,getAttrs:n=>{let i=e.getAttrs?e.getAttrs(n):e.attrs;if(!1===i)return!1;let r=t.reduce((e,t)=>{var i;let r=t.attribute.parseHTML?t.attribute.parseHTML(n):"string"!=typeof(i=n.getAttribute(t.name))?i:i.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(i):"true"===i||"false"!==i&&i;return null==r?e:{...e,[t.name]:r}},{});return{...i,...r}}}}function Q(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>!("attrs"===e&&function(e={}){return 0===Object.keys(e).length&&e.constructor===Object}(t))&&null!=t))}function ee(e,t){return t.nodes[e]||t.marks[e]||null}function et(e,t){return Array.isArray(t)?t.some(t=>("string"==typeof t?t:t.name)===e.name):t}function en(e,t){let n=a.PW.fromSchema(t).serializeFragment(e),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}let ei=(e,t=500)=>{let n="",i=e.parentOffset;return e.parent.nodesBetween(Math.max(0,i-t),i,(e,t,r,o)=>{var s,a;let l=(null===(a=(s=e.type.spec).toText)||void 0===a?void 0:a.call(s,{node:e,pos:t,parent:r,index:o}))||e.textContent||"%leaf%";n+=e.isAtom&&!e.isText?l:l.slice(0,Math.max(0,i-t))}),n};function er(e){return"[object RegExp]"===Object.prototype.toString.call(e)}class eo{constructor(e){this.find=e.find,this.handler=e.handler}}let es=(e,t)=>{if(er(t))return t.exec(e);let n=t(e);if(!n)return null;let i=[n.text];return i.index=n.index,i.input=e,i.data=n.data,n.replaceWith&&(!n.text.includes(n.replaceWith)&&console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),i.push(n.replaceWith)),i};function ea(e){var t;let{editor:n,from:i,to:r,text:o,rules:s,plugin:a}=e,{view:l}=n;if(l.composing)return!1;let d=l.state.doc.resolve(i);if(d.parent.type.spec.code||(null===(t=d.nodeBefore||d.nodeAfter)||void 0===t?void 0:t.marks.find(e=>e.type.spec.code)))return!1;let c=!1,h=ei(d)+o;return s.forEach(e=>{if(c)return;let t=es(h,e.find);if(!t)return;let s=l.state.tr,d=H({state:l.state,transaction:s}),u={from:i-(t[0].length-o.length),to:r},{commands:p,chain:f,can:m}=new V({editor:n,state:d});if(null!==e.handler({state:d,range:u,match:t,commands:p,chain:f,can:m})&&!!s.steps.length)s.setMeta(a,{transform:s,from:i,to:r,text:o}),l.dispatch(s),c=!0}),c}function el(e){var t;return"Object"===(t=e,Object.prototype.toString.call(t).slice(8,-1))&&e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function ed(e,t){let n={...e};return el(e)&&el(t)&&Object.keys(t).forEach(i=>{el(t[i])&&el(e[i])?n[i]=ed(e[i],t[i]):n[i]=t[i]}),n}class ec{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=X($(this,"addOptions",{name:this.name}))),this.storage=X($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ec(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ed(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new ec(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=X($(t,"addOptions",{name:t.name})),t.storage=X($(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:n}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){let r=i.marks();if(!r.find(e=>(null==e?void 0:e.type.name)===t.name))return!1;let o=r.find(e=>(null==e?void 0:e.type.name)===t.name);return o&&n.removeStoredMark(o),n.insertText(" ",i.pos),e.view.dispatch(n),!0}return!1}}class eh{constructor(e){this.find=e.find,this.handler=e.handler}}let eu=(e,t,n)=>{if(er(t))return[...e.matchAll(t)];let i=t(e,n);return i?i.map(t=>{let n=[t.text];return n.index=t.index,n.input=e,n.data=t.data,t.replaceWith&&(!t.text.includes(t.replaceWith)&&console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(t.replaceWith)),n}):[]},ep=null,ef=e=>{var t;let n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(t=n.clipboardData)||void 0===t||t.setData("text/html",e),n};class em{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=em.resolve(e),this.schema=function(e,t){var n;let i=q(e),{nodeExtensions:r,markExtensions:o}=W(e),s=null===(n=r.find(e=>$(e,"topNode")))||void 0===n?void 0:n.name,l=Object.fromEntries(r.map(n=>{let r=i.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:t},s=Q({...e.reduce((e,t)=>{let i=$(t,"extendNodeSchema",o);return{...e,...i?i(n):{}}},{}),content:X($(n,"content",o)),marks:X($(n,"marks",o)),group:X($(n,"group",o)),inline:X($(n,"inline",o)),atom:X($(n,"atom",o)),selectable:X($(n,"selectable",o)),draggable:X($(n,"draggable",o)),code:X($(n,"code",o)),whitespace:X($(n,"whitespace",o)),linebreakReplacement:X($(n,"linebreakReplacement",o)),defining:X($(n,"defining",o)),isolating:X($(n,"isolating",o)),attrs:Object.fromEntries(r.map(e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]}))}),a=X($(n,"parseHTML",o));a&&(s.parseDOM=a.map(e=>J(e,r)));let l=$(n,"renderHTML",o);l&&(s.toDOM=e=>l({node:e,HTMLAttributes:Z(e,r)}));let d=$(n,"renderText",o);return d&&(s.toText=d),[n.name,s]})),d=Object.fromEntries(o.map(n=>{let r=i.filter(e=>e.type===n.name),o={name:n.name,options:n.options,storage:n.storage,editor:t},s=Q({...e.reduce((e,t)=>{let i=$(t,"extendMarkSchema",o);return{...e,...i?i(n):{}}},{}),inclusive:X($(n,"inclusive",o)),excludes:X($(n,"excludes",o)),group:X($(n,"group",o)),spanning:X($(n,"spanning",o)),code:X($(n,"code",o)),attrs:Object.fromEntries(r.map(e=>{var t;return[e.name,{default:null===(t=null==e?void 0:e.attribute)||void 0===t?void 0:t.default}]}))}),a=X($(n,"parseHTML",o));a&&(s.parseDOM=a.map(e=>J(e,r)));let l=$(n,"renderHTML",o);return l&&(s.toDOM=e=>l({mark:e,HTMLAttributes:Z(e,r)})),[n.name,s]}));return new a.V_({topNode:s,nodes:l,marks:d})}(this.extensions,t),this.setupExtensions()}static resolve(e){var t;let n=em.sort(em.flatten(e));let i=Array.from(new Set((t=n.map(e=>e.name)).filter((e,n)=>t.indexOf(e)!==n)));return i.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${i.map(e=>`'${e}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(e=>{let t={name:e.name,options:e.options,storage:e.storage},n=$(e,"addExtensions",t);return n?[e,...this.flatten(n())]:e}).flat(10)}static sort(e){return e.sort((e,t)=>{let n=$(e,"priority")||100,i=$(t,"priority")||100;return n>i?-1:n{let n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ee(t.name,this.schema)},i=$(t,"addCommands",n);return i?{...e,...i()}:e},{})}get plugins(){let{editor:e}=this,t=em.sort([...this.extensions].reverse()),n=[],i=[],o=t.map(t=>{let r={name:t.name,options:t.options,storage:t.storage,editor:e,type:ee(t.name,this.schema)},o=[],a=$(t,"addKeyboardShortcuts",r),l={};if("mark"===t.type&&$(t,"exitable",r)&&(l.ArrowRight=()=>ec.handleExit({editor:e,mark:t})),a){let t=Object.fromEntries(Object.entries(a()).map(([t,n])=>[t,()=>n({editor:e})]));l={...l,...t}}let d=(0,s.h)(l);o.push(d);let c=$(t,"addInputRules",r);et(t,e.options.enableInputRules)&&c&&n.push(...c());let h=$(t,"addPasteRules",r);et(t,e.options.enablePasteRules)&&h&&i.push(...h());let u=$(t,"addProseMirrorPlugins",r);if(u){let e=u();o.push(...e)}return o}).flat();return[function(e){let{editor:t,rules:n}=e,i=new r.Sy({state:{init:()=>null,apply(e,r,o){let s=e.getMeta(i);if(s)return s;let l=e.getMeta("applyInputRules");return l&&setTimeout(()=>{let{text:e}=l;"string"==typeof e||(e=en(a.HY.from(e),o.schema));let{from:r}=l,s=r+e.length;ea({editor:t,from:r,to:s,text:e,rules:n,plugin:i})}),e.selectionSet||e.docChanged?null:r}},props:{handleTextInput:(e,r,o,s)=>ea({editor:t,from:r,to:o,text:s,rules:n,plugin:i}),handleDOMEvents:{compositionend:e=>(setTimeout(()=>{let{$cursor:r}=e.state.selection;r&&ea({editor:t,from:r.pos,to:r.pos,text:"",rules:n,plugin:i})}),!1)},handleKeyDown(e,r){if("Enter"!==r.key)return!1;let{$cursor:o}=e.state.selection;return!!o&&ea({editor:t,from:o.pos,to:o.pos,text:"\n",rules:n,plugin:i})}},isInputRules:!0});return i}({editor:e,rules:n}),...function(e){let t;let{editor:n,rules:i}=e,o=null,s=!1,l=!1,d="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null;try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{t=null}let c=({state:e,from:i,to:r,rule:o,pasteEvt:s})=>{let a=e.tr;if(!!function(e){let{editor:t,state:n,from:i,to:r,rule:o,pasteEvent:s,dropEvent:a}=e,{commands:l,chain:d,can:c}=new V({editor:t,state:n}),h=[];return n.doc.nodesBetween(i,r,(e,t)=>{if(!e.isTextblock||e.type.spec.code)return;let u=Math.max(i,t),p=Math.min(r,t+e.content.size);eu(e.textBetween(u-t,p-t,void 0,""),o.find,s).forEach(e=>{if(void 0===e.index)return;let t=u+e.index+1,i=t+e[0].length,r={from:n.tr.mapping.map(t),to:n.tr.mapping.map(i)},p=o.handler({state:n,range:r,match:e,commands:l,chain:d,can:c,pasteEvent:s,dropEvent:a});h.push(p)})}),h.every(e=>null!==e)}({editor:n,state:H({state:e,transaction:a}),from:Math.max(i-1,0),to:r.b-1,rule:o,pasteEvent:s,dropEvent:t})&&!!a.steps.length){try{t="undefined"!=typeof DragEvent?new DragEvent("drop"):null}catch{t=null}return d="undefined"!=typeof ClipboardEvent?new ClipboardEvent("paste"):null,a}};return i.map(e=>new r.Sy({view(e){let t=t=>{var i;(o=(null===(i=e.dom.parentElement)||void 0===i?void 0:i.contains(t.target))?e.dom.parentElement:null)&&(ep=n)},i=()=>{ep&&(ep=null)};return window.addEventListener("dragstart",t),window.addEventListener("dragend",i),{destroy(){window.removeEventListener("dragstart",t),window.removeEventListener("dragend",i)}}},props:{handleDOMEvents:{drop:(e,n)=>{if(l=o===e.dom.parentElement,t=n,!l){let e=ep;e&&setTimeout(()=>{let t=e.state.selection;t&&e.commands.deleteRange({from:t.from,to:t.to})},10)}return!1},paste:(e,t)=>{var n;let i=null===(n=t.clipboardData)||void 0===n?void 0:n.getData("text/html");return d=t,s=!!(null==i?void 0:i.includes("data-pm-slice")),!1}}},appendTransaction:(t,n,i)=>{let r=t[0],o="paste"===r.getMeta("uiEvent")&&!s,h="drop"===r.getMeta("uiEvent")&&!l,u=r.getMeta("applyPasteRules"),p=!!u;if(!o&&!h&&!p)return;if(p){let{text:t}=u;"string"==typeof t||(t=en(a.HY.from(t),i.schema));let{from:n}=u,r=n+t.length;return c({rule:e,state:i,from:n,to:{b:r},pasteEvt:ef(t)})}let f=n.doc.content.findDiffStart(i.doc.content),m=n.doc.content.findDiffEnd(i.doc.content);if("number"==typeof f&&!!m&&f!==m.b)return c({rule:e,state:i,from:f,to:m,pasteEvt:d})}}))}({editor:e,rules:i}),...o]}get attributes(){return q(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=W(this.extensions);return Object.fromEntries(t.filter(e=>!!$(e,"addNodeView")).map(t=>{let n=this.attributes.filter(e=>e.type===t.name),i={name:t.name,options:t.options,storage:t.storage,editor:e,type:G(t.name,this.schema)},r=$(t,"addNodeView",i);return r?[t.name,(i,o,s,a,l)=>{let d=Z(i,n);return r()({node:i,view:o,getPos:s,decorations:a,innerDecorations:l,editor:e,extension:t,HTMLAttributes:d})}]:[]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let n={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ee(e.name,this.schema)};"mark"===e.type&&(null===(t=X($(e,"keepOnSplit",n)))||void 0===t||t)&&this.splittableMarks.push(e.name);let i=$(e,"onBeforeCreate",n),r=$(e,"onCreate",n),o=$(e,"onUpdate",n),s=$(e,"onSelectionUpdate",n),a=$(e,"onTransaction",n),l=$(e,"onFocus",n),d=$(e,"onBlur",n),c=$(e,"onDestroy",n);i&&this.editor.on("beforeCreate",i),r&&this.editor.on("create",r),o&&this.editor.on("update",o),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),d&&this.editor.on("blur",d),c&&this.editor.on("destroy",c)})}}class eg{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=X($(this,"addOptions",{name:this.name}))),this.storage=X($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new eg(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ed(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new eg({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=X($(t,"addOptions",{name:t.name})),t.storage=X($(t,"addStorage",{name:t.name,options:t.options})),t}}function ev(e,t,n){let{from:i,to:r}=t,{blockSeparator:o="\n\n",textSerializers:s={}}=n||{},a="";return e.nodesBetween(i,r,(e,n,l,d)=>{var c;e.isBlock&&n>i&&(a+=o);let h=null==s?void 0:s[e.type.name];if(h)return l&&(a+=h({node:e,pos:n,parent:l,index:d,range:t})),!1;e.isText&&(a+=null===(c=null==e?void 0:e.text)||void 0===c?void 0:c.slice(Math.max(i,n)-n,r-n))}),a}function eb(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}let ey=eg.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:e}=this,{state:t,schema:n}=e,{doc:i,selection:r}=t,{ranges:o}=r,s=Math.min(...o.map(e=>e.$from.pos)),a=Math.max(...o.map(e=>e.$to.pos)),l=eb(n);return ev(i,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}});function ex(e,t,n={strict:!0}){let i=Object.keys(t);return!i.length||i.every(i=>n.strict?t[i]===e[i]:er(t[i])?t[i].test(e[i]):t[i]===e[i])}function ew(e,t,n={}){return e.find(e=>e.type===t&&ex(Object.fromEntries(Object.keys(n).map(t=>[t,e.attrs[t]])),n))}function e_(e,t,n={}){return!!ew(e,t,n)}function eS(e,t,n){var i;if(!e||!t)return;let r=e.parent.childAfter(e.parentOffset);if((!r.node||!r.node.marks.some(e=>e.type===t))&&(r=e.parent.childBefore(e.parentOffset)),!r.node||!r.node.marks.some(e=>e.type===t))return;if(n=n||(null===(i=r.node.marks[0])||void 0===i?void 0:i.attrs),!ew([...r.node.marks],t,n))return;let o=r.index,s=e.start()+r.offset,a=o+1,l=s+r.node.nodeSize;for(;o>0&&e_([...e.parent.child(o-1).marks],t,n);)o-=1,s-=e.parent.child(o).nodeSize;for(;a{let t=e.childNodes;for(let n=t.length-1;n>=0;n-=1){let i=t[n];3===i.nodeType&&i.nodeValue&&/^(\n\s\s|\n)$/.test(i.nodeValue)?e.removeChild(i):1===i.nodeType&&eM(i)}return e};function eD(e){let t=`${e}`;return eM(new window.DOMParser().parseFromString(t,"text/html").body)}function eO(e,t,n){if(e instanceof a.NB||e instanceof a.HY)return e;n={slice:!0,parseOptions:{},...n};let i="object"==typeof e&&null!==e,r="string"==typeof e;if(i)try{if(Array.isArray(e)&&e.length>0)return a.HY.fromArray(e.map(e=>t.nodeFromJSON(e)));let i=t.nodeFromJSON(e);return n.errorOnInvalidContent&&i.check(),i}catch(i){if(n.errorOnInvalidContent)throw Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",i),eO("",t,n)}if(r){if(n.errorOnInvalidContent){let i=!1,r="",o=new a.V_({topNode:t.spec.topNode,marks:t.spec.marks,nodes:t.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:e=>(i=!0,r="string"==typeof e?e:e.outerHTML,null)}]}})});if(n.slice?a.aw.fromSchema(o).parseSlice(eD(e),n.parseOptions):a.aw.fromSchema(o).parse(eD(e),n.parseOptions),n.errorOnInvalidContent&&i)throw Error("[tiptap error]: Invalid HTML content",{cause:Error(`Invalid element found: ${r}`)})}let i=a.aw.fromSchema(t);return n.slice?i.parseSlice(eD(e),n.parseOptions).content:i.parse(eD(e),n.parseOptions)}return eO("",t,n)}let eI=e=>!("type"in e);function eN(){return"undefined"!=typeof navigator&&/Mac/.test(navigator.platform)}function eP(e,t,n={}){let{from:i,to:r,empty:o}=e.selection,s=t?G(t,e.schema):null,a=[];e.doc.nodesBetween(i,r,(e,t)=>{if(e.isText)return;let n=Math.max(i,t),o=Math.min(r,t+e.nodeSize);a.push({node:e,from:n,to:o})});let l=r-i,d=a.filter(e=>!s||s.name===e.node.type.name).filter(e=>ex(e.node.attrs,n,{strict:!1}));return o?!!d.length:d.reduce((e,t)=>e+t.to-t.from,0)>=l}function eR(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function eL(e,t){let n="string"==typeof t?[t]:t;return Object.keys(e).reduce((t,i)=>(!n.includes(i)&&(t[i]=e[i]),t),{})}function ej(e,t,n={},i={}){return eO(e,t,{slice:!1,parseOptions:n,errorOnInvalidContent:i.errorOnInvalidContent})}function eF(e,t){let n=eC(t,e.schema),{from:i,to:r,empty:o}=e.selection,s=[];o?(e.storedMarks&&s.push(...e.storedMarks),s.push(...e.selection.$head.marks())):e.doc.nodesBetween(i,r,e=>{s.push(...e.marks)});let a=s.find(e=>e.type.name===n.name);return a?{...a.attrs}:{}}function eB(e,t){for(let n=e.depth;n>0;n-=1){let i=e.node(n);if(t(i))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:i}}}function ez(e){return t=>eB(t.$from,e)}function eH(e,t,n){let i=[];return e===t?n.resolve(e).marks().forEach(t=>{let r=eS(n.resolve(e),t.type);if(!!r)i.push({mark:t,...r})}):n.nodesBetween(e,t,(e,t)=>{if(!!e&&(null==e?void 0:e.nodeSize)!==void 0)i.push(...e.marks.map(n=>({from:t,to:t+e.nodeSize,mark:n})))}),i}function eV(e,t,n){return Object.fromEntries(Object.entries(n).filter(([n])=>{let i=e.find(e=>e.type===t&&e.name===n);return!!i&&i.attribute.keepOnSplit}))}function eU(e,t,n={}){let{empty:i,ranges:r}=e.selection,o=t?eC(t,e.schema):null;if(i)return!!(e.storedMarks||e.selection.$from.marks()).filter(e=>!o||o.name===e.type.name).find(e=>ex(e.attrs,n,{strict:!1}));let s=0,a=[];if(r.forEach(({$from:t,$to:n})=>{let i=t.pos,r=n.pos;e.doc.nodesBetween(i,r,(e,t)=>{if(!e.isText&&!e.marks.length)return;let n=Math.max(i,t),o=Math.min(r,t+e.nodeSize);s+=o-n,a.push(...e.marks.map(e=>({mark:e,from:n,to:o})))})}),0===s)return!1;let l=a.filter(e=>!o||o.name===e.mark.type.name).filter(e=>ex(e.mark.attrs,n,{strict:!1})).reduce((e,t)=>e+t.to-t.from,0),d=a.filter(e=>!o||e.mark.type!==o&&e.mark.type.excludes(o)).reduce((e,t)=>e+t.to-t.from,0);return(l>0?l+d:l)>=s}function e$(e,t){let{nodeExtensions:n}=W(t),i=n.find(t=>t.name===e);if(!i)return!1;let r={name:i.name,options:i.options,storage:i.storage},o=X($(i,"group",r));return"string"==typeof o&&o.split(" ").includes("list")}function eW(e,{checkChildren:t=!0,ignoreWhitespace:n=!1}={}){var i;if(n){if("hardBreak"===e.type.name)return!0;if(e.isText)return/^\s*$/m.test(null!==(i=e.text)&&void 0!==i?i:"")}if(e.isText)return!e.text;if(e.isAtom||e.isLeaf)return!1;if(0===e.content.childCount)return!0;if(t){let i=!0;return e.content.forEach(e=>{if(!1!==i)!eW(e,{ignoreWhitespace:n,checkChildren:t})&&(i=!1)}),i}return!1}function eq(e){return e instanceof r.qv}function eG(e,t){let n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){let i=n.filter(e=>null==t?void 0:t.includes(e.type.name));e.tr.ensureMarks(i)}}let eK=(e,t)=>{let n=ez(e=>e.type===t)(e.selection);if(!n)return!0;let i=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===i)return!0;let r=e.doc.nodeAt(i);return!(n.node.type===(null==r?void 0:r.type)&&(0,l.Mn)(e.doc,n.pos))||(e.join(n.pos),!0)},eZ=(e,t)=>{let n=ez(e=>e.type===t)(e.selection);if(!n)return!0;let i=e.doc.resolve(n.start).after(n.depth);if(void 0===i)return!0;let r=e.doc.nodeAt(i);return!(n.node.type===(null==r?void 0:r.type)&&(0,l.Mn)(e.doc,i))||(e.join(i),!0)};var eY=Object.freeze({__proto__:null,blur:()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;!e.isDestroyed&&(t.dom.blur(),null===(n=null==window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())}),!0),clearContent:(e=!1)=>({commands:t})=>t.setContent("",e),clearNodes:()=>({state:e,tr:t,dispatch:n})=>{let{selection:i}=t,{ranges:r}=i;return!n||(r.forEach(({$from:n,$to:i})=>{e.doc.nodesBetween(n.pos,i.pos,(e,n)=>{if(e.type.isText)return;let{doc:i,mapping:r}=t,o=i.resolve(r.map(n)),s=i.resolve(r.map(n+e.nodeSize)),a=o.blockRange(s);if(!a)return;let d=(0,l.k9)(a);if(e.type.isTextblock){let{defaultType:e}=o.parent.contentMatchAt(o.index());t.setNodeMarkup(a.start,e)}(d||0===d)&&t.lift(a,d)})}),!0)},command:e=>t=>e(t),createParagraphNear:()=>({state:e,dispatch:t})=>T(e,t),cut:(e,t)=>({editor:n,tr:i})=>{let{state:o}=n,s=o.doc.slice(e.from,e.to);i.deleteRange(e.from,e.to);let a=i.mapping.map(t);return i.insert(a,s.content),i.setSelection(new r.Bs(i.doc.resolve(a-1))),!0},deleteCurrentNode:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,i=n.$anchor.node();if(i.content.size>0)return!1;let r=e.selection.$anchor;for(let n=r.depth;n>0;n-=1)if(r.node(n).type===i.type){if(t){let t=r.before(n),i=r.after(n);e.delete(t,i).scrollIntoView()}return!0}return!1},deleteNode:e=>({tr:t,state:n,dispatch:i})=>{let r=G(e,n.schema),o=t.selection.$anchor;for(let e=o.depth;e>0;e-=1)if(o.node(e).type===r){if(i){let n=o.before(e),i=o.after(e);t.delete(n,i).scrollIntoView()}return!0}return!1},deleteRange:e=>({tr:t,dispatch:n})=>{let{from:i,to:r}=e;return n&&t.delete(i,r),!0},deleteSelection:()=>({state:e,dispatch:t})=>d(e,t),enter:()=>({commands:e})=>e.keyboardShortcut("Enter"),exitCode:()=>({state:e,dispatch:t})=>k(e,t),extendMarkRange:(e,t={})=>({tr:n,state:i,dispatch:o})=>{let s=eC(e,i.schema),{doc:a,selection:l}=n,{$from:d,from:c,to:h}=l;if(o){let e=eS(d,s,t);if(e&&e.from<=c&&e.to>=h){let t=r.Bs.create(a,e.from,e.to);n.setSelection(t)}}return!0},first:e=>t=>{let n="function"==typeof e?e(t):e;for(let e=0;e({editor:n,view:i,tr:r,dispatch:o})=>{t={scrollIntoView:!0,...t};let s=()=>{(eT()||"Android"===navigator.platform||/android/i.test(navigator.userAgent))&&i.dom.focus(),requestAnimationFrame(()=>{!n.isDestroyed&&(i.focus(),(null==t?void 0:t.scrollIntoView)&&n.commands.scrollIntoView())})};if(i.hasFocus()&&null===e||!1===e)return!0;if(o&&null===e&&!eA(n.state.selection))return s(),!0;let a=ek(r.doc,e)||n.state.selection,l=n.state.selection.eq(a);return o&&(!l&&r.setSelection(a),l&&r.storedMarks&&r.setStoredMarks(r.storedMarks),s()),!0},forEach:(e,t)=>n=>e.every((e,i)=>t(e,{...n,index:i})),insertContent:(e,t)=>({tr:n,commands:i})=>i.insertContentAt({from:n.selection.from,to:n.selection.to},e,t),insertContentAt:(e,t,n)=>({tr:i,dispatch:o,editor:s})=>{var d;if(o){let o,c;n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let h=e=>{s.emit("contentError",{editor:s,error:e,disableCollaboration:()=>{s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},u={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{eO(t,s.schema,{parseOptions:u,errorOnInvalidContent:!0})}catch(e){h(e)}try{o=eO(t,s.schema,{parseOptions:u,errorOnInvalidContent:null!==(d=n.errorOnInvalidContent)&&void 0!==d?d:s.options.enableContentCheck})}catch(e){return h(e),!1}let{from:p,to:f}="number"==typeof e?{from:e,to:e}:{from:e.from,to:e.to},m=!0,g=!0;if((eI(o)?o:[o]).forEach(e=>{e.check(),m=!!m&&e.isText&&0===e.marks.length,g=!!g&&e.isBlock}),p===f&&g){let{parent:e}=i.doc.resolve(p);e.isTextblock&&!e.type.spec.code&&!e.childCount&&(p-=1,f+=1)}if(m){if(Array.isArray(t))c=t.map(e=>e.text||"").join("");else if(t instanceof a.HY){let e="";t.forEach(t=>{t.text&&(e+=t.text)}),c=e}else c="object"==typeof t&&t&&t.text?t.text:t;i.insertText(c,p,f)}else c=o,i.replaceWith(p,f,c);n.updateSelection&&!function(e,t,n){let i=e.steps.length-1;if(i{0===a&&(a=i)}),e.setSelection(r.Y1.near(e.doc.resolve(a),-1))}(i,i.steps.length-1,-1),n.applyInputRules&&i.setMeta("applyInputRules",{from:p,text:c}),n.applyPasteRules&&i.setMeta("applyPasteRules",{from:p,text:c})}return!0},joinBackward:()=>({state:e,dispatch:t})=>h(e,t),joinDown:()=>({state:e,dispatch:t})=>S(e,t),joinForward:()=>({state:e,dispatch:t})=>y(e,t),joinItemBackward:()=>({state:e,dispatch:t,tr:n})=>{try{let i=(0,l.GJ)(e.doc,e.selection.$from.pos,-1);if(null==i)return!1;return n.join(i,2),t&&t(n),!0}catch{return!1}},joinItemForward:()=>({state:e,dispatch:t,tr:n})=>{try{let i=(0,l.GJ)(e.doc,e.selection.$from.pos,1);if(null==i)return!1;return n.join(i,2),t&&t(n),!0}catch{return!1}},joinTextblockBackward:()=>({state:e,dispatch:t})=>u(e,t),joinTextblockForward:()=>({state:e,dispatch:t})=>p(e,t),joinUp:()=>({state:e,dispatch:t})=>_(e,t),keyboardShortcut:e=>({editor:t,view:n,tr:i,dispatch:r})=>{let o=(function(e){let t,n,i,r;let o=e.split(/-(?!$)/),s=o[o.length-1];"Space"===s&&(s=" ");for(let e=0;e!["Alt","Ctrl","Meta","Shift"].includes(e)),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),l=t.captureTransaction(()=>{n.someProp("handleKeyDown",e=>e(n,a))});return null==l||l.steps.forEach(e=>{let t=e.map(i.mapping);t&&r&&i.maybeStep(t)}),!0},lift:(e,t={})=>({state:n,dispatch:i})=>{let r=G(e,n.schema);return!!eP(n,r,t)&&C(n,i)},liftEmptyBlock:()=>({state:e,dispatch:t})=>M(e,t),liftListItem:e=>({state:t,dispatch:n})=>{var i;return(i=G(e,t.schema),function(e,t){let{$from:n,$to:r}=e.selection,o=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==i);return!!o&&(!t||(n.node(o.depth-1).type==i?function(e,t,n,i){let r=e.tr,o=i.end,s=i.$to.end(i.depth);oo;t--)e-=r.child(t).nodeSize,i.delete(e-1,e+1);let o=i.doc.resolve(n.start),s=o.nodeAfter;if(i.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let d=0==n.startIndex,c=n.endIndex==r.childCount,h=o.node(-1),u=o.index(-1);if(!h.canReplace(u+(d?0:1),u+1,s.content.append(c?a.HY.empty:a.HY.from(r))))return!1;let p=o.pos,f=p+s.nodeSize;return i.step(new l.FC(p-(d?1:0),f+(c?1:0),p+1,f-1,new a.p2((d?a.HY.empty:a.HY.from(r.copy(a.HY.empty))).append(c?a.HY.empty:a.HY.from(r.copy(a.HY.empty))),d?0:1,c?0:1),d?0:1)),t(i.scrollIntoView()),!0}(e,t,o)))})(t,n)},newlineInCode:()=>({state:e,dispatch:t})=>A(e,t),resetAttributes:(e,t)=>({tr:n,state:i,dispatch:r})=>{let o=null,s=null,a=eR("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(o=G(e,i.schema)),"mark"===a&&(s=eC(e,i.schema)),r&&n.selection.ranges.forEach(e=>{i.doc.nodesBetween(e.$from.pos,e.$to.pos,(e,i)=>{o&&o===e.type&&n.setNodeMarkup(i,void 0,eL(e.attrs,t)),s&&e.marks.length&&e.marks.forEach(r=>{s===r.type&&n.addMark(i,i+e.nodeSize,s.create(eL(r.attrs,t)))})})}),!0)},scrollIntoView:()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),selectAll:()=>({tr:e,dispatch:t})=>{if(t){let t=new r.C1(e.doc);e.setSelection(t)}return!0},selectNodeBackward:()=>({state:e,dispatch:t})=>g(e,t),selectNodeForward:()=>({state:e,dispatch:t})=>x(e,t),selectParentNode:()=>({state:e,dispatch:t})=>D(e,t),selectTextblockEnd:()=>({state:e,dispatch:t})=>P(e,t),selectTextblockStart:()=>({state:e,dispatch:t})=>N(e,t),setContent:(e,t=!1,n={},i={})=>({editor:r,tr:o,dispatch:s,commands:a})=>{var l,d;let{doc:c}=o;if("full"!==n.preserveWhitespace){let a=ej(e,r.schema,n,{errorOnInvalidContent:null!==(l=i.errorOnInvalidContent)&&void 0!==l?l:r.options.enableContentCheck});return s&&o.replaceWith(0,c.content.size,a).setMeta("preventUpdate",!t),!0}return s&&o.setMeta("preventUpdate",!t),a.insertContentAt({from:0,to:c.content.size},e,{parseOptions:n,errorOnInvalidContent:null!==(d=i.errorOnInvalidContent)&&void 0!==d?d:r.options.enableContentCheck})},setMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{let{selection:o}=n,{empty:s,ranges:a}=o,l=eC(e,i.schema);if(r){if(s){let e=eF(i,l);n.addStoredMark(l.create({...e,...t}))}else a.forEach(e=>{let r=e.$from.pos,o=e.$to.pos;i.doc.nodesBetween(r,o,(e,i)=>{let s=Math.max(i,r),a=Math.min(i+e.nodeSize,o);e.marks.find(e=>e.type===l)?e.marks.forEach(e=>{l===e.type&&n.addMark(s,a,l.create({...e.attrs,...t}))}):n.addMark(s,a,l.create(t))})})}return function(e,t,n){var i;let{selection:r}=t,o=null;if(eA(r)&&(o=r.$cursor),o){let t=null!==(i=e.storedMarks)&&void 0!==i?i:o.marks();return!!n.isInSet(t)||!t.some(e=>e.type.excludes(n))}let{ranges:s}=r;return s.some(({$from:t,$to:i})=>{let r=0===t.depth&&e.doc.inlineContent&&e.doc.type.allowsMarkType(n);return e.doc.nodesBetween(t.pos,i.pos,(e,t,i)=>{if(r)return!1;if(e.isInline){let t=!i||i.type.allowsMarkType(n),o=!!n.isInSet(e.marks)||!e.marks.some(e=>e.type.excludes(n));r=t&&o}return!r}),r})}(i,n,l)},setMeta:(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),setNode:(e,t={})=>({state:n,dispatch:i,chain:r})=>{let o;let s=G(e,n.schema);return(n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock)?r().command(({commands:e})=>!!R(s,{...o,...t})(n)||e.clearNodes()).command(({state:e})=>R(s,{...o,...t})(e,i)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,i=eE(e,0,n.content.size),o=r.qv.create(n,i);t.setSelection(o)}return!0},setTextSelection:e=>({tr:t,dispatch:n})=>{if(n){let{doc:n}=t,{from:i,to:o}="number"==typeof e?{from:e,to:e}:e,s=r.Bs.atStart(n).from,a=r.Bs.atEnd(n).to,l=eE(i,s,a),d=eE(o,s,a),c=r.Bs.create(n,l,d);t.setSelection(c)}return!0},sinkListItem:e=>({state:t,dispatch:n})=>{var i;return(i=G(e,t.schema),function(e,t){let{$from:n,$to:r}=e.selection,o=n.blockRange(r,e=>e.childCount>0&&e.firstChild.type==i);if(!o)return!1;let s=o.startIndex;if(0==s)return!1;let d=o.parent,c=d.child(s-1);if(c.type!=i)return!1;if(t){let n=c.lastChild&&c.lastChild.type==d.type,r=a.HY.from(n?i.create():null),s=new a.p2(a.HY.from(i.create(null,a.HY.from(d.type.create(null,r)))),n?3:1,0),h=o.start,u=o.end;t(e.tr.step(new l.FC(h-(n?3:1),u,h,u,s,1,!0)).scrollIntoView())}return!0})(t,n)},splitBlock:({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:i,editor:o})=>{let{selection:s,doc:a}=t,{$from:d,$to:c}=s,h=eV(o.extensionManager.attributes,d.node().type.name,d.node().attrs);if(s instanceof r.qv&&s.node.isBlock)return!!(d.parentOffset&&(0,l.Ax)(a,d.pos))&&(i&&(e&&eG(n,o.extensionManager.splittableMarks),t.split(d.pos).scrollIntoView()),!0);if(!d.parent.isBlock)return!1;let u=c.parentOffset===c.parent.content.size,p=0===d.depth?void 0:function(e){for(let t=0;t({tr:n,state:i,dispatch:o,editor:s})=>{var d;let c=G(e,i.schema),{$from:h,$to:u}=i.selection,p=i.selection.node;if(p&&p.isBlock||h.depth<2||!h.sameParent(u))return!1;let f=h.node(-1);if(f.type!==c)return!1;let m=s.extensionManager.attributes;if(0===h.parent.content.size&&h.node(-1).childCount===h.indexAfter(-1)){if(2===h.depth||h.node(-3).type!==c||h.index(-2)!==h.node(-2).childCount-1)return!1;if(o){let e=a.HY.empty,i=h.index(-1)?1:h.index(-2)?2:3;for(let t=h.depth-i;t>=h.depth-3;t-=1)e=a.HY.from(h.node(t).copy(e));let o=h.indexAfter(-1){if(p>-1)return!1;e.isTextblock&&0===e.content.size&&(p=t+1)}),p>-1&&n.setSelection(r.Bs.near(n.doc.resolve(p))),n.scrollIntoView()}return!0}let g=u.pos===h.end()?f.contentMatchAt(0).defaultType:null,v={...eV(m,f.type.name,f.attrs),...t},b={...eV(m,h.node().type.name,h.node().attrs),...t};n.delete(h.pos,u.pos);let y=g?[{type:c,attrs:v},{type:g,attrs:b}]:[{type:c,attrs:v}];if(!(0,l.Ax)(n.doc,h.pos,2))return!1;if(o){let{selection:e,storedMarks:t}=i,{splittableMarks:r}=s.extensionManager,a=t||e.$to.parentOffset&&e.$from.marks();if(n.split(h.pos,2,y).scrollIntoView(),!a||!o)return!0;let l=a.filter(e=>r.includes(e.type.name));n.ensureMarks(l)}return!0},toggleList:(e,t,n,i={})=>({editor:r,tr:o,state:s,dispatch:a,chain:l,commands:d,can:c})=>{let{extensions:h,splittableMarks:u}=r.extensionManager,p=G(e,s.schema),f=G(t,s.schema),{selection:m,storedMarks:g}=s,{$from:v,$to:b}=m,y=v.blockRange(b),x=g||m.$to.parentOffset&&m.$from.marks();if(!y)return!1;let w=ez(e=>e$(e.type.name,h))(m);if(y.depth>=1&&w&&y.depth-w.depth<=1){if(w.node.type===p)return d.liftListItem(f);if(e$(w.node.type.name,h)&&p.validContent(w.node.content)&&a)return l().command(()=>(o.setNodeMarkup(w.pos,p),!0)).command(()=>eK(o,p)).command(()=>eZ(o,p)).run()}return n&&x&&a?l().command(()=>{let e=c().wrapInList(p,i),t=x.filter(e=>u.includes(e.type.name));return o.ensureMarks(t),!!e||d.clearNodes()}).wrapInList(p,i).command(()=>eK(o,p)).command(()=>eZ(o,p)).run():l().command(()=>!!c().wrapInList(p,i)||d.clearNodes()).wrapInList(p,i).command(()=>eK(o,p)).command(()=>eZ(o,p)).run()},toggleMark:(e,t={},n={})=>({state:i,commands:r})=>{let{extendEmptyMarkRange:o=!1}=n,s=eC(e,i.schema);return eU(i,s,t)?r.unsetMark(s,{extendEmptyMarkRange:o}):r.setMark(s,t)},toggleNode:(e,t,n={})=>({state:i,commands:r})=>{let o;let s=G(e,i.schema),a=G(t,i.schema),l=eP(i,s,n);return(i.selection.$anchor.sameParent(i.selection.$head)&&(o=i.selection.$anchor.parent.attrs),l)?r.setNode(a,o):r.setNode(s,{...o,...n})},toggleWrap:(e,t={})=>({state:n,commands:i})=>{let r=G(e,n.schema);return eP(n,r,t)?i.lift(r):i.wrapIn(r,t)},undoInputRule:()=>({state:e,dispatch:t})=>{let n=e.plugins;for(let i=0;i=0;e-=1)t.step(n.steps[e].invert(n.docs[e]));if(r.text){let n=t.doc.resolve(r.from).marks();t.replaceWith(r.from,r.to,e.schema.text(r.text,n))}else t.delete(r.from,r.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{let{selection:n}=e,{empty:i,ranges:r}=n;return!!i||(t&&r.forEach(t=>{e.removeMark(t.$from.pos,t.$to.pos)}),!0)},unsetMark:(e,t={})=>({tr:n,state:i,dispatch:r})=>{var o;let{extendEmptyMarkRange:s=!1}=t,{selection:a}=n,l=eC(e,i.schema),{$from:d,empty:c,ranges:h}=a;if(!r)return!0;if(c&&s){let{from:e,to:t}=a,i=null===(o=d.marks().find(e=>e.type===l))||void 0===o?void 0:o.attrs,r=eS(d,l,i);r&&(e=r.from,t=r.to),n.removeMark(e,t,l)}else h.forEach(e=>{n.removeMark(e.$from.pos,e.$to.pos,l)});return n.removeStoredMark(l),!0},updateAttributes:(e,t={})=>({tr:n,state:i,dispatch:r})=>{let o=null,s=null,a=eR("string"==typeof e?e:e.name,i.schema);return!!a&&("node"===a&&(o=G(e,i.schema)),"mark"===a&&(s=eC(e,i.schema)),r&&n.selection.ranges.forEach(e=>{let r,a,l,d;let c=e.$from.pos,h=e.$to.pos;n.selection.empty?i.doc.nodesBetween(c,h,(e,t)=>{o&&o===e.type&&(l=Math.max(t,c),d=Math.min(t+e.nodeSize,h),r=t,a=e)}):i.doc.nodesBetween(c,h,(e,i)=>{i=c&&i<=h&&(o&&o===e.type&&n.setNodeMarkup(i,void 0,{...e.attrs,...t}),s&&e.marks.length&&e.marks.forEach(r=>{if(s===r.type){let o=Math.max(i,c),a=Math.min(i+e.nodeSize,h);n.addMark(o,a,s.create({...r.attrs,...t}))}}))}),a&&(void 0!==r&&n.setNodeMarkup(r,void 0,{...a.attrs,...t}),s&&a.marks.length&&a.marks.forEach(e=>{s===e.type&&n.addMark(l,d,s.create({...e.attrs,...t}))}))}),!0)},wrapIn:(e,t={})=>({state:n,dispatch:i})=>(function(e,t=null){return function(n,i){let{$from:r,$to:o}=n.selection,s=r.blockRange(o),a=s&&(0,l.nd)(s,e,t);return!!a&&(i&&i(n.tr.wrap(s,a).scrollIntoView()),!0)}})(G(e,n.schema),t)(n,i),wrapInList:(e,t={})=>({state:n,dispatch:i})=>(function(e,t=null){return function(n,i){let{$from:r,$to:o}=n.selection,s=r.blockRange(o);if(!s)return!1;let d=i?n.tr:null;return!!function(e,t,n,i=null){let r=!1,o=t,s=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=s.resolve(t.start-2);o=new a.Ts(e,e,t.depth),t.endIndex=0;e--)o=a.HY.from(n[e].type.create(n[e].attrs,o));e.step(new l.FC(t.start-(i?2:0),t.end,t.start,t.end,new a.p2(o,0,0),n.length,!0));let s=0;for(let e=0;e({...eY})}),eJ=eg.create({name:"drop",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("tiptapDrop"),props:{handleDrop:(e,t,n,i)=>{this.editor.emit("drop",{editor:this.editor,event:t,slice:n,moved:i})}}})]}}),eQ=eg.create({name:"editable",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("editable"),props:{editable:()=>this.editor.options.editable}})]}}),e0=new r.H$("focusEvents"),e1=eg.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:e}=this;return[new r.Sy({key:e0,props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;let i=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1},blur:(t,n)=>{e.isFocused=!1;let i=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(i),!1}}}})]}}),e2=eg.create({name:"keymap",addKeyboardShortcuts(){let e=()=>this.editor.commands.first(({commands:e})=>[()=>e.undoInputRule(),()=>e.command(({tr:t})=>{let{selection:n,doc:i}=t,{empty:o,$anchor:s}=n,{pos:a,parent:l}=s,d=s.parent.isTextblock&&a>0?t.doc.resolve(a-1):s,c=d.parent.type.spec.isolating,h=s.pos-s.parentOffset,u=c&&1===d.parent.childCount?h===s.pos:r.Y1.atStart(i).from===a;return!!o&&!!l.type.isTextblock&&!l.textContent.length&&!!u&&(!u||"paragraph"!==s.parent.type.name)&&e.clearNodes()}),()=>e.deleteSelection(),()=>e.joinBackward(),()=>e.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:e})=>[()=>e.deleteSelection(),()=>e.deleteCurrentNode(),()=>e.joinForward(),()=>e.selectNodeForward()]),n={Enter:()=>this.editor.commands.first(({commands:e})=>[()=>e.newlineInCode(),()=>e.createParagraphNear(),()=>e.liftEmptyBlock(),()=>e.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...n},o={...n,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return eT()||eN()?o:i},addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("clearDocument"),appendTransaction:(e,t,n)=>{if(e.some(e=>e.getMeta("composition")))return;let i=e.some(e=>e.docChanged)&&!t.doc.eq(n.doc),o=e.some(e=>e.getMeta("preventClearDocument"));if(!i||o)return;let{empty:s,from:a,to:l}=t.selection,d=r.Y1.atStart(t.doc).from,c=r.Y1.atEnd(t.doc).to;if(s||!(a===d&&l===c)||!eW(n.doc))return;let h=n.tr,u=H({state:n,transaction:h}),{commands:p}=new V({editor:this.editor,state:u});if(p.clearNodes(),!!h.steps.length)return h}})]}}),e5=eg.create({name:"paste",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("tiptapPaste"),props:{handlePaste:(e,t,n)=>{this.editor.emit("paste",{editor:this.editor,event:t,slice:n})}}})]}}),e3=eg.create({name:"tabindex",addProseMirrorPlugins(){return[new r.Sy({key:new r.H$("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class e4{get name(){return this.node.type.name}constructor(e,t,n=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=e,this.editor=t,this.currentNode=i}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return null!==(e=this.actualDepth)&&void 0!==e?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,n=this.to;if(this.isBlock){if(0===this.content.size){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:t,to:n},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1);return new e4(this.resolvedPos.doc.resolve(e),this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new e4(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new e4(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,n)=>{let i=t.isBlock&&!t.isTextblock,r=t.isAtom&&!t.isText,o=this.pos+n+(r?0:1),s=this.resolvedPos.doc.resolve(o);if(!i&&s.depth<=this.depth)return;let a=new e4(s,this.editor,i,i?t:null);i&&(a.actualDepth=this.depth+1),e.push(new e4(s,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let n=null,i=this.parent;for(;i&&!n;){if(i.node.type.name===e){if(Object.keys(t).length>0){let e=i.node.attrs,n=Object.keys(t);for(let i=0;i{if(n&&i.length>0)return;if(o.node.type.name===e&&r.every(e=>t[e]===o.node.attrs[e])&&i.push(o),!n||!(i.length>0))i=i.concat(o.querySelectorAll(e,t,n))}),i}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(t)}}let e6=`.ProseMirror { position: relative; } .ProseMirror { word-wrap: break-word; white-space: pre-wrap; white-space: break-spaces; -webkit-font-variant-ligatures: none; font-variant-ligatures: none; font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */ } .ProseMirror [contenteditable="false"] { white-space: normal; } .ProseMirror [contenteditable="false"] [contenteditable="true"] { white-space: pre-wrap; } .ProseMirror pre { white-space: pre-wrap; } img.ProseMirror-separator { display: inline !important; border: none !important; margin: 0 !important; width: 0 !important; height: 0 !important; } .ProseMirror-gapcursor { display: none; pointer-events: none; position: absolute; margin: 0; } .ProseMirror-gapcursor:after { content: ""; display: block; position: absolute; top: -2px; width: 20px; border-top: 1px solid black; animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite; } @keyframes ProseMirror-cursor-blink { to { visibility: hidden; } } .ProseMirror-hideselection *::selection { background: transparent; } .ProseMirror-hideselection *::-moz-selection { background: transparent; } .ProseMirror-hideselection * { caret-color: transparent; } .ProseMirror-focused .ProseMirror-gapcursor { display: block; } .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 }`;class e8 extends U{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:e})=>{throw e},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:e,slice:t,moved:n})=>this.options.onDrop(e,t,n)),this.on("paste",({event:e,slice:t})=>this.options.onPaste(e,t)),window.setTimeout(()=>{if(!this.isDestroyed)this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(e,t,n){let i=document.querySelector("style[data-tiptap-style]");if(null!==i)return i;let r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),r.innerHTML=e,document.getElementsByTagName("head")[0].appendChild(r),r}(e6,this.options.injectNonce))}setOptions(e={}){if(this.options={...this.options,...e},!!this.view&&!!this.state&&!this.isDestroyed)this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state)}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let n=Y(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,n=t;if([].concat(e).forEach(e=>{let t="string"==typeof e?`${e}$`:e.key;n=n.filter(e=>!e.key.startsWith(t))}),t.length===n.length)return;let i=this.state.reconfigure({plugins:n});return this.view.updateState(i),i}createExtensionManager(){var e,t;let n=[...this.options.enableCoreExtensions?[eQ,ey.configure({blockSeparator:null===(t=null===(e=this.options.coreExtensionOptions)||void 0===e?void 0:e.clipboardTextSerializer)||void 0===t?void 0:t.blockSeparator}),eX,e1,e2,e3,eJ,e5].filter(e=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[e.name]):[],...this.options.extensions].filter(e=>["extension","node","mark"].includes(null==e?void 0:e.type));this.extensionManager=new em(n,this)}createCommandManager(){this.commandManager=new V({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=ej(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(e=>"collaboration"!==e.name),this.createExtensionManager()}}),t=ej(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let n=ek(t,this.options.autofocus);this.view=new o.tk(this.options.element,{...this.options.editorProps,attributes:{role:"textbox",...null===(e=this.options.editorProps)||void 0===e?void 0:e.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:r.yy.create({doc:t,selection:n||void 0})});let i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.createNodeViews(),this.prependClass(),this.view.dom.editor=this}createNodeViews(){if(!this.view.isDestroyed)this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(e=>{var t;return null===(t=this.capturedTransaction)||void 0===t?void 0:t.step(e)});return}let t=this.state.apply(e),n=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),n&&this.emit("selectionUpdate",{editor:this,transaction:e});let i=e.getMeta("focus"),r=e.getMeta("blur");if(i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),r&&this.emit("blur",{editor:this,event:r.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate")))this.emit("update",{editor:this,transaction:e})}getAttributes(e){return function(e,t){let n=eR("string"==typeof t?t:t.name,e.schema);return"node"===n?function(e,t){let n=G(t,e.schema),{from:i,to:r}=e.selection,o=[];e.doc.nodesBetween(i,r,e=>{o.push(e)});let s=o.reverse().find(e=>e.type.name===n.name);return s?{...s.attrs}:{}}(e,t):"mark"===n?eF(e,t):{}}(this.state,e)}isActive(e,t){let n="string"==typeof e?e:null,i="string"==typeof e?t:e;return function(e,t,n={}){if(!t)return eP(e,null,n)||eU(e,null,n);let i=eR(t,e.schema);return"node"===i?eP(e,t,n):"mark"===i&&eU(e,t,n)}(this.state,n,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return en(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t="\n\n",textSerializers:n={}}=e||{};return function(e,t){let n={from:0,to:e.content.size};return ev(e,n,t)}(this.state.doc,{blockSeparator:t,textSerializers:{...eb(this.schema),...n}})}get isEmpty(){return eW(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(null===(e=this.view)||void 0===e?void 0:e.docView)}$node(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(e,t))||null}$nodes(e,t){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(e,t))||null}$pos(e){return new e4(this.state.doc.resolve(e),this)}get $doc(){return this.$pos(0)}}function e7(e){return new eo({find:e.find,handler:({state:t,range:n,match:i})=>{let r=X(e.getAttributes,void 0,i);if(!1===r||null===r)return null;let{tr:o}=t,s=i[i.length-1],a=i[0];if(s){let i=a.search(/\S/),l=n.from+a.indexOf(s),d=l+s.length;if(eH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>l).length)return null;dn.from&&o.delete(n.from+i,l);let c=n.from+i+s.length;o.addMark(n.from+i,c,e.type.create(r||{})),o.removeStoredMark(e.type)}}})}function e9(e){return new eo({find:e.find,handler:({state:t,range:n,match:i})=>{let r=X(e.getAttributes,void 0,i)||{},{tr:o}=t,s=n.from,a=n.to,l=e.type.create(r);if(i[1]){let e=s+i[0].lastIndexOf(i[1]);e>a?e=a:a=e+i[1].length;let t=i[0][i[0].length-1];o.insertText(t,s+i[0].length-1),o.replaceWith(e,a,l)}else if(i[0]){let t=e.type.isInline?s:s-1;o.insert(t,e.type.create(r)).delete(o.mapping.map(s),o.mapping.map(a))}o.scrollIntoView()}})}function te(e){return new eo({find:e.find,handler:({state:t,range:n,match:i})=>{let r=t.doc.resolve(n.from),o=X(e.getAttributes,void 0,i)||{};if(!r.node(-1).canReplaceWith(r.index(-1),r.indexAfter(-1),e.type))return null;t.tr.delete(n.from,n.to).setBlockType(n.from,n.from,e.type,o)}})}function tt(e){return new eo({find:e.find,handler:({state:t,range:n,match:i,chain:r})=>{let o=X(e.getAttributes,void 0,i)||{},s=t.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),d=a&&(0,l.nd)(a,e.type,o);if(!d)return null;if(s.wrap(a,d),e.keepMarks&&e.editor){let{selection:n,storedMarks:i}=t,{splittableMarks:r}=e.editor.extensionManager,o=i||n.$to.parentOffset&&n.$from.marks();if(o){let e=o.filter(e=>r.includes(e.type.name));s.ensureMarks(e)}}if(e.keepAttributes){let t="bulletList"===e.type.name||"orderedList"===e.type.name?"listItem":"taskList";r().updateAttributes(t,o).run()}let c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===e.type&&(0,l.Mn)(s.doc,n.from-1)&&(!e.joinPredicate||e.joinPredicate(i,c))&&s.join(n.from-1)}})}class tn{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=X($(this,"addOptions",{name:this.name}))),this.storage=X($(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new tn(e)}configure(e={}){let t=this.extend({...this.config,addOptions:()=>ed(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new tn(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=X($(t,"addOptions",{name:t.name})),t.storage=X($(t,"addStorage",{name:t.name,options:t.options})),t}}function ti(e){return new eh({find:e.find,handler:({state:t,range:n,match:i,pasteEvent:r})=>{let o=X(e.getAttributes,void 0,i,r);if(!1===o||null===o)return null;let{tr:s}=t,a=i[i.length-1],l=i[0],d=n.to;if(a){let i=l.search(/\S/),r=n.from+l.indexOf(a),c=r+a.length;if(eH(n.from,n.to,t.doc).filter(t=>t.mark.type.excluded.find(n=>n===e.type&&n!==t.mark.type)).filter(e=>e.to>r).length)return null;cn.from&&s.delete(n.from+i,r),d=n.from+i+a.length,s.addMark(n.from+i,d,e.type.create(o||{})),s.removeStoredMark(e.type)}}})}},550745:function(e,t,n){n.d(t,{ZP:function(){return o}});var i=n(453203);let r=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,o=i.NB.create({name:"image",addOptions:()=>({inline:!1,allowBase64:!1,HTMLAttributes:{}}),inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes:()=>({src:{default:null},alt:{default:null},title:{default:null}}),parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:e}){return["img",(0,i.P1)(this.options.HTMLAttributes,e)]},addCommands(){return{setImage:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[(0,i.x2)({find:r,type:this.type,getAttributes:e=>{let[,,t,n,i]=e;return{src:n,alt:t,title:i}}})]}})},778681:function(e,t,n){n.d(t,{Z:function(){return r}});var i=n(453203);let r=i.NB.create({name:"tableCell",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"cell",isolating:!0,parseHTML:()=>[{tag:"td"}],renderHTML({HTMLAttributes:e}){return["td",(0,i.P1)(this.options.HTMLAttributes,e),0]}})},357962:function(e,t,n){n.d(t,{Z:function(){return r}});var i=n(453203);let r=i.NB.create({name:"tableHeader",addOptions:()=>({HTMLAttributes:{}}),content:"block+",addAttributes:()=>({colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{let t=e.getAttribute("colwidth");return t?t.split(",").map(e=>parseInt(e,10)):null}}}),tableRole:"header_cell",isolating:!0,parseHTML:()=>[{tag:"th"}],renderHTML({HTMLAttributes:e}){return["th",(0,i.P1)(this.options.HTMLAttributes,e),0]}})},76049:function(e,t,n){n.d(t,{Z:function(){return r}});var i=n(453203);let r=i.NB.create({name:"tableRow",addOptions:()=>({HTMLAttributes:{}}),content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML:()=>[{tag:"tr"}],renderHTML({HTMLAttributes:e}){return["tr",(0,i.P1)(this.options.HTMLAttributes,e),0]}})},481265:function(e,t,n){n.d(t,{ZP:()=>eh});var i,r,o=n("453203"),s=n("871738"),a=n("153737"),l=n("661763"),d=n("132308"),c=n("240554");if("undefined"!=typeof WeakMap){let e=new WeakMap;i=t=>e.get(t),r=(t,n)=>(e.set(t,n),n)}else{let e=[],t=0;i=t=>{for(let n=0;n(10==t&&(t=0),e[t++]=n,e[t++]=i)}var h=class{constructor(e,t,n,i){this.width=e,this.height=t,this.map=n,this.problems=i}findCell(e){for(let t=0;ti&&(o+=r.attrs.colspan)}}for(let e=0;e1&&(n=!0)}-1==t?t=o:t!=o&&(t=Math.max(t,o))}return t}(e),n=e.childCount,i=[],r=0,o=null,s=[];for(let e=0,r=t*n;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:l,n:u-e});break}let d=r+e*t;for(let e=0;e0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function m(e){let t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function g(e){let t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;let n=f(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){let i=t.type.spec.tableRole;if("cell"==i||"header_cell"==i)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){let i=t.type.spec.tableRole;if("cell"==i||"header_cell"==i)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw RangeError(`No cell found around position ${t.head}`)}function v(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function b(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function y(e,t,n){let i=e.node(-1),r=h.get(i),o=e.start(-1),s=r.nextCell(e.pos-o,t,n);return null==s?null:e.node(0).resolve(o+s)}function x(e,t,n=1){let i={...e,colspan:e.colspan-n};return i.colwidth&&(i.colwidth=i.colwidth.slice(),i.colwidth.splice(t,n),!i.colwidth.some(e=>e>0)&&(i.colwidth=null)),i}function w(e,t,n=1){let i={...e,colspan:e.colspan+n};if(i.colwidth){i.colwidth=i.colwidth.slice();for(let e=0;ee!=t.pos-r);l.unshift(t.pos-r);let d=l.map(e=>{let t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);let i=r+e+1;return new s.xm(a.resolve(i),a.resolve(i+t.content.size))});super(d[0].$from,d[0].$to,d),this.$anchorCell=e,this.$headCell=t}map(t,n){let i=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(v(i)&&v(r)&&b(i,r)){let t=this.$anchorCell.node(-1)!=i.node(-1);return t&&this.isRowSelection()?e.rowSelection(i,r):t&&this.isColSelection()?e.colSelection(i,r):new e(i,r)}return s.Bs.between(i,r)}content(){let e=this.$anchorCell.node(-1),t=h.get(e),n=this.$anchorCell.start(-1),i=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},o=[];for(let n=i.top;n0||c>0){let e=l.attrs;if(d>0&&(e=x(e,0,d)),c>0&&(e=x(e,e.colspan-c,c)),a.lefti.bottom){let e={...l.attrs,rowspan:Math.min(a.bottom,i.bottom)-Math.max(a.top,i.top)};l=a.top0)return!1;let n=e+this.$anchorCell.nodeAfter.attrs.rowspan;return Math.max(n,t+this.$headCell.nodeAfter.attrs.rowspan)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){let i=t.node(-1),r=h.get(i),o=t.start(-1),s=r.findCell(t.pos-o),a=r.findCell(n.pos-o),l=t.node(0);return s.top<=a.top?(s.top>0&&(t=l.resolve(o+r.map[s.left])),a.bottom0&&(n=l.resolve(o+r.map[a.left])),s.bottom0)return!1;let o=i+this.$anchorCell.nodeAfter.attrs.colspan;return Math.max(o,r+this.$headCell.nodeAfter.attrs.colspan)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){let i=t.node(-1),r=h.get(i),o=t.start(-1),s=r.findCell(t.pos-o),a=r.findCell(n.pos-o),l=t.node(0);return s.left<=a.left?(s.left>0&&(t=l.resolve(o+r.map[s.top*r.width])),a.right0&&(n=l.resolve(o+r.map[a.top*r.width])),s.right{t.push(l.p.node(n,n+e.nodeSize,{class:"selectedCell"}))}),l.EH.create(e.doc,t)}var A=new s.H$("fix-tables");function E(e,t){let n;let i=(t,i)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,i){let r,o;let s=h.get(t);if(!s.problems)return i;!i&&(i=e.tr);let a=[];for(let e=0;e0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);let a=[];for(let n=0;n0?-1:0;(function(e,t,n){let i=u(t.type.schema).header_cell;for(let r=0;r0&&r0?-1:0;(function(e,t,n){var i;let r=u(t.type.schema).header_cell;for(let o=0;o0&&r0&&n[o]==n[o-1]||i.right0&&n[r]==n[r-e]||i.bottom{var i;let r,o;let s=t.selection;if(s instanceof _){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;r=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(!(r=function(e){for(let t=e.depth;t>0;t--){let n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(s.$from)))return!1;o=null==(i=f(s.$from))?void 0:i.pos}if(null==r||null==o||1==r.attrs.colspan&&1==r.attrs.rowspan)return!1;if(n){let i,a=r.attrs,l=[],d=a.colwidth;a.rowspan>1&&(a={...a,rowspan:1}),a.colspan>1&&(a={...a,colspan:1});let c=k(t),h=t.tr;for(let e=0;en[e.type.spec.tableRole])(e,t)}function N(e,t,n){let i=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;er.table.nodeAt(e));for(let e=0;e{let t=e+r.tableStart,n=o.doc.nodeAt(t);n&&o.setNodeMarkup(t,c,n.attrs)}),n(o)}return!0}}P("row",{useDeprecatedLogic:!0}),P("column",{useDeprecatedLogic:!0});var R=P("cell",{useDeprecatedLogic:!0});function L(e){return function(t,n){if(!m(t))return!1;let i=function(e,t){if(t<0){let t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){let i=e.node(-1).child(t),r=i.lastChild;if(r)return n-1-r.nodeSize;n-=i.nodeSize}}else{if(e.index(){!e.content.eq(r)&&i.replace(i.mapping.map(t+1),i.mapping.map(t+e.nodeSize-1),new a.p2(r,0,0))}),i.docChanged&&t(i)}return!0}function F(e,t){let n=e.createAndFill();return new c.wx(n).replace(0,n.content.size,t).doc}function B(e,t,n,i,r,o,s,a){if(0==s||s==t.height)return!1;let l=!1;for(let d=r;dt.width)for(let o=0,a=0;ot.height){let h=[];for(let e=0,i=(t.height-1)*t.width;e=t.width)&&n.nodeAt(t.map[i+e]).type==c.header_cell;h.push(r?d||(d=c.header_cell.createAndFill()):l||(l=c.cell.createAndFill()))}let u=c.row.create(null,a.HY.from(h)),p=[];for(let e=t.height;e{if(!r)return!1;let o=n.selection;if(o instanceof _)return U(n,i,s.Y1.near(o.$headCell,t));if("horiz"!=e&&!o.empty)return!1;let a=Z(r,e,t);if(null==a)return!1;if("horiz"==e)return U(n,i,s.Y1.near(n.doc.resolve(o.head+t),t));{let r;let o=n.doc.resolve(a),l=y(o,e,t);return r=l?s.Y1.near(l,1):t<0?s.Y1.near(n.doc.resolve(o.before(-1)),-1):s.Y1.near(n.doc.resolve(o.after(-1)),1),U(n,i,r)}}}function W(e,t){return(n,i,r)=>{let o;if(!r)return!1;let s=n.selection;if(s instanceof _)o=s;else{let i=Z(r,e,t);if(null==i)return!1;o=new _(n.doc.resolve(i))}let a=y(o.$headCell,e,t);return!!a&&U(n,i,new _(o.$anchorCell,a))}}function q(e,t){let n=f(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new _(n))),!0)}function G(e,t,n){if(!m(e.state))return!1;let i=function(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:i}=e;for(;1==t.childCount&&(n>0&&i>0||"table"==t.child(0).type.spec.tableRole);)n--,i--,t=t.child(0).content;let r=t.child(0),o=r.type.spec.tableRole,s=r.type.schema,l=[];if("row"==o)for(let e=0;e=0;t--){let{rowspan:r,colspan:o}=i.child(t).attrs;for(let t=e;t=t.length&&t.push(a.HY.empty),n[r]i&&(a=a.type.createChecked(x(a.attrs,a.attrs.colspan,n+a.attrs.colspan-i),a.content)),s.push(a),n+=a.attrs.colspan;for(let n=1;nr&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,r-t.attrs.rowspan)},t.content)),s.push(t)}e.push(a.HY.from(s))}n=e,t=r}return{width:e,height:t,rows:n}}(i,s.right-s.left,s.bottom-s.top),H(e.state,e.dispatch,o,s,i),!0}if(!i)return!1;{let t=g(e.state),n=t.start(-1);return H(e.state,e.dispatch,n,h.get(t.node(-1)).findCell(t.pos-n),i),!0}}function K(e,t){var n;let i;if(t.ctrlKey||t.metaKey)return;let r=Y(e,t.target);if(t.shiftKey&&e.state.selection instanceof _)o(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(i=f(e.state.selection.$anchor))&&(null==(n=X(e,t))?void 0:n.pos)!=i.pos)o(i,t),t.preventDefault();else if(!r)return;function o(t,n){let i=X(e,n),r=null==p.getState(e.state);if(!i||!b(t,i)){if(!r)return;i=t}let o=new _(t,i);if(r||!e.state.selection.eq(o)){let n=e.state.tr.setSelection(o);r&&n.setMeta(p,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",a),null!=p.getState(e.state)&&e.dispatch(e.state.tr.setMeta(p,-1))}function a(n){let i;let a=p.getState(e.state);if(null!=a)i=e.state.doc.resolve(a);else if(Y(e,n.target)!=r&&!(i=X(e,t)))return s();i&&o(i,n)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",a)}function Z(e,t,n){if(!(e.state.selection instanceof s.Bs))return null;let{$head:i}=e.state.selection;for(let r=i.depth-1;r>=0;r--){let o=i.node(r);if((n<0?i.index(r):i.indexAfter(r))!=(n<0?0:o.childCount))break;if("cell"==o.type.spec.tableRole||"header_cell"==o.type.spec.tableRole){let o=i.before(r),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?o:null}}return null}function Y(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function X(e,t){let n=e.posAtCoords({left:t.clientX,top:t.clientY});return n?n?f(e.state.doc.resolve(n.pos)):null:null}var J=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Q(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Q(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Q(e,t,n,i,r,o){var s;let a=0,l=!0,d=t.firstChild,c=e.firstChild;if(c){for(let e=0,n=0;e-1&&t.docChanged){let n=t.mapping.map(this.activeHandle,-1);return!v(t.doc.resolve(n))&&(n=-1),new e(n,this.dragging)}return this}};function en(e,t,n,i){let r=e.posAtCoords({left:t.clientX+("right"==n?-i:i),top:t.clientY});if(!r)return -1;let{pos:o}=r,s=f(e.state.doc.resolve(o));if(!s)return -1;if("right"==n)return s.pos;let a=h.get(s.node(-1)),l=s.start(-1),d=a.map.indexOf(s.pos-l);return d%a.width==0?-1:l+a.map[d-1]}function ei(e,t,n){let i=t.clientX-e.startX;return Math.max(n,e.startWidth+i)}function er(e,t){e.dispatch(e.state.tr.setMeta(ee,{setHandle:t}))}function eo(e,t,n,i){let r=e.state.doc.resolve(t),o=r.node(-1),s=r.start(-1),a=h.get(o).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,l=e.domAtPos(r.start(-1)).node;for(;l&&"TABLE"!=l.nodeName;)l=l.parentNode;l&&Q(o,l.firstChild,l,i,a,n)}function es(e,t){return t?["width",`${Math.max(t,e)}px`]:["min-width",`${e}px`]}function ea(e,t,n,i,r,o){var s;let a=0,l=!0,d=t.firstChild,c=e.firstChild;if(null!==c)for(let e=0,n=0;e{let{selection:t}=e.state;if(!(t instanceof _))return!1;let n=0,i=(0,o.qv)(t.ranges[0].$from,e=>"table"===e.type.name);return null==i||i.node.descendants(e=>{if("table"===e.type.name)return!1;["tableCell","tableHeader"].includes(e.type.name)&&(n+=1)}),n===t.ranges.length&&(e.commands.deleteTable(),!0)},eh=o.NB.create({name:"table",addOptions:()=>({HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:el,lastColumnResizable:!0,allowTableNodeSelection:!1}),content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML:()=>[{tag:"table"}],renderHTML({node:e,HTMLAttributes:t}){let{colgroup:n,tableWidth:i,tableMinWidth:r}=function(e,t,n,i){let r=0,o=!0,s=[],a=e.firstChild;if(!a)return{};for(let e=0,n=0;e({insertTable:({rows:e=3,cols:t=3,withHeaderRow:n=!0}={})=>({tr:i,dispatch:r,editor:o})=>{let a=function(e,t,n,i,r){let o=function(e){if(e.cached.tableNodeTypes)return e.cached.tableNodeTypes;let t={};return Object.keys(e.nodes).forEach(n=>{let i=e.nodes[n];i.spec.tableRole&&(t[i.spec.tableRole]=i)}),e.cached.tableNodeTypes=t,t}(e),s=[],a=[];for(let e=0;e({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(T(e.tr,n,n.left))}return!0})(e,t),addColumnAfter:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(T(e.tr,n,n.right))}return!0})(e,t),deleteColumn:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e),i=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;!function(e,{map:t,table:n,tableStart:i},r){let o=e.mapping.maps.length;for(let s=0;s0&&t.map[a-1]==l||r({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(M(e.tr,n,n.top))}return!0})(e,t),addRowAfter:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e);t(M(e.tr,n,n.bottom))}return!0})(e,t),deleteRow:()=>({state:e,dispatch:t})=>(function(e,t){if(!m(e))return!1;if(t){let n=k(e),i=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;!function(e,{map:t,table:n,tableStart:i},r){let o=0;for(let e=0;e0&&d==t.map[s-t.width]){let t=n.nodeAt(d).attrs;e.setNodeMarkup(e.mapping.slice(a).map(d+i),null,{...t,rowspan:t.rowspan-1}),o+=t.colspan-1}else if(r({state:e,dispatch:t})=>(function(e,t){let n=e.selection.$anchor;for(let i=n.depth;i>0;i--)if("table"==n.node(i).type.spec.tableRole)return t&&t(e.tr.delete(n.before(i),n.after(i)).scrollIntoView()),!0;return!1})(e,t),mergeCells:()=>({state:e,dispatch:t})=>O(e,t),splitCell:()=>({state:e,dispatch:t})=>I(e,t),toggleHeaderColumn:()=>({state:e,dispatch:t})=>P("column")(e,t),toggleHeaderRow:()=>({state:e,dispatch:t})=>P("row")(e,t),toggleHeaderCell:()=>({state:e,dispatch:t})=>R(e,t),mergeOrSplit:()=>({state:e,dispatch:t})=>!!O(e,t)||I(e,t),setCellAttribute:(e,t)=>({state:n,dispatch:i})=>{var r,o;return(r=e,o=t,function(e,t){if(!m(e))return!1;let n=g(e);if(n.nodeAfter.attrs[r]===o)return!1;if(t){let i=e.tr;e.selection instanceof _?e.selection.forEachCell((e,t)=>{e.attrs[r]!==o&&i.setNodeMarkup(t,null,{...e.attrs,[r]:o})}):i.setNodeMarkup(n.pos,null,{...n.nodeAfter.attrs,[r]:o}),t(i)}return!0})(n,i)},goToNextCell:()=>({state:e,dispatch:t})=>L(1)(e,t),goToPreviousCell:()=>({state:e,dispatch:t})=>L(-1)(e,t),fixTables:()=>({state:e,dispatch:t})=>(t&&E(e),!0),setCellSelection:e=>({tr:t,dispatch:n})=>{if(n){let n=_.create(t.doc,e.anchorCell,e.headCell);t.setSelection(n)}return!0}}),addKeyboardShortcuts(){return{Tab:()=>!!this.editor.commands.goToNextCell()||!!this.editor.can().addRowAfter()&&this.editor.chain().addRowAfter().goToNextCell().run(),"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:ec,"Mod-Backspace":ec,Delete:ec,"Mod-Delete":ec}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[function({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:i=J,lastColumnResizable:r=!0}={}){let o=new s.Sy({key:ee,state:{init(e,t){var r,s;let a=null==(s=null==(r=o.spec)?void 0:r.props)?void 0:s.nodeViews,l=u(t.schema).table.name;return i&&a&&(a[l]=(e,t)=>new i(e,n,t)),new et(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{let t=ee.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{(function(e,t,n,i){if(!e.editable)return;let r=ee.getState(e.state);if(r&&!r.dragging){let o=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target),s=-1;if(o){let{left:i,right:r}=o.getBoundingClientRect();t.clientX-i<=n?s=en(e,t,"left",n):r-t.clientX<=n&&(s=en(e,t,"right",n))}if(s!=r.activeHandle){if(!i&&-1!==s){let t=e.state.doc.resolve(s),n=t.node(-1),i=h.get(n),r=t.start(-1);if(i.colCount(t.pos-r)+t.nodeAfter.attrs.colspan-1==i.width-1)return}er(e,s)}}})(t,n,e,r)},mouseleave:e=>{(function(e){if(!e.editable)return;let t=ee.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&er(e,-1)})(e)},mousedown:(e,i)=>{(function(e,t,n,i){var r;if(!e.editable)return;let o=null!=(r=e.dom.ownerDocument.defaultView)?r:window,s=ee.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return;let a=e.state.doc.nodeAt(s.activeHandle),l=function(e,t,{colspan:n,colwidth:i}){let r=i&&i[i.length-1];if(r)return r;let o=e.domAtPos(t),s=o.node.childNodes[o.offset].offsetWidth,a=n;if(i)for(let e=0;e{let t=ee.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;let i=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return l.EH.empty;let s=h.get(o),a=r.start(-1),d=s.colCount(r.pos-a)+r.nodeAfter.attrs.colspan-1;for(let t=0;tnull,apply(e,t){let n=e.getMeta(p);if(null!=n)return -1==n?null:n;if(null==t||!e.docChanged)return t;let{deleted:i,pos:r}=e.mapping.mapResult(t);return i?null:r}},props:{decorations:C,handleDOMEvents:{mousedown:K},createSelectionBetween:e=>null!=p.getState(e.state)?e.state.selection:null,handleTripleClick:q,handleKeyDown:V,handlePaste:G},appendTransaction:(t,n,i)=>(function(e,t,n){let i,r;let o=(t||e).selection,a=(t||e).doc;if(o instanceof s.qv&&(r=o.node.type.spec.tableRole)){if("cell"==r||"header_cell"==r)i=_.create(a,o.from);else if("row"==r){let e=a.resolve(o.from+1);i=_.rowSelection(e,e)}else if(!n){let e=h.get(o.node),t=o.from+1,n=t+e.map[e.width*e.height-1];i=_.create(a,t+1,n)}}else o instanceof s.Bs&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos=0&&!(e.after(r+1)=0&&!(t.before(e+1)>t.start(e));e--,i--);return n==i&&/row|table/.test(e.node(r).type.spec.tableRole)}(o)?i=s.Bs.create(a,o.from):o instanceof s.Bs&&function({$from:e,$to:t}){let n,i;for(let t=e.depth;t>0;t--){let i=e.node(t);if("cell"===i.type.spec.tableRole||"header_cell"===i.type.spec.tableRole){n=i;break}}for(let e=t.depth;e>0;e--){let n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){i=n;break}}return n!==i&&0===t.parentOffset}(o)&&(i=s.Bs.create(a,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t})(i,E(i,n),e)})}({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(e){let t={name:e.name,options:e.options,storage:e.storage};return{tableRole:(0,o.nU)((0,o.Nl)(e,"tableRole",t))}}})},707291:function(e,t,n){n.d(t,{jE:function(){return E},kg:function(){return g}});var i,r,o,s=n(455069),a=n(921463),l=n(453203),d={exports:{}},c={};d.exports=function(){if(r)return c;r=1;var e="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},t=s.useState,n=s.useEffect,i=s.useLayoutEffect,o=s.useDebugValue;function a(t){var n=t.getSnapshot;t=t.value;try{var i=n();return!e(t,i)}catch(e){return!0}}var l="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,r){var s=r(),l=t({inst:{value:s,getSnapshot:r}}),d=l[0].inst,c=l[1];return i(function(){d.value=s,d.getSnapshot=r,a(d)&&c({inst:d})},[e,s,r]),n(function(){return a(d)&&c({inst:d}),e(function(){a(d)&&c({inst:d})})},[e]),o(s),s};return c.useSyncExternalStore=void 0!==s.useSyncExternalStore?s.useSyncExternalStore:l,c}();var h=d.exports;let u=(...e)=>t=>{e.forEach(e=>{"function"==typeof e?e(t):e&&(e.current=t)})},p=({contentComponent:e})=>{let t=h.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return s.createElement(s.Fragment,null,Object.values(t))};class f extends s.Component{constructor(e){var t;super(e),this.editorContentRef=s.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!(null===(t=e.editor)||void 0===t?void 0:t.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){let e=this.props.editor;if(e&&!e.isDestroyed&&e.options.element){if(e.contentComponent)return;let t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=function(){let e=new Set,t={};return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),getSnapshot:()=>t,getServerSnapshot:()=>t,setRenderer(n,i){t={...t,[n]:a.createPortal(i.reactElement,i.element,n)},e.forEach(e=>e())},removeRenderer(n){let i={...t};delete i[n],t=i,e.forEach(e=>e())}}}(),!this.state.hasContentComponentInitialized&&(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(e=>e.hasContentComponentInitialized?e:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.createNodeViews(),this.initialized=!0}}componentWillUnmount(){let e=this.props.editor;if(!e)return;if(this.initialized=!1,!e.isDestroyed&&e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!e.options.element.firstChild)return;let t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){let{editor:e,innerRef:t,...n}=this.props;return s.createElement(s.Fragment,null,s.createElement("div",{ref:u(t,this.editorContentRef),...n}),(null==e?void 0:e.contentComponent)&&s.createElement(p,{contentComponent:e.contentComponent}))}}let m=(0,s.forwardRef)((e,t)=>{let n=s.useMemo(()=>Math.floor(0xffffffff*Math.random()).toString(),[e.editor]);return s.createElement(f,{key:n,innerRef:t,...e})}),g=s.memo(m);var v=(i=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t instanceof Map&&n instanceof Map){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;for(r of t.entries())if(!e(r[1],n.get(r[0])))return!1;return!0}if(t instanceof Set&&n instanceof Set){if(t.size!==n.size)return!1;for(r of t.entries())if(!n.has(r[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(n)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(t[r]!==n[r])return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;0!=r--;){var i,r,o,s=o[r];if("_owner"!==s||!t.$$typeof){if(!e(t[s],n[s]))return!1}}return!0}return t!=t&&n!=n},i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default"))?i.default:i,b={exports:{}},y={};b.exports=function(){if(o)return y;o=1;var e="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},t=h.useSyncExternalStore,n=s.useRef,i=s.useEffect,r=s.useMemo,a=s.useDebugValue;return y.useSyncExternalStoreWithSelector=function(o,s,l,d,c){var h=n(null);if(null===h.current){var u={hasValue:!1,value:null};h.current=u}else u=h.current;var p=t(o,(h=r(function(){function t(t){if(!r){if(r=!0,n=t,t=d(t),void 0!==c&&u.hasValue){var o=u.value;if(c(o,t))return i=o}return i=t}if(o=i,e(n,t))return o;var s=d(t);return void 0!==c&&c(o,s)?o:(n=t,i=s)}var n,i,r=!1,o=void 0===l?null:l;return[function(){return t(s())},null===o?void 0:function(){return t(o())}]},[s,l,d,c]))[0],h[1]);return i(function(){u.hasValue=!0,u.value=p},[p]),a(p),p},y}();var x=b.exports;let w="undefined"!=typeof window?s.useLayoutEffect:s.useEffect;class _{constructor(e){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=e,this.lastSnapshot={editor:e,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}watch(e){if(this.editor=e,this.editor){let e=()=>{this.transactionNumber+=1,this.subscribers.forEach(e=>e())},t=this.editor;return t.on("transaction",e),()=>{t.off("transaction",e)}}}}let S="undefined"==typeof window,C=S||!!("undefined"!=typeof window&&window.next);class A{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(e=>e())}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return S||C?null:this.createEditor();this.options.current.immediatelyRender;return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){let e={...this.options.current,onBeforeCreate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(t,...e)},onBlur:(...e)=>{var t,n;return null===(n=(t=this.options.current).onBlur)||void 0===n?void 0:n.call(t,...e)},onCreate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onCreate)||void 0===n?void 0:n.call(t,...e)},onDestroy:(...e)=>{var t,n;return null===(n=(t=this.options.current).onDestroy)||void 0===n?void 0:n.call(t,...e)},onFocus:(...e)=>{var t,n;return null===(n=(t=this.options.current).onFocus)||void 0===n?void 0:n.call(t,...e)},onSelectionUpdate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(t,...e)},onTransaction:(...e)=>{var t,n;return null===(n=(t=this.options.current).onTransaction)||void 0===n?void 0:n.call(t,...e)},onUpdate:(...e)=>{var t,n;return null===(n=(t=this.options.current).onUpdate)||void 0===n?void 0:n.call(t,...e)},onContentError:(...e)=>{var t,n;return null===(n=(t=this.options.current).onContentError)||void 0===n?void 0:n.call(t,...e)},onDrop:(...e)=>{var t,n;return null===(n=(t=this.options.current).onDrop)||void 0===n?void 0:n.call(t,...e)},onPaste:(...e)=>{var t,n;return null===(n=(t=this.options.current).onPaste)||void 0===n?void 0:n.call(t,...e)}};return new l.ML(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,t){return Object.keys(e).every(n=>{if(["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(n))return!0;if("extensions"===n&&e.extensions&&t.extensions)return e.extensions.length===t.extensions.length&&e.extensions.every((e,n)=>{var i;return e===(null===(i=t.extensions)||void 0===i?void 0:i[n])&&!0});return e[n]===t[n]&&!0})}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===e.length?!A.compareOptions(this.options.current,this.editor.options)&&this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((t,n)=>t===e[n]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){let e=this.instanceId,t=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){t&&t.setOptions(this.options.current);return}t&&!t.isDestroyed&&(t.destroy(),this.instanceId===e&&this.setEditor(null))},1)}}function E(e={},t=[]){let n=(0,s.useRef)(e);n.current=e;let[i]=(0,s.useState)(()=>new A(n)),r=h.useSyncExternalStore(i.subscribe,i.getEditor,i.getServerSnapshot);return(0,s.useDebugValue)(r),(0,s.useEffect)(i.onRender(t)),!function(e){var t;let[n]=(0,s.useState)(()=>new _(e.editor)),i=x.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,e.selector,null!==(t=e.equalityFn)&&void 0!==t?t:v);w(()=>n.watch(e.editor),[e.editor,n]),(0,s.useDebugValue)(i)}({editor:r,selector:({transactionNumber:t})=>!1===e.shouldRerenderOnTransaction?null:e.immediatelyRender&&0===t?0:t+1}),r}(0,s.createContext)({editor:null}).Consumer;let k=(0,s.createContext)({onDragStart:void 0}),T=()=>(0,s.useContext)(k);s.forwardRef((e,t)=>{let{onDragStart:n}=T(),i=e.as||"div";return s.createElement(i,{...e,ref:t,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...e.style}})})},724830:function(e,t,n){n.d(t,{Z:()=>ev});var i=n("453203");let r=/^\s*>\s$/,o=i.NB.create({name:"blockquote",addOptions:()=>({HTMLAttributes:{}}),content:"block+",group:"block",defining:!0,parseHTML:()=>[{tag:"blockquote"}],renderHTML({HTMLAttributes:e}){return["blockquote",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBlockquote:()=>({commands:e})=>e.wrapIn(this.name),toggleBlockquote:()=>({commands:e})=>e.toggleWrap(this.name),unsetBlockquote:()=>({commands:e})=>e.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[(0,i.S0)({find:r,type:this.type})]}}),s=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,a=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,l=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,d=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,c=i.vc.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!==e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>e.type.name===this.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}]},renderHTML({HTMLAttributes:e}){return["strong",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setBold:()=>({commands:e})=>e.setMark(this.name),toggleBold:()=>({commands:e})=>e.toggleMark(this.name),unsetBold:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[(0,i.Cf)({find:s,type:this.type}),(0,i.Cf)({find:l,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:a,type:this.type}),(0,i.K9)({find:d,type:this.type})]}}),h="textStyle",u=/^\s*([-+*])\s$/,p=i.NB.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:e}){return["ul",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleBulletList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(h)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let e=(0,i.S0)({find:u,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(e=(0,i.S0)({find:u,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(h),editor:this.editor})),[e]}}),f=/(^|[^`])`([^`]+)`(?!`)/,m=/(^|[^`])`([^`]+)`(?!`)/g,g=i.vc.create({name:"code",addOptions:()=>({HTMLAttributes:{}}),excludes:"_",code:!0,exitable:!0,parseHTML:()=>[{tag:"code"}],renderHTML({HTMLAttributes:e}){return["code",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setCode:()=>({commands:e})=>e.setMark(this.name),toggleCode:()=>({commands:e})=>e.toggleMark(this.name),unsetCode:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[(0,i.Cf)({find:f,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:m,type:this.type})]}});var v=n("871738");let b=/^```([a-z]+)?[\s\n]$/,y=/^~~~([a-z]+)?[\s\n]$/,x=i.NB.create({name:"codeBlock",addOptions:()=>({languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}),content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:e=>{var t;let{languageClassPrefix:n}=this.options,i=[...(null===(t=e.firstElementChild)||void 0===t?void 0:t.classList)||[]].filter(e=>e.startsWith(n)).map(e=>e.replace(n,""))[0];return i?i:null},rendered:!1}}},parseHTML:()=>[{tag:"pre",preserveWhitespace:"full"}],renderHTML({node:e,HTMLAttributes:t}){return["pre",(0,i.P1)(this.options.HTMLAttributes,t),["code",{class:e.attrs.language?this.options.languageClassPrefix+e.attrs.language:null},0]]},addCommands(){return{setCodeBlock:e=>({commands:t})=>t.setNode(this.name,e),toggleCodeBlock:e=>({commands:t})=>t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:e,$anchor:t}=this.editor.state.selection,n=1===t.pos;return!!e&&t.parent.type.name===this.name&&(!!n||!t.parent.textContent.length)&&this.editor.commands.clearNodes()},Enter:({editor:e})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:t}=e,{selection:n}=t,{$from:i,empty:r}=n;if(!r||i.parent.type!==this.type)return!1;let o=i.parentOffset===i.parent.nodeSize-2,s=i.parent.textContent.endsWith("\n\n");return!!o&&!!s&&e.chain().command(({tr:e})=>(e.delete(i.pos-2,i.pos),!0)).exitCode().run()},ArrowDown:({editor:e})=>{if(!this.options.exitOnArrowDown)return!1;let{state:t}=e,{selection:n,doc:i}=t,{$from:r,empty:o}=n;if(!o||r.parent.type!==this.type||r.parentOffset!==r.parent.nodeSize-2)return!1;let s=r.after();return void 0!==s&&(i.nodeAt(s)?e.commands.command(({tr:e})=>(e.setSelection(v.Y1.near(i.resolve(s))),!0)):e.commands.exitCode())}}},addInputRules(){return[(0,i.zK)({find:b,type:this.type,getAttributes:e=>({language:e[1]})}),(0,i.zK)({find:y,type:this.type,getAttributes:e=>({language:e[1]})})]},addProseMirrorPlugins(){return[new v.Sy({key:new v.H$("codeBlockVSCodeHandler"),props:{handlePaste:(e,t)=>{if(!t.clipboardData||this.editor.isActive(this.type.name))return!1;let n=t.clipboardData.getData("text/plain"),i=t.clipboardData.getData("vscode-editor-data"),r=i?JSON.parse(i):void 0,o=null==r?void 0:r.mode;if(!n||!o)return!1;let{tr:s,schema:a}=e.state,l=a.text(n.replace(/\r\n?/g,"\n"));return s.replaceSelectionWith(this.type.create({language:o},l)),s.selection.$from.parent.type!==this.type&&s.setSelection(v.Bs.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),e.dispatch(s),!0}}})]}}),w=i.NB.create({name:"doc",topNode:!0,content:"block+"});var _=n("240554");class S{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){null!=this.cursorPos&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t,n=this.editorView.state.doc.resolve(this.cursorPos),i=!n.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),a=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(i){let e=n.nodeBefore,t=n.nodeAfter;if(e||t){let n=this.editorView.nodeDOM(this.cursorPos-(e?e.nodeSize:0));if(n){let i=n.getBoundingClientRect(),o=e?i.bottom:i.top;e&&t&&(o=(o+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*l;r={left:i.left,right:i.right,top:o-s,bottom:o+s}}}}if(!r){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;r={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let d=this.editorView.dom.offsetParent;if(!this.element&&(this.element=d.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",i),this.element.classList.toggle("prosemirror-dropcursor-inline",!i),d&&(d!=document.body||"static"!=getComputedStyle(d).position)){let n=d.getBoundingClientRect(),i=n.width/d.offsetWidth,r=n.height/d.offsetHeight;e=n.left-d.scrollLeft*i,t=n.top-d.scrollTop*r}else e=-pageXOffset,t=-pageYOffset;this.element.style.left=(r.left-e)/a+"px",this.element.style.top=(r.top-t)/l+"px",this.element.style.width=(r.right-r.left)/a+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,r="function"==typeof i?i(this.editorView,t,e):i;if(t&&!r){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=(0,_.nj)(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){!this.editorView.dom.contains(e.relatedTarget)&&this.setCursor(null)}}let C=i.hj.create({name:"dropCursor",addOptions:()=>({color:"currentColor",width:1,class:void 0}),addProseMirrorPlugins(){return[function(e={}){return new v.Sy({view:t=>new S(t,e)})}(this.options)]}});var A=n("132308"),E=n("153737"),k=n("661763");class T extends v.Y1{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return T.valid(n)?new T(n):v.Y1.near(n)}content(){return E.p2.empty}eq(e){return e instanceof T&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw RangeError("Invalid input for GapCursor.fromJSON");return new T(e.resolve(t.pos))}getBookmark(){return new M(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),i=e.node(t);if(0==n){if(i.type.spec.isolating)return!0;continue}for(let e=i.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),i=e.node(t);if(n==i.childCount){if(i.type.spec.isolating)return!0;continue}for(let e=i.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){t:for(;;){if(!n&&T.valid(e))return e;let i=e.pos,r=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)0){r=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;i+=t;let s=e.doc.resolve(i);if(T.valid(s))return s}for(;;){let o=t>0?r.firstChild:r.lastChild;if(!o){if(r.isAtom&&!r.isText&&!v.qv.isSelectable(r)){e=e.doc.resolve(i+r.nodeSize*t),n=!1;continue t}break}r=o,i+=t;let s=e.doc.resolve(i);if(T.valid(s))return s}return null}}}T.prototype.visible=!1,T.findFrom=T.findGapCursorFrom,v.Y1.jsonID("gapcursor",T);class M{constructor(e){this.pos=e}map(e){return new M(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return T.valid(t)?new T(t):v.Y1.near(t)}}let D=(0,A.$)({ArrowLeft:O("horiz",-1),ArrowRight:O("horiz",1),ArrowUp:O("vert",-1),ArrowDown:O("vert",1)});function O(e,t){let n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,i,r){let o=e.selection,s=t>0?o.$to:o.$from,a=o.empty;if(o instanceof v.Bs){if(!r.endOfTextblock(n)||0==s.depth)return!1;a=!1,s=e.doc.resolve(t>0?s.after():s.before())}let l=T.findGapCursorFrom(s,t,a);return!!l&&(i&&i(e.tr.setSelection(new T(l))),!0)}}function I(e,t,n){if(!e||!e.editable)return!1;let i=e.state.doc.resolve(t);if(!T.valid(i))return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&v.qv.isSelectable(e.state.doc.nodeAt(r.inside)))&&(e.dispatch(e.state.tr.setSelection(new T(i))),!0)}function N(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof T))return!1;let{$from:n}=e.state.selection,i=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!i)return!1;let r=E.HY.empty;for(let e=i.length-1;e>=0;e--)r=E.HY.from(i[e].createAndFill(null,r));let o=e.state.tr.replace(n.pos,n.pos,new E.p2(r,0,0));return o.setSelection(v.Bs.near(o.doc.resolve(n.pos+1))),e.dispatch(o),!1}function P(e){if(!(e.selection instanceof T))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",k.EH.create(e.doc,[k.p.widget(e.selection.head,t,{key:"gapcursor"})])}let R=i.hj.create({name:"gapCursor",addProseMirrorPlugins:()=>[new v.Sy({props:{decorations:P,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&T.valid(n)?new T(n):null,handleClick:I,handleKeyDown:D,handleDOMEvents:{beforeinput:N}}})],extendNodeSchema(e){var t;let n={name:e.name,options:e.options,storage:e.storage};return{allowGapCursor:null!==(t=(0,i.nU)((0,i.Nl)(e,"allowGapCursor",n)))&&void 0!==t?t:null}}}),L=i.NB.create({name:"hardBreak",addOptions:()=>({keepMarks:!0,HTMLAttributes:{}}),inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML:()=>[{tag:"br"}],renderHTML({HTMLAttributes:e}){return["br",(0,i.P1)(this.options.HTMLAttributes,e)]},renderText:()=>"\n",addCommands(){return{setHardBreak:()=>({commands:e,chain:t,state:n,editor:i})=>e.first([()=>e.exitCode(),()=>e.command(()=>{let{selection:e,storedMarks:r}=n;if(e.$from.parent.type.spec.isolating)return!1;let{keepMarks:o}=this.options,{splittableMarks:s}=i.extensionManager,a=r||e.$to.parentOffset&&e.$from.marks();return t().insertContent({type:this.name}).command(({tr:e,dispatch:t})=>{if(t&&a&&o){let t=a.filter(e=>s.includes(e.type.name));e.ensureMarks(t)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),j=i.NB.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map(e=>({tag:`h${e}`,attrs:{level:e}}))},renderHTML({node:e,HTMLAttributes:t}){let n=this.options.levels.includes(e.attrs.level)?e.attrs.level:this.options.levels[0];return[`h${n}`,(0,i.P1)(this.options.HTMLAttributes,t),0]},addCommands(){return{setHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.setNode(this.name,e),toggleHeading:e=>({commands:t})=>!!this.options.levels.includes(e.level)&&t.toggleNode(this.name,"paragraph",e)}},addKeyboardShortcuts(){return this.options.levels.reduce((e,t)=>({...e,[`Mod-Alt-${t}`]:()=>this.editor.commands.toggleHeading({level:t})}),{})},addInputRules(){return this.options.levels.map(e=>(0,i.zK)({find:RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),type:this.type,getAttributes:{level:e}}))}});var F=function(){};F.prototype.append=function(e){return e.length?(e=F.from(e),!this.length&&e||e.length<200&&this.leafAppend(e)||this.length<200&&e.leafPrepend(this)||this.appendInner(e)):this},F.prototype.prepend=function(e){return e.length?F.from(e).append(this):this},F.prototype.appendInner=function(e){return new z(this,e)},F.prototype.slice=function(e,t){return(void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t)?F.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},F.prototype.get=function(e){if(!(e<0)&&!(e>=this.length))return this.getInner(e)},F.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},F.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var i=[];return this.forEach(function(t,n){return i.push(e(t,n))},t,n),i},F.from=function(e){return e instanceof F?e:e&&e.length?new B(e):F.empty};var B=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,i){for(var r=t;r=n;r--)if(!1===e(this.values[r],i+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=200)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=200)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(F);F.empty=new B([]);var z=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return er&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,i+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,i){var r=this.left.length;if(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,i+r)||n=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(F);class H{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){let n,i,r,o;if(0==this.eventCount)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}t&&(i=(n=this.remapping(s,this.items.length)).maps.length);let a=e.tr,l=[],d=[];return this.items.forEach((e,t)=>{if(!e.step){!n&&(i=(n=this.remapping(s,t+1)).maps.length),i--,d.push(e);return}if(n){d.push(new V(e.map));let t=e.step.map(n.slice(i)),r;t&&a.maybeStep(t).doc&&(r=a.mapping.maps[a.mapping.maps.length-1],l.push(new V(r,void 0,void 0,l.length+d.length))),i--,r&&n.appendMap(r,i)}else a.maybeStep(e.step);if(e.selection)return r=n?e.selection.map(n.slice(i)):e.selection,o=new H(this.items.slice(0,s).append(d.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:o,transform:a,selection:r}}addTransform(e,t,n,i){let r=[],o=this.eventCount,s=this.items,a=!i&&s.length?s.get(s.length-1):null;for(let n=0;n$&&(s=function(e,t){let n;return e.forEach((e,i)=>{if(e.selection&&0==t--)return n=i,!1}),e.slice(n)}(s,l),o-=l),new H(s.append(r),o)}remapping(e,t){let n=new _.vs;return this.items.forEach((t,i)=>{let r=null!=t.mirrorOffset&&i-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)},e,t),n}addMaps(e){return 0==this.eventCount?this:new H(this.items.append(e.map(e=>new V(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),r=e.mapping,o=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let a=t;this.items.forEach(t=>{let i=r.getMirror(--a);if(null==i)return;o=Math.min(o,i);let l=r.maps[i];if(t.step){let o=e.steps[i].invert(e.docs[i]),d=t.selection&&t.selection.map(r.slice(a+1,i));d&&s++,n.push(new V(l,o,d))}else n.push(new V(l))},i);let l=[];for(let e=t;e500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{!t.step&&e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],r=0;return this.items.forEach((o,s)=>{if(s>=e)i.push(o),o.selection&&r++;else if(o.step){let e=o.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let a=o.selection&&o.selection.map(t.slice(n));a&&r++;let l=new V(s.invert(),e,a),d,c=i.length-1;(d=i.length&&i[c].merge(l))?i[c]=d:i.push(l)}}else o.map&&n--},this.items.length,0),new H(F.from(i.reverse()),r)}}H.empty=new H(F.empty,0);class V{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new V(t.getMap().invert(),t,this.selection)}}}class U{constructor(e,t,n,i,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=r}}let $=20;function W(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,i,r)=>t.push(i,r));return t}function q(e,t){if(!e)return null;let n=[];for(let i=0;i{let r=Y.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(i){let o=function(e,t,n){let i=Z(t),r=Y.get(t).spec.config,o=(n?e.undone:e.done).popEvent(t,i);if(!o)return null;let s=o.selection.resolve(o.transform.doc),a=(n?e.done:e.undone).addTransform(o.transform,t.selection.getBookmark(),r,i),l=new U(n?a:o.remaining,n?o.remaining:a,null,0,-1);return o.transform.setSelection(s).setMeta(Y,{redo:n,historyState:l})}(r,n,e);o&&i(t?o.scrollIntoView():o)}return!0}}let Q=J(!1,!0),ee=J(!0,!0);J(!1,!1),J(!0,!1);let et=i.hj.create({name:"history",addOptions:()=>({depth:100,newGroupDelay:500}),addCommands:()=>({undo:()=>({state:e,dispatch:t})=>Q(e,t),redo:()=>({state:e,dispatch:t})=>ee(e,t)}),addProseMirrorPlugins(){return[function(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new v.Sy({key:Y,state:{init:()=>new U(H.empty,H.empty,null,0,-1),apply:(t,n,i)=>(function(e,t,n,i){let r=n.getMeta(Y),o;if(r)return r.historyState;n.getMeta(X)&&(e=new U(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Y))return s.getMeta(Y).redo?new U(e.done.addTransform(n,void 0,i,Z(t)),e.undone,W(n.mapping.maps),e.prevTime,e.prevComposition):new U(e.done,e.undone.addTransform(n,void 0,i,Z(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory")){if(o=n.getMeta("rebased"))return new U(e.done.rebased(n,o),e.undone.rebased(n,o),q(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new U(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),q(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}else{let r=n.getMeta("composition"),o=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-i.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,i)=>{for(let r=0;r=t[r]&&(n=!0)}),n}(n,e.prevRanges)),a=s?q(e.prevRanges,n.mapping):W(n.mapping.maps);return new U(e.done.addTransform(n,o?t.selection.getBookmark():void 0,i,Z(t)),H.empty,a,n.time,null==r?e.prevComposition:r)}})(n,i,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i="historyUndo"==n?Q:"historyRedo"==n?ee:null;return!!i&&(t.preventDefault(),i(e.state,e.dispatch))}}}})}(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),en=i.NB.create({name:"horizontalRule",addOptions:()=>({HTMLAttributes:{}}),group:"block",parseHTML:()=>[{tag:"hr"}],renderHTML({HTMLAttributes:e}){return["hr",(0,i.P1)(this.options.HTMLAttributes,e)]},addCommands(){return{setHorizontalRule:()=>({chain:e,state:t})=>{let{selection:n}=t,{$from:r,$to:o}=n,s=e();return 0===r.parentOffset?s.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):(0,i.EG)(n)?s.insertContentAt(o.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:e,dispatch:t})=>{var n;if(t){let{$to:t}=e.selection,i=t.end();if(t.nodeAfter)t.nodeAfter.isTextblock?e.setSelection(v.Bs.create(e.doc,t.pos+1)):t.nodeAfter.isBlock?e.setSelection(v.qv.create(e.doc,t.pos)):e.setSelection(v.Bs.create(e.doc,t.pos));else{let r=null===(n=t.parent.type.contentMatch.defaultType)||void 0===n?void 0:n.create();r&&(e.insert(i,r),e.setSelection(v.Bs.create(e.doc,i+1)))}e.scrollIntoView()}return!0}).run()}}},addInputRules(){return[(0,i.x2)({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),ei=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,er=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,eo=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,es=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ea=i.vc.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:e=>"normal"!==e.style.fontStyle&&null},{style:"font-style=normal",clearMark:e=>e.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:e}){return["em",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setItalic:()=>({commands:e})=>e.setMark(this.name),toggleItalic:()=>({commands:e})=>e.toggleMark(this.name),unsetItalic:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[(0,i.Cf)({find:ei,type:this.type}),(0,i.Cf)({find:eo,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:er,type:this.type}),(0,i.K9)({find:es,type:this.type})]}}),el=i.NB.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:e}){return["li",(0,i.P1)(this.options.HTMLAttributes,e),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ed="textStyle",ec=/^(\d+)\.\s$/,eh=i.NB.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:e=>e.hasAttribute("start")?parseInt(e.getAttribute("start")||"",10):1},type:{default:null,parseHTML:e=>e.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:e}){let{start:t,...n}=e;return 1===t?["ol",(0,i.P1)(this.options.HTMLAttributes,n),0]:["ol",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{toggleOrderedList:()=>({commands:e,chain:t})=>this.options.keepAttributes?t().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes("listItem",this.editor.getAttributes(ed)).run():e.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let e=(0,i.S0)({find:ec,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(e=(0,i.S0)({find:ec,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ed)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[e]}}),eu=i.NB.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:e}){return["p",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setParagraph:()=>({commands:e})=>e.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),ep=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,ef=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,em=i.vc.create({name:"strike",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:e=>!!e.includes("line-through")&&{}}],renderHTML({HTMLAttributes:e}){return["s",(0,i.P1)(this.options.HTMLAttributes,e),0]},addCommands(){return{setStrike:()=>({commands:e})=>e.setMark(this.name),toggleStrike:()=>({commands:e})=>e.toggleMark(this.name),unsetStrike:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[(0,i.Cf)({find:ep,type:this.type})]},addPasteRules(){return[(0,i.K9)({find:ef,type:this.type})]}}),eg=i.NB.create({name:"text",group:"inline"}),ev=i.hj.create({name:"starterKit",addExtensions(){let e=[];return!1!==this.options.bold&&e.push(c.configure(this.options.bold)),!1!==this.options.blockquote&&e.push(o.configure(this.options.blockquote)),!1!==this.options.bulletList&&e.push(p.configure(this.options.bulletList)),!1!==this.options.code&&e.push(g.configure(this.options.code)),!1!==this.options.codeBlock&&e.push(x.configure(this.options.codeBlock)),!1!==this.options.document&&e.push(w.configure(this.options.document)),!1!==this.options.dropcursor&&e.push(C.configure(this.options.dropcursor)),!1!==this.options.gapcursor&&e.push(R.configure(this.options.gapcursor)),!1!==this.options.hardBreak&&e.push(L.configure(this.options.hardBreak)),!1!==this.options.heading&&e.push(j.configure(this.options.heading)),!1!==this.options.history&&e.push(et.configure(this.options.history)),!1!==this.options.horizontalRule&&e.push(en.configure(this.options.horizontalRule)),!1!==this.options.italic&&e.push(ea.configure(this.options.italic)),!1!==this.options.listItem&&e.push(el.configure(this.options.listItem)),!1!==this.options.orderedList&&e.push(eh.configure(this.options.orderedList)),!1!==this.options.paragraph&&e.push(eu.configure(this.options.paragraph)),!1!==this.options.strike&&e.push(em.configure(this.options.strike)),!1!==this.options.text&&e.push(eg.configure(this.options.text)),e}})},734083:function(e,t,n){n.d(t,{J:function(){return o}});var i=Object.prototype.hasOwnProperty;function r(e,t,n){for(n of e.keys())if(o(n,t))return n}function o(e,t){var n,s,a;if(e===t)return!0;if(e&&t&&(n=e.constructor)===t.constructor){if(n===Date)return e.getTime()===t.getTime();if(n===RegExp)return e.toString()===t.toString();if(n===Array){if((s=e.length)===t.length)for(;s--&&o(e[s],t[s]););return -1===s}if(n===Set){if(e.size!==t.size)return!1;for(s of e)if((a=s)&&"object"==typeof a&&!(a=r(t,a))||!t.has(a))return!1;return!0}if(n===Map){if(e.size!==t.size)return!1;for(s of e)if((a=s[0])&&"object"==typeof a&&!(a=r(t,a))||!o(s[1],t.get(a)))return!1;return!0}if(n===ArrayBuffer)e=new Uint8Array(e),t=new Uint8Array(t);else if(n===DataView){if((s=e.byteLength)===t.byteLength)for(;s--&&e.getInt8(s)===t.getInt8(s););return -1===s}if(ArrayBuffer.isView(e)){if((s=e.byteLength)===t.byteLength)for(;s--&&e[s]===t[s];);return -1===s}if(!n||"object"==typeof e){for(n in s=0,e)if(i.call(e,n)&&++s&&!i.call(t,n)||!(n in t)||!o(e[n],t[n]))return!1;return Object.keys(t).length===s}}return e!=e&&t!=t}},59160:function(e,t,n){n.d(t,{Z:function(){return i}});function i(e){var t=!1;return{promise:new Promise(function(n,i){e.then(function(e){return!t&&n(e)}).catch(function(e){return!t&&i(e)})}),cancel:function(){t=!0}}}},213898:function(e,t,n){n.d(t,{ZP:function(){return o}});var i=function(e,t,n){if(n||2==arguments.length)for(var i,r=0,o=t.length;r{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var o=globalThis.pdfjsLib={};r.d(o,{AbortException:()=>L,AnnotationEditorLayer:()=>nH,AnnotationEditorParamsType:()=>u,AnnotationEditorType:()=>h,AnnotationEditorUIManager:()=>eM,AnnotationLayer:()=>nM,AnnotationMode:()=>c,CMapCompressionType:()=>y,ColorPicker:()=>nj,DOMSVGFactory:()=>er,DrawLayer:()=>nV,FeatureTest:()=>z,GlobalWorkerOptions:()=>tt,ImageKind:()=>m,InvalidPDFException:()=>I,MissingPDFException:()=>N,OPS:()=>x,Outliner:()=>nI,PDFDataRangeTransport:()=>tG,PDFDateString:()=>em,PDFWorker:()=>tJ,PasswordResponses:()=>w,PermissionFlag:()=>p,PixelsPerInch:()=>ee,RenderingCancelledException:()=>es,TextLayer:()=>tL,UnexpectedResponseException:()=>P,Util:()=>V,VerbosityLevel:()=>b,XfaLayer:()=>t9,build:()=>t4,createValidAbsoluteUrl:()=>k,fetchData:()=>et,getDocument:()=>t$,getFilenameFromUrl:()=>ed,getPdfFilenameFromUrl:()=>ec,getXfaPageViewport:()=>eg,isDataScheme:()=>ea,isPdfFile:()=>el,noContextMenu:()=>ep,normalizeUnicode:()=>W,renderTextLayer:()=>tj,setLayerDimensions:()=>ex,shadow:()=>T,updateTextLayer:()=>tF,version:()=>t3});let s="object"==typeof process&&process+""=="[object process]"&&!process.versions.nw&&!(process.versions.electron&&process.type&&"browser"!==process.type),a=[1,0,0,1,0,0],l=[.001,0,0,.001,0,0],d={ANY:1,DISPLAY:2,PRINT:4,ANNOTATIONS_FORMS:16,ANNOTATIONS_STORAGE:32,ANNOTATIONS_DISABLE:64,OPLIST:256},c={DISABLE:0,ENABLE:1,ENABLE_FORMS:2,ENABLE_STORAGE:3},h={DISABLE:-1,NONE:0,FREETEXT:3,HIGHLIGHT:9,STAMP:13,INK:15},u={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},p={PRINT:4,MODIFY_CONTENTS:8,COPY:16,MODIFY_ANNOTATIONS:32,FILL_INTERACTIVE_FORMS:256,COPY_FOR_ACCESSIBILITY:512,ASSEMBLE:1024,PRINT_HIGH_QUALITY:2048},f={FILL:0,STROKE:1,FILL_STROKE:2,INVISIBLE:3,FILL_STROKE_MASK:3,ADD_TO_PATH_FLAG:4},m={GRAYSCALE_1BPP:1,RGB_24BPP:2,RGBA_32BPP:3},g={TEXT:1,LINK:2,FREETEXT:3,LINE:4,SQUARE:5,CIRCLE:6,POLYGON:7,POLYLINE:8,HIGHLIGHT:9,UNDERLINE:10,SQUIGGLY:11,STRIKEOUT:12,STAMP:13,CARET:14,INK:15,POPUP:16,FILEATTACHMENT:17,WIDGET:20},v={SOLID:1,DASHED:2,BEVELED:3,INSET:4,UNDERLINE:5},b={ERRORS:0,WARNINGS:1,INFOS:5},y={NONE:0,BINARY:1},x={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},w={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},_=b.WARNINGS;function S(e){_>=b.INFOS&&console.log(`Info: ${e}`)}function C(e){_>=b.WARNINGS&&console.log(`Warning: ${e}`)}function A(e){throw Error(e)}function E(e,t){!e&&A(t)}function k(e,t=null,n=null){if(!e)return null;try{if(n&&"string"==typeof e){if(n.addDefaultProtocol&&e.startsWith("www.")){let t=e.match(/\./g);t?.length>=2&&(e=`http://${e}`)}if(n.tryConvertEncoding)try{e=function(e){return decodeURIComponent(escape(e))}(e)}catch{}}let i=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}}(i))return i}catch{}return null}function T(e,t,n,i=!1){return Object.defineProperty(e,t,{value:n,enumerable:!i,configurable:!0,writable:!1}),n}let M=function(){function e(t,n){this.constructor===e&&A("Cannot initialize BaseException."),this.message=t,this.name=n}return e.prototype=Error(),e.constructor=e,e}();class D extends M{constructor(e,t){super(e,"PasswordException"),this.code=t}}class O extends M{constructor(e,t){super(e,"UnknownErrorException"),this.details=t}}class I extends M{constructor(e){super(e,"InvalidPDFException")}}class N extends M{constructor(e){super(e,"MissingPDFException")}}class P extends M{constructor(e,t){super(e,"UnexpectedResponseException"),this.status=t}}class R extends M{constructor(e){super(e,"FormatError")}}class L extends M{constructor(e){super(e,"AbortException")}}function j(e){("object"!=typeof e||e?.length===void 0)&&A("Invalid argument for bytesToString");let t=e.length;if(t<8192)return String.fromCharCode.apply(null,e);let n=[];for(let i=0;ie.toString(16).padStart(2,"0"));class V{static makeHexColor(e,t,n){return`#${H[e]}${H[t]}${H[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){let n=e[0]*t[0]+e[1]*t[2]+t[4];return[n,e[0]*t[1]+e[1]*t[3]+t[5]]}static applyInverseTransform(e,t){let n=t[0]*t[3]-t[1]*t[2],i=(e[0]*t[3]-e[1]*t[2]+t[2]*t[5]-t[4]*t[3])/n;return[i,(-e[0]*t[1]+e[1]*t[0]+t[4]*t[1]-t[5]*t[0])/n]}static getAxialAlignedBoundingBox(e,t){let n=this.applyTransform(e,t),i=this.applyTransform(e.slice(2,4),t),r=this.applyTransform([e[0],e[3]],t),o=this.applyTransform([e[2],e[1]],t);return[Math.min(n[0],i[0],r[0],o[0]),Math.min(n[1],i[1],r[1],o[1]),Math.max(n[0],i[0],r[0],o[0]),Math.max(n[1],i[1],r[1],o[1])]}static inverseTransform(e){let 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){let t=[e[0],e[2],e[1],e[3]],n=e[0]*t[0]+e[1]*t[2],i=e[0]*t[1]+e[1]*t[3],r=e[2]*t[0]+e[3]*t[2],o=e[2]*t[1]+e[3]*t[3],s=(n+o)/2,a=Math.sqrt((n+o)**2-4*(n*o-r*i))/2;return[Math.sqrt(s+a||1),Math.sqrt(s-a||1)]}static normalizeRect(e){let 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){let n=Math.max(Math.min(e[0],e[2]),Math.min(t[0],t[2])),i=Math.min(Math.max(e[0],e[2]),Math.max(t[0],t[2]));if(n>i)return null;let r=Math.max(Math.min(e[1],e[3]),Math.min(t[1],t[3])),o=Math.min(Math.max(e[1],e[3]),Math.max(t[1],t[3]));return r>o?null:[n,r,i,o]}static #e(e,t,n,i,r,o,s,a,l,d){if(l<=0||l>=1)return;let c=1-l,h=l*l,u=h*l,p=c*(c*(c*e+3*l*t)+3*h*n)+u*i,f=c*(c*(c*r+3*l*o)+3*h*s)+u*a;d[0]=Math.min(d[0],p),d[1]=Math.min(d[1],f),d[2]=Math.max(d[2],p),d[3]=Math.max(d[3],f)}static #t(e,t,n,i,r,o,s,a,l,d,c,h){if(1e-12>Math.abs(l)){Math.abs(d)>=1e-12&&this.#e(e,t,n,i,r,o,s,a,-c/d,h);return}let u=d**2-4*c*l;if(u<0)return;let p=Math.sqrt(u),f=2*l;this.#e(e,t,n,i,r,o,s,a,(-d+p)/f,h),this.#e(e,t,n,i,r,o,s,a,(-d-p)/f,h)}static bezierBoundingBox(e,t,n,i,r,o,s,a,l){return l?(l[0]=Math.min(l[0],e,s),l[1]=Math.min(l[1],t,a),l[2]=Math.max(l[2],e,s),l[3]=Math.max(l[3],t,a)):l=[Math.min(e,s),Math.min(t,a),Math.max(e,s),Math.max(t,a)],this.#t(e,n,r,s,t,i,o,a,3*(-e+3*(n-r)+s),6*(e-2*n+r),3*(n-e),l),this.#t(e,n,r,s,t,i,o,a,3*(-t+3*(i-o)+a),6*(t-2*i+o),3*(i-t),l),l}}let U=null,$=null;function W(e){return!U&&(U=/([\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,$=new Map([["ſt","ſt"]])),e.replaceAll(U,(e,t,n)=>t?t.normalize("NFKC"):$.get(n))}let q="pdfjs_internal_id_",G={BEZIER_CURVE_TO:0,MOVE_TO:1,LINE_TO:2,QUADRATIC_CURVE_TO:3,RESTORE:4,SAVE:5,SCALE:6,TRANSFORM:7,TRANSLATE:8};class K{constructor(){this.constructor===K&&A("Cannot initialize BaseFilterFactory.")}addFilter(e){return"none"}addHCMFilter(e,t){return"none"}addAlphaFilter(e){return"none"}addLuminosityFilter(e){return"none"}addHighlightHCMFilter(e,t,n,i,r){return"none"}destroy(e=!1){}}class Z{#n=!1;constructor({enableHWA:e=!1}={}){this.constructor===Z&&A("Cannot initialize BaseCanvasFactory."),this.#n=e}create(e,t){if(e<=0||t<=0)throw Error("Invalid canvas size");let n=this._createCanvas(e,t);return{canvas:n,context:n.getContext("2d",{willReadFrequently:!this.#n})}}reset(e,t,n){if(!e.canvas)throw Error("Canvas is not specified");if(t<=0||n<=0)throw Error("Invalid canvas size");e.canvas.width=t,e.canvas.height=n}destroy(e){if(!e.canvas)throw Error("Canvas is not specified");e.canvas.width=0,e.canvas.height=0,e.canvas=null,e.context=null}_createCanvas(e,t){A("Abstract method `_createCanvas` called.")}}class Y{constructor({baseUrl:e=null,isCompressed:t=!0}){this.constructor===Y&&A("Cannot initialize BaseCMapReaderFactory."),this.baseUrl=e,this.isCompressed=t}async fetch({name:e}){if(!this.baseUrl)throw Error('The CMap "baseUrl" parameter must be specified, ensure that the "cMapUrl" and "cMapPacked" API parameters are provided.');if(!e)throw Error("CMap name must be specified.");let t=this.baseUrl+e+(this.isCompressed?".bcmap":""),n=this.isCompressed?y.BINARY:y.NONE;return this._fetchData(t,n).catch(e=>{throw Error(`Unable to load ${this.isCompressed?"binary ":""}CMap at: ${t}`)})}_fetchData(e,t){A("Abstract method `_fetchData` called.")}}class X{constructor({baseUrl:e=null}){this.constructor===X&&A("Cannot initialize BaseStandardFontDataFactory."),this.baseUrl=e}async fetch({filename:e}){if(!this.baseUrl)throw Error('The standard font "baseUrl" parameter must be specified, ensure that the "standardFontDataUrl" API parameter is provided.');if(!e)throw Error("Font filename must be specified.");let t=`${this.baseUrl}${e}`;return this._fetchData(t).catch(e=>{throw Error(`Unable to load font data at: ${t}`)})}_fetchData(e){A("Abstract method `_fetchData` called.")}}class J{constructor(){this.constructor===J&&A("Cannot initialize BaseSVGFactory.")}create(e,t,n=!1){if(e<=0||t<=0)throw Error("Invalid SVG dimensions");let i=this._createSVG("svg:svg");return i.setAttribute("version","1.1"),!n&&(i.setAttribute("width",`${e}px`),i.setAttribute("height",`${t}px`)),i.setAttribute("preserveAspectRatio","none"),i.setAttribute("viewBox",`0 0 ${e} ${t}`),i}createElement(e){if("string"!=typeof e)throw Error("Invalid SVG element type");return this._createSVG(e)}_createSVG(e){A("Abstract method `_createSVG` called.")}}let Q="http://www.w3.org/2000/svg";class ee{static CSS=96;static PDF=72;static PDF_TO_CSS_UNITS=this.CSS/this.PDF}async function et(e,t="text"){if(eu(e,document.baseURI)){let n=await fetch(e);if(!n.ok)throw 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,i)=>{let r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType=t,r.onreadystatechange=()=>{if(r.readyState===XMLHttpRequest.DONE){if(200===r.status||0===r.status){switch(t){case"arraybuffer":case"blob":case"json":n(r.response);return}n(r.responseText);return}i(Error(r.statusText))}},r.send(null)})}class en extends Y{_fetchData(e,t){return et(e,this.isCompressed?"arraybuffer":"text").then(e=>({cMapData:e instanceof ArrayBuffer?new Uint8Array(e):F(e),compressionType:t}))}}class ei extends X{_fetchData(e){return et(e,"arraybuffer").then(e=>new Uint8Array(e))}}class er extends J{_createSVG(e){return document.createElementNS(Q,e)}}class eo{constructor({viewBox:e,scale:t,rotation:n,offsetX:i=0,offsetY:r=0,dontFlip:o=!1}){let s,a,l,d,c,h,u,p;this.viewBox=e,this.scale=t,this.rotation=n,this.offsetX=i,this.offsetY=r;let f=(e[2]+e[0])/2,m=(e[3]+e[1])/2;switch((n%=360)<0&&(n+=360),n){case 180:s=-1,a=0,l=0,d=1;break;case 90:s=0,a=1,l=1,d=0;break;case 270:s=0,a=-1,l=-1,d=0;break;case 0:s=1,a=0,l=0,d=-1;break;default:throw Error("PageViewport: Invalid rotation, must be a multiple of 90 degrees.")}o&&(l=-l,d=-d),0===s?(c=Math.abs(m-e[1])*t+i,h=Math.abs(f-e[0])*t+r,u=(e[3]-e[1])*t,p=(e[2]-e[0])*t):(c=Math.abs(f-e[0])*t+i,h=Math.abs(m-e[1])*t+r,u=(e[2]-e[0])*t,p=(e[3]-e[1])*t),this.transform=[s*t,a*t,l*t,d*t,c-s*t*f-l*t*m,h-a*t*f-d*t*m],this.width=u,this.height=p}get rawDims(){let{viewBox:e}=this;return T(this,"rawDims",{pageWidth:e[2]-e[0],pageHeight:e[3]-e[1],pageX:e[0],pageY:e[1]})}clone({scale:e=this.scale,rotation:t=this.rotation,offsetX:n=this.offsetX,offsetY:i=this.offsetY,dontFlip:r=!1}={}){return new eo({viewBox:this.viewBox.slice(),scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}convertToViewportPoint(e,t){return V.applyTransform([e,t],this.transform)}convertToViewportRectangle(e){let t=V.applyTransform([e[0],e[1]],this.transform),n=V.applyTransform([e[2],e[3]],this.transform);return[t[0],t[1],n[0],n[1]]}convertToPdfPoint(e,t){return V.applyInverseTransform([e,t],this.transform)}}class es extends M{constructor(e,t=0){super(e,"RenderingCancelledException"),this.extraDelay=t}}function ea(e){let t=e.length,n=0;for(;n=1&&r<=12?r-1:0;let o=parseInt(t[3],10);o=o>=1&&o<=31?o:1;let s=parseInt(t[4],10);s=s>=0&&s<=23?s:0;let a=parseInt(t[5],10);a=a>=0&&a<=59?a:0;let l=parseInt(t[6],10);l=l>=0&&l<=59?l:0;let d=t[7]||"Z",c=parseInt(t[8],10);c=c>=0&&c<=23?c:0;let h=parseInt(t[9],10)||0;return h=h>=0&&h<=59?h:0,"-"===d?(s+=c,a+=h):"+"===d&&(s-=c,a-=h),new Date(Date.UTC(n,r,o,s,a,l))}}function eg(e,{scale:t=1,rotation:n=0}){let{width:i,height:r}=e.attributes.style;return new eo({viewBox:[0,0,parseInt(i),parseInt(r)],scale:t,rotation:n})}function ev(e){if(e.startsWith("#")){let t=parseInt(e.slice(1),16);return[(0xff0000&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):(C(`Not a valid color format: "${e}"`),[0,0,0])}function eb(e){let{a:t,b:n,c:i,d:r,e:o,f:s}=e.getTransform();return[t,n,i,r,o,s]}function ey(e){let{a:t,b:n,c:i,d:r,e:o,f:s}=e.getTransform().invertSelf();return[t,n,i,r,o,s]}function ex(e,t,n=!1,i=!0){if(t instanceof eo){let{pageWidth:i,pageHeight:r}=t.rawDims,{style:o}=e,s=z.isCSSRoundSupported,a=`var(--scale-factor) * ${i}px`,l=`var(--scale-factor) * ${r}px`,d=s?`round(${a}, 1px)`:`calc(${a})`,c=s?`round(${l}, 1px)`:`calc(${l})`;n&&t.rotation%180!=0?(o.width=c,o.height=d):(o.width=d,o.height=c)}i&&e.setAttribute("data-main-rotation",t.rotation)}class ew{#i=null;#r=null;#o;#s=null;constructor(e){this.#o=e}render(){let e=this.#i=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar");let t=this.#o._uiManager._signal;e.addEventListener("contextmenu",ep,{signal:t}),e.addEventListener("pointerdown",ew.#a,{signal:t});let n=this.#s=document.createElement("div");n.className="buttons",e.append(n);let i=this.#o.toolbarPosition;if(i){let{style:t}=e,n="ltr"===this.#o._uiManager.direction?1-i[0]:i[0];t.insetInlineEnd=`${100*n}%`,t.top=`calc(${100*i[1]}% + var(--editor-toolbar-vert-offset))`}return this.#l(),e}static #a(e){e.stopPropagation()}#d(e){this.#o._focusEventsAllowed=!1,e.preventDefault(),e.stopPropagation()}#c(e){this.#o._focusEventsAllowed=!0,e.preventDefault(),e.stopPropagation()}#h(e){let t=this.#o._uiManager._signal;e.addEventListener("focusin",this.#d.bind(this),{capture:!0,signal:t}),e.addEventListener("focusout",this.#c.bind(this),{capture:!0,signal:t}),e.addEventListener("contextmenu",ep,{signal:t})}hide(){this.#i.classList.add("hidden"),this.#r?.hideDropdown()}show(){this.#i.classList.remove("hidden")}#l(){let e=document.createElement("button");e.className="delete",e.tabIndex=0,e.setAttribute("data-l10n-id",`pdfjs-editor-remove-${this.#o.editorType}-button`),this.#h(e),e.addEventListener("click",e=>{this.#o._uiManager.delete()},{signal:this.#o._uiManager._signal}),this.#s.append(e)}get #u(){let e=document.createElement("div");return e.className="divider",e}addAltTextButton(e){this.#h(e),this.#s.prepend(e,this.#u)}addColorPicker(e){this.#r=e;let t=e.renderButton();this.#h(t),this.#s.prepend(t,this.#u)}remove(){this.#i.remove(),this.#r?.destroy(),this.#r=null}}class e_{#s=null;#i=null;#p;constructor(e){this.#p=e}#f(){let e=this.#i=document.createElement("div");e.className="editToolbar",e.setAttribute("role","toolbar"),e.addEventListener("contextmenu",ep,{signal:this.#p._signal});let t=this.#s=document.createElement("div");return t.className="buttons",e.append(t),this.#m(),e}#g(e,t){let n=0,i=0;for(let r of e){let e=r.y+r.height;if(en){i=o,n=e;continue}t?o>i&&(i=o):o{this.#p.highlightSelection("floating_button")},{signal:n}),this.#s.append(e)}}function eS(e,t,n){for(let i of n)t.addEventListener(i,e[i].bind(e))}class eC{#v=0;get id(){return`pdfjs_internal_editor_${this.#v++}`}}class eA{#b=(function(){if("undefined"!=typeof crypto&&"function"==typeof crypto?.randomUUID)return crypto.randomUUID();let e=new Uint8Array(32);if("undefined"!=typeof crypto&&"function"==typeof crypto?.getRandomValues)crypto.getRandomValues(e);else for(let t=0;t<32;t++)e[t]=Math.floor(255*Math.random());return j(e)})();#v=0;#y=null;static get _isSVGFittingCanvas(){let e=new OffscreenCanvas(1,3).getContext("2d",{willReadFrequently:!0}),t=new Image;return t.src='data:image/svg+xml;charset=UTF-8,',T(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 #x(e,t){this.#y||=new Map;let n=this.#y.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.#b}_${this.#v++}`,refCounter:0,isSvg:!1},"string"==typeof t?(n.url=t,e=await et(t,"blob")):e=n.file=t,"image/svg+xml"===e.type){let t=eA._isSVGFittingCanvas,i=new FileReader,r=new Image,o=new Promise((e,o)=>{r.onload=()=>{n.bitmap=r,n.isSvg=!0,e()},i.onload=async()=>{let e=n.svgUrl=i.result;r.src=await t?`${e}#svgView(preserveAspectRatio(none))`:e},r.onerror=i.onerror=o});i.readAsDataURL(e),await o}else n.bitmap=await createImageBitmap(e);n.refCounter=1}catch(e){console.error(e),n=null}return this.#y.set(e,n),n&&this.#y.set(n.id,n),n}async getFromFile(e){let{lastModified:t,name:n,size:i,type:r}=e;return this.#x(`${t}_${n}_${i}_${r}`,e)}async getFromUrl(e){return this.#x(e,e)}async getFromId(e){this.#y||=new Map;let t=this.#y.get(e);return t?t.bitmap?(t.refCounter+=1,t):t.file?this.getFromFile(t.file):this.getFromUrl(t.url):null}getSvgUrl(e){let t=this.#y.get(e);return t?.isSvg?t.svgUrl:null}deleteId(e){this.#y||=new Map;let t=this.#y.get(e);if(!t)return;if(t.refCounter-=1,0===t.refCounter)t.bitmap=null}isValidId(e){return e.startsWith(`image_${this.#b}_`)}}class eE{#w=[];#_=!1;#S;#C=-1;constructor(e=128){this.#S=e}add({cmd:e,undo:t,post:n,mustExec:i,type:r=NaN,overwriteIfSameType:o=!1,keepUndo:s=!1}){if(i&&e(),this.#_)return;let a={cmd:e,undo:t,post:n,type:r};if(-1===this.#C){this.#w.length>0&&(this.#w.length=0),this.#C=0,this.#w.push(a);return}if(o&&this.#w[this.#C].type===r){s&&(a.undo=this.#w[this.#C].undo),this.#w[this.#C]=a;return}let l=this.#C+1;l===this.#S?this.#w.splice(0,1):(this.#C=l,le===t[n]))return eT._colorsMapping.get(e);return t}getHexCode(e){let t=this._colors.get(e);return t?V.makeHexColor(...t):e}}class eM{#E=new AbortController;#k=null;#T=new Map;#M=new Map;#D=null;#O=null;#I=null;#N=new eE;#P=0;#R=new Set;#L=null;#j=null;#F=new Set;#B=!1;#z=null;#H=null;#V=null;#U=!1;#$=null;#W=new eC;#q=!1;#G=!1;#K=null;#Z=null;#Y=null;#X=h.NONE;#J=new Set;#Q=null;#ee=null;#et=null;#en=this.blur.bind(this);#ei=this.focus.bind(this);#er=this.copy.bind(this);#eo=this.cut.bind(this);#es=this.paste.bind(this);#ea=this.keydown.bind(this);#el=this.keyup.bind(this);#ed=this.onEditingAction.bind(this);#ec=this.onPageChanging.bind(this);#eh=this.onScaleChanging.bind(this);#eu=this.onRotationChanging.bind(this);#ep={isEditing:!1,isEmpty:!0,hasSomethingToUndo:!1,hasSomethingToRedo:!1,hasSelectedEditor:!1,hasSelectedText:!1};#ef=[0,0];#em=null;#eg=null;#ev=null;static TRANSLATE_SMALL=1;static TRANSLATE_BIG=10;static get _keyboardManager(){let e=eM.prototype,t=e=>e.#eg.contains(document.activeElement)&&"BUTTON"!==document.activeElement.tagName&&e.hasSomethingToControl(),n=(e,{target:t})=>{if(t instanceof HTMLInputElement){let{type:e}=t;return"text"!==e&&"number"!==e}return!0},i=this.TRANSLATE_SMALL,r=this.TRANSLATE_BIG;return T(this,"_keyboardManager",new ek([[["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.#eg.contains(t)&&!e.isEnterHandled}],[[" ","mac+ "],e.addNewEditorFromKeyboard,{checker:(e,{target:t})=>!(t instanceof HTMLButtonElement)&&e.#eg.contains(document.activeElement)}],[["Escape","mac+Escape"],e.unselectAll],[["ArrowLeft","mac+ArrowLeft"],e.translateSelectedEditors,{args:[-i,0],checker:t}],[["ctrl+ArrowLeft","mac+shift+ArrowLeft"],e.translateSelectedEditors,{args:[-r,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e.translateSelectedEditors,{args:[i,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e.translateSelectedEditors,{args:[r,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e.translateSelectedEditors,{args:[0,-i],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e.translateSelectedEditors,{args:[0,-r],checker:t}],[["ArrowDown","mac+ArrowDown"],e.translateSelectedEditors,{args:[0,i],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e.translateSelectedEditors,{args:[0,r],checker:t}]]))}constructor(e,t,n,i,r,o,s,a,l){this._signal=this.#E.signal,this.#eg=e,this.#ev=t,this.#D=n,this._eventBus=i,this._eventBus._on("editingaction",this.#ed),this._eventBus._on("pagechanging",this.#ec),this._eventBus._on("scalechanging",this.#eh),this._eventBus._on("rotationchanging",this.#eu),this.#eb(),this.#ey(),this.#ex(),this.#O=r.annotationStorage,this.#z=r.filterFactory,this.#ee=o,this.#V=s||null,this.#B=a,this.#Y=l||null,this.viewParameters={realScale:ee.PDF_TO_CSS_UNITS,rotation:0},this.isShiftKeyDown=!1}destroy(){for(let e of(this.#E?.abort(),this.#E=null,this._signal=null,this._eventBus._off("editingaction",this.#ed),this._eventBus._off("pagechanging",this.#ec),this._eventBus._off("scalechanging",this.#eh),this._eventBus._off("rotationchanging",this.#eu),this.#M.values()))e.destroy();this.#M.clear(),this.#T.clear(),this.#F.clear(),this.#k=null,this.#J.clear(),this.#N.destroy(),this.#D?.destroy(),this.#$?.hide(),this.#$=null,this.#H&&(clearTimeout(this.#H),this.#H=null),this.#em&&(clearTimeout(this.#em),this.#em=null)}async mlGuess(e){return this.#Y?.guess(e)||null}get hasMLManager(){return!!this.#Y}get hcmFilter(){return T(this,"hcmFilter",this.#ee?this.#z.addHCMFilter(this.#ee.foreground,this.#ee.background):"none")}get direction(){return T(this,"direction",getComputedStyle(this.#eg).direction)}get highlightColors(){return T(this,"highlightColors",this.#V?new Map(this.#V.split(",").map(e=>e.split("=").map(e=>e.trim()))):null)}get highlightColorNames(){return T(this,"highlightColorNames",this.highlightColors?new Map(Array.from(this.highlightColors,e=>e.reverse())):null)}setMainHighlightColorPicker(e){this.#Z=e}editAltText(e){this.#D?.editAltText(this,e)}onPageChanging({pageNumber:e}){this.#P=e-1}focusMainContainer(){this.#eg.focus()}findParent(e,t){for(let n of this.#M.values()){let{x:i,y:r,width:o,height:s}=n.div.getBoundingClientRect();if(e>=i&&e<=i+o&&t>=r&&t<=r+s)return n}return null}disableUserSelect(e=!1){this.#ev.classList.toggle("noUserSelect",e)}addShouldRescale(e){this.#F.add(e)}removeShouldRescale(e){this.#F.delete(e)}onScaleChanging({scale:e}){for(let t of(this.commitOrRemove(),this.viewParameters.realScale=e*ee.PDF_TO_CSS_UNITS,this.#F))t.onScaleChanging()}onRotationChanging({pagesRotation:e}){this.commitOrRemove(),this.viewParameters.rotation=e}#ew({anchorNode:e}){return e.nodeType===Node.TEXT_NODE?e.parentElement:e}highlightSelection(e=""){let t=document.getSelection();if(!t||t.isCollapsed)return;let{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}=t,s=t.toString(),a=this.#ew(t).closest(".textLayer"),l=this.getSelectionBoxes(a);if(!!l){for(let d of(t.empty(),this.#X===h.NONE&&(this._eventBus.dispatch("showannotationeditorui",{source:this,mode:h.HIGHLIGHT}),this.showAllEditors("highlight",!0,!0)),this.#M.values()))if(d.hasTextLayer(a)){d.createAndAddNewEditor({x:0,y:0},!1,{methodOfCreation:e,boxes:l,anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o,text:s});break}}}#e_(){let e=document.getSelection();if(!e||e.isCollapsed)return;let t=this.#ew(e).closest(".textLayer"),n=this.getSelectionBoxes(t);if(!!n)this.#$||=new e_(this),this.#$.show(t,n,"ltr"===this.direction)}addToAnnotationStorage(e){!e.isEmpty()&&this.#O&&!this.#O.has(e.id)&&this.#O.setValue(e.id,e)}#eS(){let e=document.getSelection();if(!e||e.isCollapsed){this.#Q&&(this.#$?.hide(),this.#Q=null,this.#eC({hasSelectedText:!1}));return}let{anchorNode:t}=e;if(t===this.#Q)return;if(!this.#ew(e).closest(".textLayer")){this.#Q&&(this.#$?.hide(),this.#Q=null,this.#eC({hasSelectedText:!1}));return}if(this.#$?.hide(),this.#Q=t,this.#eC({hasSelectedText:!0}),this.#X===h.HIGHLIGHT||this.#X===h.NONE){if(this.#X===h.HIGHLIGHT&&this.showAllEditors("highlight",!0,!0),this.#U=this.isShiftKeyDown,!this.isShiftKeyDown){let e=this._signal,t=e=>{if("pointerup"!==e.type||0===e.button)window.removeEventListener("pointerup",t),window.removeEventListener("blur",t),"pointerup"===e.type&&this.#eA("main_toolbar")};window.addEventListener("pointerup",t,{signal:e}),window.addEventListener("blur",t,{signal:e})}}}#eA(e=""){this.#X===h.HIGHLIGHT?this.highlightSelection(e):this.#B&&this.#e_()}#eb(){document.addEventListener("selectionchange",this.#eS.bind(this),{signal:this._signal})}#eE(){let e=this._signal;window.addEventListener("focus",this.#ei,{signal:e}),window.addEventListener("blur",this.#en,{signal:e})}#ek(){window.removeEventListener("focus",this.#ei),window.removeEventListener("blur",this.#en)}blur(){if(this.isShiftKeyDown=!1,this.#U&&(this.#U=!1,this.#eA("main_toolbar")),!this.hasSelection)return;let{activeElement:e}=document;for(let t of this.#J)if(t.div.contains(e)){this.#K=[t,e],t._focusEventsAllowed=!1;break}}focus(){if(!this.#K)return;let[e,t]=this.#K;this.#K=null,t.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this._signal}),t.focus()}#ex(){let e=this._signal;window.addEventListener("keydown",this.#ea,{signal:e}),window.addEventListener("keyup",this.#el,{signal:e})}#eT(){window.removeEventListener("keydown",this.#ea),window.removeEventListener("keyup",this.#el)}#eM(){let e=this._signal;document.addEventListener("copy",this.#er,{signal:e}),document.addEventListener("cut",this.#eo,{signal:e}),document.addEventListener("paste",this.#es,{signal:e})}#eD(){document.removeEventListener("copy",this.#er),document.removeEventListener("cut",this.#eo),document.removeEventListener("paste",this.#es)}#ey(){let e=this._signal;document.addEventListener("dragover",this.dragOver.bind(this),{signal:e}),document.addEventListener("drop",this.drop.bind(this),{signal:e})}addEditListeners(){this.#ex(),this.#eM()}removeEditListeners(){this.#eT(),this.#eD()}dragOver(e){for(let{type:t}of e.dataTransfer.items)for(let n of this.#j)if(n.isHandlingMimeForPasting(t)){e.dataTransfer.dropEffect="copy",e.preventDefault();return}}drop(e){for(let t of e.dataTransfer.items)for(let n of this.#j)if(n.isHandlingMimeForPasting(t.type)){n.paste(t,this.currentLayer),e.preventDefault();return}}copy(e){if(e.preventDefault(),this.#k?.commitOrRemove(),!this.hasSelection)return;let t=[];for(let e of this.#J){let n=e.serialize(!0);n&&t.push(n)}if(0!==t.length)e.clipboardData.setData("application/pdfjs",JSON.stringify(t))}cut(e){this.copy(e),this.delete()}paste(e){e.preventDefault();let{clipboardData:t}=e;for(let e of t.items)for(let t of this.#j)if(t.isHandlingMimeForPasting(e.type)){t.paste(e,this.currentLayer);return}let n=t.getData("application/pdfjs");if(!n)return;try{n=JSON.parse(n)}catch(e){C(`paste: "${e.message}".`);return}if(!Array.isArray(n))return;this.unselectAll();let i=this.currentLayer;try{let e=[];for(let t of n){let n=i.deserialize(t);if(!n)return;e.push(n)}this.addCommands({cmd:()=>{for(let t of e)this.#eO(t);this.#eI(e)},undo:()=>{for(let t of e)t.remove()},mustExec:!0})}catch(e){C(`paste: "${e.message}".`)}}keydown(e){!this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!0),this.#X!==h.NONE&&!this.isEditorHandlingKeyboard&&eM._keyboardManager.exec(this,e)}keyup(e){this.isShiftKeyDown&&"Shift"===e.key&&(this.isShiftKeyDown=!1,this.#U&&(this.#U=!1,this.#eA("main_toolbar")))}onEditingAction({name:e}){switch(e){case"undo":case"redo":case"delete":case"selectAll":this[e]();break;case"highlightSelection":this.highlightSelection("context_menu")}}#eC(e){Object.entries(e).some(([e,t])=>this.#ep[e]!==t)&&(this._eventBus.dispatch("annotationeditorstateschanged",{source:this,details:Object.assign(this.#ep,e)}),this.#X===h.HIGHLIGHT&&!1===e.hasSelectedEditor&&this.#eN([[u.HIGHLIGHT_FREE,!0]]))}#eN(e){this._eventBus.dispatch("annotationeditorparamschanged",{source:this,details:e})}setEditingState(e){e?(this.#eE(),this.#eM(),this.#eC({isEditing:this.#X!==h.NONE,isEmpty:this.#eP(),hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:this.#N.hasSomethingToRedo(),hasSelectedEditor:!1})):(this.#ek(),this.#eD(),this.#eC({isEditing:!1}),this.disableUserSelect(!1))}registerEditorTypes(e){if(!this.#j)for(let t of(this.#j=e,this.#j))this.#eN(t.defaultPropertiesToUpdate)}getId(){return this.#W.id}get currentLayer(){return this.#M.get(this.#P)}getLayer(e){return this.#M.get(e)}get currentPageIndex(){return this.#P}addLayer(e){this.#M.set(e.pageIndex,e),this.#q?e.enable():e.disable()}removeLayer(e){this.#M.delete(e.pageIndex)}updateMode(e,t=null,n=!1){if(this.#X===e)return;if(this.#X=e,e===h.NONE){this.setEditingState(!1),this.#eR();return}for(let t of(this.setEditingState(!0),this.#eL(),this.unselectAll(),this.#M.values()))t.updateMode(e);if(!t&&n){this.addNewEditorFromKeyboard();return}if(!!t){for(let e of this.#T.values())if(e.annotationElementId===t){this.setSelected(e),e.enterInEditMode();break}}}addNewEditorFromKeyboard(){this.currentLayer.canCreateNewEmptyEditor()&&this.currentLayer.addNewEditor()}updateToolbar(e){if(e!==this.#X)this._eventBus.dispatch("switchannotationeditormode",{source:this,mode:e})}updateParams(e,t){if(!!this.#j){switch(e){case u.CREATE:this.currentLayer.addNewEditor();return;case u.HIGHLIGHT_DEFAULT_COLOR:this.#Z?.updateColor(t);break;case u.HIGHLIGHT_SHOW_ALL:this._eventBus.dispatch("reporttelemetry",{source:this,details:{type:"editing",data:{type:"highlight",action:"toggle_visibility"}}}),(this.#et||=new Map).set(e,t),this.showAllEditors("highlight",t)}for(let n of this.#J)n.updateParams(e,t);for(let n of this.#j)n.updateDefaultParams(e,t)}}showAllEditors(e,t,n=!1){for(let n of this.#T.values())n.editorType===e&&n.show(t);(this.#et?.get(u.HIGHLIGHT_SHOW_ALL)??!0)!==t&&this.#eN([[u.HIGHLIGHT_SHOW_ALL,t]])}enableWaiting(e=!1){if(this.#G!==e)for(let t of(this.#G=e,this.#M.values()))e?t.disableClick():t.enableClick(),t.div.classList.toggle("waiting",e)}#eL(){if(!this.#q){for(let e of(this.#q=!0,this.#M.values()))e.enable();for(let e of this.#T.values())e.enable()}}#eR(){if(this.unselectAll(),this.#q){for(let e of(this.#q=!1,this.#M.values()))e.disable();for(let e of this.#T.values())e.disable()}}getEditors(e){let t=[];for(let n of this.#T.values())n.pageIndex===e&&t.push(n);return t}getEditor(e){return this.#T.get(e)}addEditor(e){this.#T.set(e.id,e)}removeEditor(e){e.div.contains(document.activeElement)&&(this.#H&&clearTimeout(this.#H),this.#H=setTimeout(()=>{this.focusMainContainer(),this.#H=null},0)),this.#T.delete(e.id),this.unselect(e),(!e.annotationElementId||!this.#R.has(e.annotationElementId))&&this.#O?.remove(e.id)}addDeletedAnnotationElement(e){this.#R.add(e.annotationElementId),this.addChangedExistingAnnotation(e),e.deleted=!0}isDeletedAnnotationElement(e){return this.#R.has(e)}removeDeletedAnnotationElement(e){this.#R.delete(e.annotationElementId),this.removeChangedExistingAnnotation(e),e.deleted=!1}#eO(e){let t=this.#M.get(e.pageIndex);t?t.addOrRebuild(e):(this.addEditor(e),this.addToAnnotationStorage(e))}setActiveEditor(e){if(this.#k!==e)this.#k=e,e&&this.#eN(e.propertiesToUpdate)}get #ej(){let e=null;for(e of this.#J);return e}updateUI(e){this.#ej===e&&this.#eN(e.propertiesToUpdate)}toggleSelected(e){if(this.#J.has(e)){this.#J.delete(e),e.unselect(),this.#eC({hasSelectedEditor:this.hasSelection});return}this.#J.add(e),e.select(),this.#eN(e.propertiesToUpdate),this.#eC({hasSelectedEditor:!0})}setSelected(e){for(let t of this.#J)t!==e&&t.unselect();this.#J.clear(),this.#J.add(e),e.select(),this.#eN(e.propertiesToUpdate),this.#eC({hasSelectedEditor:!0})}isSelected(e){return this.#J.has(e)}get firstSelectedEditor(){return this.#J.values().next().value}unselect(e){e.unselect(),this.#J.delete(e),this.#eC({hasSelectedEditor:this.hasSelection})}get hasSelection(){return 0!==this.#J.size}get isEnterHandled(){return 1===this.#J.size&&this.firstSelectedEditor.isEnterHandled}undo(){this.#N.undo(),this.#eC({hasSomethingToUndo:this.#N.hasSomethingToUndo(),hasSomethingToRedo:!0,isEmpty:this.#eP()})}redo(){this.#N.redo(),this.#eC({hasSomethingToUndo:!0,hasSomethingToRedo:this.#N.hasSomethingToRedo(),isEmpty:this.#eP()})}addCommands(e){this.#N.add(e),this.#eC({hasSomethingToUndo:!0,hasSomethingToRedo:!1,isEmpty:this.#eP()})}#eP(){if(0===this.#T.size)return!0;if(1===this.#T.size)for(let e of this.#T.values())return e.isEmpty();return!1}delete(){if(this.commitOrRemove(),!this.hasSelection)return;let e=[...this.#J];this.addCommands({cmd:()=>{for(let t of e)t.remove()},undo:()=>{for(let t of e)this.#eO(t)},mustExec:!0})}commitOrRemove(){this.#k?.commitOrRemove()}hasSomethingToControl(){return this.#k||this.hasSelection}#eI(e){for(let e of this.#J)e.unselect();for(let t of(this.#J.clear(),e)){if(!t.isEmpty())this.#J.add(t),t.select()}this.#eC({hasSelectedEditor:this.hasSelection})}selectAll(){for(let e of this.#J)e.commit();this.#eI(this.#T.values())}unselectAll(){if((!this.#k||(this.#k.commitOrRemove(),this.#X===h.NONE))&&!!this.hasSelection){for(let e of this.#J)e.unselect();this.#J.clear(),this.#eC({hasSelectedEditor:!1})}}translateSelectedEditors(e,t,n=!1){if(!n&&this.commitOrRemove(),!this.hasSelection)return;this.#ef[0]+=e,this.#ef[1]+=t;let[i,r]=this.#ef,o=[...this.#J];for(let n of(this.#em&&clearTimeout(this.#em),this.#em=setTimeout(()=>{this.#em=null,this.#ef[0]=this.#ef[1]=0,this.addCommands({cmd:()=>{for(let e of o)this.#T.has(e.id)&&e.translateInPage(i,r)},undo:()=>{for(let e of o)this.#T.has(e.id)&&e.translateInPage(-i,-r)},mustExec:!1})},1e3),o))n.translateInPage(e,t)}setUpDragSession(){if(!!this.hasSelection)for(let e of(this.disableUserSelect(!0),this.#L=new Map,this.#J))this.#L.set(e,{savedX:e.x,savedY:e.y,savedPageIndex:e.pageIndex,newX:0,newY:0,newPageIndex:-1})}endDragSession(){if(!this.#L)return!1;this.disableUserSelect(!1);let e=this.#L;this.#L=null;let t=!1;for(let[{x:n,y:i,pageIndex:r},o]of e)o.newX=n,o.newY=i,o.newPageIndex=r,t||=n!==o.savedX||i!==o.savedY||r!==o.savedPageIndex;if(!t)return!1;let n=(e,t,n,i)=>{if(this.#T.has(e.id)){let r=this.#M.get(i);r?e._setParentAndPosition(r,t,n):(e.pageIndex=i,e.x=t,e.y=n)}};return this.addCommands({cmd:()=>{for(let[t,{newX:i,newY:r,newPageIndex:o}]of e)n(t,i,r,o)},undo:()=>{for(let[t,{savedX:i,savedY:r,savedPageIndex:o}]of e)n(t,i,r,o)},mustExec:!0}),!0}dragSelectedEditors(e,t){if(!!this.#L)for(let n of this.#L.keys())n.drag(e,t)}rebuild(e){if(null===e.parent){let 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.#J.size&&this.firstSelectedEditor.shouldGetKeyboardEvents()}isActive(e){return this.#k===e}getActive(){return this.#k}getMode(){return this.#X}get imageManager(){return T(this,"imageManager",new eA)}getSelectionBoxes(e){let t;if(!e)return null;let n=document.getSelection();for(let t=0,i=n.rangeCount;t({x:(t-r)/s,y:1-(e+n-i)/o,width:a/s,height:n/o});break;case"180":t=(e,t,n,a)=>({x:1-(e+n-i)/o,y:1-(t+a-r)/s,width:n/o,height:a/s});break;case"270":t=(e,t,n,a)=>({x:1-(t+a-r)/s,y:(e-i)/o,width:a/s,height:n/o});break;default:t=(e,t,n,a)=>({x:(e-i)/o,y:(t-r)/s,width:n/o,height:a/s})}let a=[];for(let e=0,i=n.rangeCount;ee.stopPropagation(),{signal:n});let i=e=>{e.preventDefault(),this.#o._uiManager.editAltText(this.#o)};return e.addEventListener("click",i,{capture:!0,signal:n}),e.addEventListener("keydown",t=>{t.target===e&&"Enter"===t.key&&(this.#eU=!0,i(t))},{signal:n}),await this.#e$(),e}finish(){if(!!this.#ez)this.#ez.focus({focusVisible:this.#eU}),this.#eU=!1}isEmpty(){return!this.#eF&&!this.#eB}get data(){return{altText:this.#eF,decorative:this.#eB}}set data({altText:e,decorative:t}){if(this.#eF!==e||this.#eB!==t)this.#eF=e,this.#eB=t,this.#e$()}toggle(e=!1){if(!!this.#ez)!e&&this.#eV&&(clearTimeout(this.#eV),this.#eV=null),this.#ez.disabled=!e}destroy(){this.#ez?.remove(),this.#ez=null,this.#eH=null}async #e$(){let e=this.#ez;if(!e)return;if(!this.#eF&&!this.#eB){e.classList.remove("done"),this.#eH?.remove();return}e.classList.add("done"),eD._l10nPromise.get("pdfjs-editor-alt-text-edit-button-label").then(t=>{e.setAttribute("aria-label",t)});let t=this.#eH;if(!t){this.#eH=t=document.createElement("span"),t.className="tooltip",t.setAttribute("role","tooltip");let n=t.id=`alt-text-tooltip-${this.#o.id}`;e.setAttribute("aria-describedby",n);let i=this.#o._uiManager._signal;i.addEventListener("abort",()=>{clearTimeout(this.#eV),this.#eV=null},{once:!0}),e.addEventListener("mouseenter",()=>{this.#eV=setTimeout(()=>{this.#eV=null,this.#eH.classList.add("show"),this.#o._reportTelemetry({action:"alt_text_tooltip"})},100)},{signal:i}),e.addEventListener("mouseleave",()=>{this.#eV&&(clearTimeout(this.#eV),this.#eV=null),this.#eH?.classList.remove("show")},{signal:i})}t.innerText=this.#eB?await eD._l10nPromise.get("pdfjs-editor-alt-text-decorative-tooltip"):this.#eF,!t.parentNode&&e.append(t);let n=this.#o.getImageForAltText();n?.setAttribute("aria-describedby",t.id)}}class eO{#eW=null;#eq=null;#eF=null;#eG=!1;#eK=!1;#eZ=null;#eY=null;#eX=this.focusin.bind(this);#eJ=this.focusout.bind(this);#eQ=null;#e0="";#e1=!1;#e2=null;#e5=!1;#e3=!1;#e4=!1;#e6=null;#e8=0;#e7=0;#e9=null;_initialOptions=Object.create(null);_isVisible=!0;_uiManager=null;_focusEventsAllowed=!0;_l10nPromise=null;#te=!1;#tt=eO._zIndex++;static _borderLineWidth=-1;static _colorManager=new eT;static _zIndex=1;static _telemetryTimeout=1e3;static get _resizerKeyboardManager(){let e=eO.prototype._resizeWithKeyboard,t=eM.TRANSLATE_SMALL,n=eM.TRANSLATE_BIG;return T(this,"_resizerKeyboardManager",new ek([[["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"],eO.prototype._stopResizingWithKeyboard]]))}constructor(e){this.constructor===eO&&A("Cannot initialize AnnotationEditor."),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;let{rotation:t,rawDims:{pageWidth:n,pageHeight:i,pageX:r,pageY:o}}=this.parent.viewport;this.rotation=t,this.pageRotation=(360+t-this._uiManager.viewParameters.rotation)%360,this.pageDimensions=[n,i],this.pageTranslation=[r,o];let[s,a]=this.parentDimensions;this.x=e.x/s,this.y=e.y/a,this.isAttachedToDOM=!1,this.deleted=!1}get editorType(){return Object.getPrototypeOf(this).constructor._type}static get _defaultLineColor(){return T(this,"_defaultLineColor",this._colorManager.getHexCode("CanvasText"))}static deleteAnnotationElement(e){let t=new eI({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,n){if(eO._l10nPromise||=new Map(["pdfjs-editor-alt-text-button-label","pdfjs-editor-alt-text-edit-button-label","pdfjs-editor-alt-text-decorative-tooltip","pdfjs-editor-resizer-label-topLeft","pdfjs-editor-resizer-label-topMiddle","pdfjs-editor-resizer-label-topRight","pdfjs-editor-resizer-label-middleRight","pdfjs-editor-resizer-label-bottomRight","pdfjs-editor-resizer-label-bottomMiddle","pdfjs-editor-resizer-label-bottomLeft","pdfjs-editor-resizer-label-middleLeft"].map(t=>[t,e.get(t.replaceAll(/([A-Z])/g,e=>`-${e.toLowerCase()}`))])),n?.strings)for(let t of n.strings)eO._l10nPromise.set(t,e.get(t));if(-1!==eO._borderLineWidth)return;let i=getComputedStyle(document.documentElement);eO._borderLineWidth=parseFloat(i.getPropertyValue("--outline-width"))||0}static updateDefaultParams(e,t){}static get defaultPropertiesToUpdate(){return[]}static isHandlingMimeForPasting(e){return!1}static paste(e,t){A("Not implemented")}get propertiesToUpdate(){return[]}get _isDraggable(){return this.#te}set _isDraggable(e){this.#te=e,this.div?.classList.toggle("draggable",e)}get isEnterHandled(){return!0}center(){let[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.#tn(),this.parent=e}focusin(e){if(!!this._focusEventsAllowed)this.#e1?this.#e1=!1:this.parent.setSelected(this)}focusout(e){if(!this._focusEventsAllowed||!this.isAttachedToDOM)return;let t=e.relatedTarget;if(!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,i){let[r,o]=this.parentDimensions;[n,i]=this.screenToPageTranslation(n,i),this.x=(e+n)/r,this.y=(t+i)/o,this.fixAndSetPosition()}#ti([e,t],n,i){[n,i]=this.screenToPageTranslation(n,i),this.x+=n/e,this.y+=i/t,this.fixAndSetPosition()}translate(e,t){this.#ti(this.parentDimensions,e,t)}translateInPage(e,t){this.#e2||=[this.x,this.y],this.#ti(this.pageDimensions,e,t),this.div.scrollIntoView({block:"nearest"})}drag(e,t){this.#e2||=[this.x,this.y];let[n,i]=this.parentDimensions;if(this.x+=e/n,this.y+=t/i,this.parent&&(this.x<0||this.x>1||this.y<0||this.y>1)){let{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:r,y:o}=this,[s,a]=this.getBaseTranslation();r+=s,o+=a,this.div.style.left=`${(100*r).toFixed(2)}%`,this.div.style.top=`${(100*o).toFixed(2)}%`,this.div.scrollIntoView({block:"nearest"})}get _hasBeenMoved(){return!!this.#e2&&(this.#e2[0]!==this.x||this.#e2[1]!==this.y)}getBaseTranslation(){let[e,t]=this.parentDimensions,{_borderLineWidth:n}=eO,i=n/e,r=n/t;switch(this.rotation){case 90:return[-i,r];case 180:return[i,r];case 270:return[i,-r];default:return[-i,-r]}}get _mustFixPosition(){return!0}fixAndSetPosition(e=this.rotation){let[t,n]=this.pageDimensions,{x:i,y:r,width:o,height:s}=this;if(o*=t,s*=n,i*=t,r*=n,this._mustFixPosition)switch(e){case 0:i=Math.max(0,Math.min(t-o,i)),r=Math.max(0,Math.min(n-s,r));break;case 90:i=Math.max(0,Math.min(t-s,i)),r=Math.min(n,Math.max(o,r));break;case 180:i=Math.min(t,Math.max(o,i)),r=Math.min(n,Math.max(s,r));break;case 270:i=Math.min(t,Math.max(s,i)),r=Math.max(0,Math.min(n-o,r))}this.x=i/=t,this.y=r/=n;let[a,l]=this.getBaseTranslation();i+=a,r+=l;let{style:d}=this.div;d.left=`${(100*i).toFixed(2)}%`,d.top=`${(100*r).toFixed(2)}%`,this.moveInDOM()}static #tr(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 eO.#tr(e,t,this.parentRotation)}pageTranslationToScreen(e,t){return eO.#tr(e,t,360-this.parentRotation)}#to(e){switch(e){case 90:{let[e,t]=this.pageDimensions;return[0,-e/t,t/e,0]}case 180:return[-1,0,0,-1];case 270:{let[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(){let{parentScale:e,pageDimensions:[t,n]}=this,i=t*e,r=n*e;return z.isCSSRoundSupported?[Math.round(i),Math.round(r)]:[i,r]}setDims(e,t){let[n,i]=this.parentDimensions;this.div.style.width=`${(100*e/n).toFixed(2)}%`,!this.#eK&&(this.div.style.height=`${(100*t/i).toFixed(2)}%`)}fixDims(){let{style:e}=this.div,{height:t,width:n}=e,i=n.endsWith("%"),r=!this.#eK&&t.endsWith("%");if(i&&r)return;let[o,s]=this.parentDimensions;!i&&(e.width=`${(100*parseFloat(n)/o).toFixed(2)}%`),!this.#eK&&!r&&(e.height=`${(100*parseFloat(t)/s).toFixed(2)}%`)}getInitialTranslation(){return[0,0]}#ts(){if(this.#eZ)return;this.#eZ=document.createElement("div"),this.#eZ.classList.add("resizers");let e=this._willKeepAspectRatio?["topLeft","topRight","bottomRight","bottomLeft"]:["topLeft","topMiddle","topRight","middleRight","bottomRight","bottomMiddle","bottomLeft","middleLeft"],t=this._uiManager._signal;for(let n of e){let e=document.createElement("div");this.#eZ.append(e),e.classList.add("resizer",n),e.setAttribute("data-resizer-name",n),e.addEventListener("pointerdown",this.#ta.bind(this,n),{signal:t}),e.addEventListener("contextmenu",ep,{signal:t}),e.tabIndex=-1}this.div.prepend(this.#eZ)}#ta(e,t){t.preventDefault();let{isMac:n}=z.platform;if(0!==t.button||t.ctrlKey&&n)return;this.#eF?.toggle(!1);let i=this.#tl.bind(this,e),r=this._isDraggable;this._isDraggable=!1;let o=this._uiManager._signal,s={passive:!0,capture:!0,signal:o};this.parent.togglePointerEvents(!1),window.addEventListener("pointermove",i,s),window.addEventListener("contextmenu",ep,{signal:o});let a=this.x,l=this.y,d=this.width,c=this.height,h=this.parent.div.style.cursor,u=this.div.style.cursor;this.div.style.cursor=this.parent.div.style.cursor=window.getComputedStyle(t.target).cursor;let p=()=>{this.parent.togglePointerEvents(!0),this.#eF?.toggle(!0),this._isDraggable=r,window.removeEventListener("pointerup",p),window.removeEventListener("blur",p),window.removeEventListener("pointermove",i,s),window.removeEventListener("contextmenu",ep),this.parent.div.style.cursor=h,this.div.style.cursor=u,this.#td(a,l,d,c)};window.addEventListener("pointerup",p,{signal:o}),window.addEventListener("blur",p,{signal:o})}#td(e,t,n,i){let r=this.x,o=this.y,s=this.width,a=this.height;if(r!==e||o!==t||s!==n||a!==i)this.addCommands({cmd:()=>{this.width=s,this.height=a,this.x=r,this.y=o;let[e,t]=this.parentDimensions;this.setDims(e*s,t*a),this.fixAndSetPosition()},undo:()=>{this.width=n,this.height=i,this.x=e,this.y=t;let[r,o]=this.parentDimensions;this.setDims(r*n,o*i),this.fixAndSetPosition()},mustExec:!0})}#tl(e,t){let n,i,r,o;let[s,a]=this.parentDimensions,l=this.x,d=this.y,c=this.width,h=this.height,u=eO.MIN_SIZE/s,p=eO.MIN_SIZE/a,f=e=>Math.round(1e4*e)/1e4,m=this.#to(this.rotation),g=(e,t)=>[m[0]*e+m[2]*t,m[1]*e+m[3]*t],v=this.#to(360-this.rotation),b=!1,y=!1;switch(e){case"topLeft":b=!0,n=(e,t)=>[0,0],i=(e,t)=>[e,t];break;case"topMiddle":n=(e,t)=>[e/2,0],i=(e,t)=>[e/2,t];break;case"topRight":b=!0,n=(e,t)=>[e,0],i=(e,t)=>[0,t];break;case"middleRight":y=!0,n=(e,t)=>[e,t/2],i=(e,t)=>[0,t/2];break;case"bottomRight":b=!0,n=(e,t)=>[e,t],i=(e,t)=>[0,0];break;case"bottomMiddle":n=(e,t)=>[e/2,t],i=(e,t)=>[e/2,0];break;case"bottomLeft":b=!0,n=(e,t)=>[0,t],i=(e,t)=>[e,0];break;case"middleLeft":y=!0,n=(e,t)=>[0,t/2],i=(e,t)=>[e,t/2]}let x=n(c,h),w=i(c,h),_=g(...w),S=f(l+_[0]),C=f(d+_[1]),A=1,E=1,[k,T]=this.screenToPageTranslation(t.movementX,t.movementY);if([k,T]=(r=k/s,o=T/a,[v[0]*r+v[2]*o,v[1]*r+v[3]*o]),b){let e=Math.hypot(c,h);A=E=Math.max(Math.min(Math.hypot(w[0]-x[0]-k,w[1]-x[1]-T)/e,1/c,1/h),u/c,p/h)}else y?A=Math.max(u,Math.min(1,Math.abs(w[0]-x[0]-k)))/c:E=Math.max(p,Math.min(1,Math.abs(w[1]-x[1]-T)))/h;let M=f(c*A),D=f(h*E),O=S-(_=g(...i(M,D)))[0],I=C-_[1];this.width=M,this.height=D,this.x=O,this.y=I,this.setDims(s*M,a*D),this.fixAndSetPosition()}altTextFinish(){this.#eF?.finish()}async addEditToolbar(){return this.#eQ||this.#e3?this.#eQ:(this.#eQ=new ew(this),this.div.append(this.#eQ.render()),this.#eF&&this.#eQ.addAltTextButton(await this.#eF.render()),this.#eQ)}removeEditToolbar(){if(!!this.#eQ)this.#eQ.remove(),this.#eQ=null,this.#eF?.destroy()}getClientDimensions(){return this.div.getBoundingClientRect()}async addAltTextButton(){if(!this.#eF)eD.initialize(eO._l10nPromise),this.#eF=new eD(this),this.#eW&&(this.#eF.data=this.#eW,this.#eW=null),await this.addEditToolbar()}get altTextData(){return this.#eF?.data}set altTextData(e){if(!!this.#eF)this.#eF.data=e}hasAltText(){return!this.#eF?.isEmpty()}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.#eG?-1:0,!this._isVisible&&this.div.classList.add("hidden"),this.setInForeground();let e=this._uiManager._signal;this.div.addEventListener("focusin",this.#eX,{signal:e}),this.div.addEventListener("focusout",this.#eJ,{signal:e});let[t,n]=this.parentDimensions;this.parentRotation%180!=0&&(this.div.style.maxWidth=`${(100*n/t).toFixed(2)}%`,this.div.style.maxHeight=`${(100*t/n).toFixed(2)}%`);let[i,r]=this.getInitialTranslation();return this.translate(i,r),eS(this,this.div,["pointerdown"]),this.div}pointerdown(e){let{isMac:t}=z.platform;if(0!==e.button||e.ctrlKey&&t){e.preventDefault();return}if(this.#e1=!0,this._isDraggable){this.#tc(e);return}this.#th(e)}#th(e){let{isMac:t}=z.platform;e.ctrlKey&&!t||e.shiftKey||e.metaKey&&t?this.parent.toggleSelected(this):this.parent.setSelected(this)}#tc(e){let t,n;let i=this._uiManager.isSelected(this);this._uiManager.setUpDragSession();let r=this._uiManager._signal;i&&(this.div.classList.add("moving"),t={passive:!0,capture:!0,signal:r},this.#e8=e.clientX,this.#e7=e.clientY,n=e=>{let{clientX:t,clientY:n}=e,[i,r]=this.screenToPageTranslation(t-this.#e8,n-this.#e7);this.#e8=t,this.#e7=n,this._uiManager.dragSelectedEditors(i,r)},window.addEventListener("pointermove",n,t));let o=()=>{window.removeEventListener("pointerup",o),window.removeEventListener("blur",o),i&&(this.div.classList.remove("moving"),window.removeEventListener("pointermove",n,t)),this.#e1=!1,!this._uiManager.endDragSession()&&this.#th(e)};window.addEventListener("pointerup",o,{signal:r}),window.addEventListener("blur",o,{signal:r})}moveInDOM(){this.#e6&&clearTimeout(this.#e6),this.#e6=setTimeout(()=>{this.#e6=null,this.parent?.moveEditorInDOM(this)},0)}_setParentAndPosition(e,t,n){e.changeParent(this),this.x=t,this.y=n,this.fixAndSetPosition()}getRect(e,t,n=this.rotation){let i=this.parentScale,[r,o]=this.pageDimensions,[s,a]=this.pageTranslation,l=e/i,d=t/i,c=this.x*r,h=this.y*o,u=this.width*r,p=this.height*o;switch(n){case 0:return[c+l+s,o-h-d-p+a,c+l+u+s,o-h-d+a];case 90:return[c+d+s,o-h+l+a,c+d+p+s,o-h+l+u+a];case 180:return[c-l-u+s,o-h+d+a,c-l+s,o-h+d+p+a];case 270:return[c-d-p+s,o-h-l-u+a,c-d+s,o-h-l+a];default:throw Error("Invalid rotation")}}getRectInCurrentCoords(e,t){let[n,i,r,o]=e,s=r-n,a=o-i;switch(this.rotation){case 0:return[n,t-o,s,a];case 90:return[n,t-i,a,s];case 180:return[r,t-i,s,a];case 270:return[r,t-o,a,s];default:throw Error("Invalid rotation")}}onceAdded(){}isEmpty(){return!1}enableEditMode(){this.#e3=!0}disableEditMode(){this.#e3=!1}isInEditMode(){return this.#e3}shouldGetKeyboardEvents(){return this.#e4}needsToBeRebuilt(){return this.div&&!this.isAttachedToDOM}rebuild(){let e=this._uiManager._signal;this.div?.addEventListener("focusin",this.#eX,{signal:e}),this.div?.addEventListener("focusout",this.#eJ,{signal:e})}rotate(e){}serialize(e=!1,t=null){A("An editor must be serializable")}static deserialize(e,t,n){let i=new this.prototype.constructor({parent:t,id:t.getNextId(),uiManager:n});i.rotation=e.rotation,i.#eW=e.accessibilityData;let[r,o]=i.pageDimensions,[s,a,l,d]=i.getRectInCurrentCoords(e.rect,o);return i.x=s/r,i.y=a/o,i.width=l/r,i.height=d/o,i}get hasBeenModified(){return!!this.annotationElementId&&(this.deleted||null!==this.serialize())}remove(){if(this.div.removeEventListener("focusin",this.#eX),this.div.removeEventListener("focusout",this.#eJ),!this.isEmpty()&&this.commit(),this.parent?this.parent.remove(this):this._uiManager.removeEditor(this),this.#e6&&(clearTimeout(this.#e6),this.#e6=null),this.#tn(),this.removeEditToolbar(),this.#e9){for(let e of this.#e9.values())clearTimeout(e);this.#e9=null}this.parent=null}get isResizable(){return!1}makeResizable(){this.isResizable&&(this.#ts(),this.#eZ.classList.remove("hidden"),eS(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.#eY={savedX:this.x,savedY:this.y,savedWidth:this.width,savedHeight:this.height};let t=this.#eZ.children;if(!this.#eq){this.#eq=Array.from(t);let e=this.#tu.bind(this),n=this.#tp.bind(this),i=this._uiManager._signal;for(let t of this.#eq){let r=t.getAttribute("data-resizer-name");t.setAttribute("role","spinbutton"),t.addEventListener("keydown",e,{signal:i}),t.addEventListener("blur",n,{signal:i}),t.addEventListener("focus",this.#tf.bind(this,r),{signal:i}),eO._l10nPromise.get(`pdfjs-editor-resizer-label-${r}`).then(e=>t.setAttribute("aria-label",e))}}let n=this.#eq[0],i=0;for(let e of t){if(e===n)break;i++}let r=(360-this.rotation+this.parentRotation)%360/90*(this.#eq.length/4);if(r!==i){if(ri)for(let e=0;en.setAttribute("aria-label",e))}}this.#tm(0),this.#e4=!0,this.#eZ.firstChild.focus({focusVisible:!0}),e.preventDefault(),e.stopImmediatePropagation()}#tu(e){eO._resizerKeyboardManager.exec(this,e)}#tp(e){this.#e4&&e.relatedTarget?.parentNode!==this.#eZ&&this.#tn()}#tf(e){this.#e0=this.#e4?e:""}#tm(e){if(!!this.#eq)for(let t of this.#eq)t.tabIndex=e}_resizeWithKeyboard(e,t){if(!!this.#e4)this.#tl(this.#e0,{movementX:e,movementY:t})}#tn(){if(this.#e4=!1,this.#tm(-1),this.#eY){let{savedX:e,savedY:t,savedWidth:n,savedHeight:i}=this.#eY;this.#td(e,t,n,i),this.#eY=null}}_stopResizingWithKeyboard(){this.#tn(),this.div.focus()}select(){if(this.makeResizable(),this.div?.classList.add("selectedEditor"),!this.#eQ){this.addEditToolbar().then(()=>{this.div?.classList.contains("selectedEditor")&&this.#eQ?.show()});return}this.#eQ?.show()}unselect(){this.#eZ?.classList.add("hidden"),this.div?.classList.remove("selectedEditor"),this.div?.contains(document.activeElement)&&this._uiManager.currentLayer.div.focus({preventScroll:!0}),this.#eQ?.hide()}updateParams(e,t){}disableEditing(){}enableEditing(){}enterInEditMode(){}getImageForAltText(){return null}get contentDiv(){return this.div}get isEditing(){return this.#e5}set isEditing(e){if(this.#e5=e,!!this.parent)e?(this.parent.setSelected(this),this.parent.setActiveEditor(this)):this.parent.setActiveEditor(null)}setAspectRatio(e,t){this.#eK=!0;let{style:n}=this.div;n.aspectRatio=e/t,n.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.#e9||=new Map;let{action:t}=e,n=this.#e9.get(t);n&&clearTimeout(n),n=setTimeout(()=>{this._reportTelemetry(e),this.#e9.delete(t),0===this.#e9.size&&(this.#e9=null)},eO._telemetryTimeout),this.#e9.set(t,n);return}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.#eG=!1}disable(){this.div&&(this.div.tabIndex=-1),this.#eG=!0}renderAnnotationElement(e){let t=e.container.querySelector(".annotationContent");if(t){if("CANVAS"===t.nodeName){let e=t;(t=document.createElement("div")).classList.add("annotationContent",this.editorType),e.before(t)}}else(t=document.createElement("div")).classList.add("annotationContent",this.editorType),e.container.prepend(t);return t}resetAnnotationElement(e){let{firstChild:t}=e.container;"DIV"===t.nodeName&&t.classList.contains("annotationContent")&&t.remove()}}class eI extends eO{constructor(e){super(e),this.annotationElementId=e.annotationElementId,this.deleted=!0}serialize(){return{id:this.annotationElementId,deleted:!0,pageIndex:this.pageIndex}}}class eN{constructor(e){this.h1=e?0xffffffff&e:0xc3d2e1f0,this.h2=e?0xffffffff&e:0xc3d2e1f0}update(e){let t,n;if("string"==typeof e){t=new Uint8Array(2*e.length),n=0;for(let i=0,r=e.length;i>>8,t[n++]=255&r)}}else if(ArrayBuffer.isView(e))n=(t=e.slice()).byteLength;else throw Error("Invalid data format, must be a string or TypedArray.");let i=n>>2,r=n-4*i,o=new Uint32Array(t.buffer,0,i),s=0,a=0,l=this.h1,d=this.h2,c=11601,h=13715;for(let e=0;e>>17)&0xffff0000|s*h&65535,l=5*(l=l<<13|l>>>19)+0xe6546b64):(d^=a=0x1b873593*(a=(a=0xcc9e2d51*(a=o[e])&0xffff0000|a*c&65535)<<15|a>>>17)&0xffff0000|a*h&65535,d=5*(d=d<<13|d>>>19)+0xe6546b64);switch(s=0,r){case 3:s^=t[4*i+2]<<16;case 2:s^=t[4*i+1]<<8;case 1:s^=t[4*i],s=0x1b873593*(s=(s=0xcc9e2d51*s&0xffff0000|s*c&65535)<<15|s>>>17)&0xffff0000|s*h&65535,1&i?l^=s:d^=s}this.h1=l,this.h2=d}hexdigest(){let e=this.h1,t=this.h2;return e^=t>>>1,t=0xff51afd7*t&0xffff0000|((t<<16|(e=0xed558ccd*e&0xffff0000|36045*e&65535)>>>16)*0xafd7ed55&0xffff0000)>>>16,e^=t>>>1,t=0xc4ceb9fe*t&0xffff0000|((t<<16|(e=0x1a85ec53*e&0xffff0000|60499*e&65535)>>>16)*0xb9fe1a85&0xffff0000)>>>16,((e^=t>>>1)>>>0).toString(16).padStart(8,"0")+(t>>>0).toString(16).padStart(8,"0")}}let eP=Object.freeze({map:null,hash:"",transfer:void 0});class eR{#tg=!1;#tv=new Map;constructor(){this.onSetModified=null,this.onResetModified=null,this.onAnnotationEditor=null}getValue(e,t){let n=this.#tv.get(e);return void 0===n?t:Object.assign(t,n)}getRawValue(e){return this.#tv.get(e)}remove(e){if(this.#tv.delete(e),0===this.#tv.size&&this.resetModified(),"function"==typeof this.onAnnotationEditor){for(let e of this.#tv.values())if(e instanceof eO)return;this.onAnnotationEditor(null)}}setValue(e,t){let n=this.#tv.get(e),i=!1;if(void 0!==n)for(let[e,r]of Object.entries(t))n[e]!==r&&(i=!0,n[e]=r);else i=!0,this.#tv.set(e,t);i&&this.#tb(),t instanceof eO&&"function"==typeof this.onAnnotationEditor&&this.onAnnotationEditor(t.constructor._type)}has(e){return this.#tv.has(e)}getAll(){return this.#tv.size>0?B(this.#tv):null}setAll(e){for(let[t,n]of Object.entries(e))this.setValue(t,n)}get size(){return this.#tv.size}#tb(){!this.#tg&&(this.#tg=!0,"function"==typeof this.onSetModified&&this.onSetModified())}resetModified(){this.#tg&&(this.#tg=!1,"function"==typeof this.onResetModified&&this.onResetModified())}get print(){return new eL(this)}get serializable(){if(0===this.#tv.size)return eP;let e=new Map,t=new eN,n=[],i=Object.create(null),r=!1;for(let[n,o]of this.#tv){let s=o instanceof eO?o.serialize(!1,i):o;s&&(e.set(n,s),t.update(`${n}:${JSON.stringify(s)}`),r||=!!s.bitmap)}if(r)for(let t of e.values())t.bitmap&&n.push(t.bitmap);return e.size>0?{map:e,hash:t.hexdigest(),transfer:n}:eP}get editorStats(){let e=null,t=new Map;for(let n of this.#tv.values()){if(!(n instanceof eO))continue;let i=n.telemetryFinalData;if(!i)continue;let{type:r}=i;!t.has(r)&&t.set(r,Object.getPrototypeOf(n).constructor),e||=Object.create(null);let o=e[r]||=new Map;for(let[e,t]of Object.entries(i)){if("type"===e)continue;let n=o.get(e);!n&&(n=new Map,o.set(e,n));let i=n.get(t)??0;n.set(t,i+1)}}for(let[n,i]of t)e[n]=i.computeTelemetryFinalData(e[n]);return e}}class eL extends eR{#ty;constructor(e){super();let{map:t,hash:n,transfer:i}=e.serializable,r=structuredClone(t,i?{transfer:i}:null);this.#ty={map:r,hash:n,transfer:i}}get print(){A("Should not call PrintAnnotationStorage.print")}get serializable(){return this.#ty}}class ej{#tx=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));let t=this.styleElement.sheet;t.insertRule(e,t.cssRules.length)}clear(){for(let e of this.nativeFontFaces)this._document.fonts.delete(e);this.nativeFontFaces.clear(),this.#tx.clear(),this.styleElement&&(this.styleElement.remove(),this.styleElement=null)}async loadSystemFont({systemFontInfo:e,_inspectFont:t}){if(!(!e||this.#tx.has(e.loadedName))){if(E(!this.disableFontFace,"loadSystemFont shouldn't be called when `disableFontFace` is set."),this.isFontLoadingAPISupported){let{loadedName:n,src:i,style:r}=e,o=new FontFace(n,i,r);this.addNativeFontFace(o);try{await o.load(),this.#tx.add(n),t?.(e)}catch{C(`Cannot load system font: ${e.baseFontName}, installing it could help to improve PDF rendering.`),this.removeNativeFontFace(o)}return}A("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){await this.loadSystemFont(e);return}if(this.isFontLoadingAPISupported){let t=e.createNativeFontFace();if(t){this.addNativeFontFace(t);try{await t.loaded}catch(n){throw C(`Failed to load font '${t.family}': '${n}'.`),e.disableFontFace=!0,n}}return}let t=e.createFontFaceRule();if(t){if(this.insertRule(t),this.isSyncFontLoadingSupported)return;await new Promise(t=>{let n=this._queueLoadingCallback(t);this._prepareFontLoadEvent(e,n)})}}get isFontLoadingAPISupported(){return T(this,"isFontLoadingAPISupported",!!this._document?.fonts)}get isSyncFontLoadingSupported(){let e=!1;return s?e=!0:"undefined"!=typeof navigator&&"string"==typeof navigator?.userAgent&&/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)&&(e=!0),T(this,"isSyncFontLoadingSupported",e)}_queueLoadingCallback(e){let{loadingRequests:t}=this,n={done:!1,complete:function(){for(E(!n.done,"completeRequest() cannot be called twice."),n.done=!0;t.length>0&&t[0].done;)setTimeout(t.shift().callback,0)},callback:e};return t.push(n),n}get _loadTestFont(){return T(this,"_loadTestFont",atob("T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQAABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwAAAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbmFtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAAAADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6AABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAAMQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAAAAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAAAAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQAAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMAAQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAAEAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgcA/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQAAAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAgABAAAAAAAAAAAD6AAAAAAAAA=="))}_prepareFontLoadEvent(e,t){var n;let i,r;function o(e,t){return e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|255&e.charCodeAt(t+3)}function s(e,t,n,i){let r=e.substring(0,t);return r+i+e.substring(t+n)}let a=this._document.createElement("canvas");a.width=1,a.height=1;let l=a.getContext("2d"),d=0,c=`lt${Date.now()}${this.loadTestFontId++}`,h=this._loadTestFont;h=s(h,976,c.length,c);let u=o(h,16);for(i=0,r=c.length-3;i>24&255,n>>16&255,n>>8&255,255&n));let p=`url(data:font/opentype;base64,${btoa(h)});`,f=`@font-face {font-family:"${c}";src:${p}}`;this.insertRule(f);let m=this._document.createElement("div");for(let t of(m.style.visibility="hidden",m.style.width=m.style.height="10px",m.style.position="absolute",m.style.top=m.style.left="0px",[e.loadedName,c])){let e=this._document.createElement("span");e.textContent="Hi",e.style.fontFamily=t,m.append(e)}this._document.body.append(m),!function e(t,n){if(++d>30){C("Load test font never loaded."),n();return}if(l.font="30px "+t,l.fillText(".",0,20),l.getImageData(0,0,1,1).data[3]>0){n();return}setTimeout(e.bind(null,t,n))}(c,()=>{m.remove(),t.complete()})}}class eF{constructor(e,{disableFontFace:t=!1,inspectFont:n=null}){for(let t in this.compiledGlyphs=Object.create(null),e)this[t]=e[t];this.disableFontFace=!0===t,this._inspectFont=n}createNativeFontFace(){let e;if(!this.data||this.disableFontFace)return null;if(this.cssFontInfo){let 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(){let e;if(!this.data||this.disableFontFace)return null;let t=j(this.data),n=`url(data:${this.mimetype};base64,${btoa(t)});`;if(this.cssFontInfo){let t=`font-weight: ${this.cssFontInfo.fontWeight};`;this.cssFontInfo.italicAngle&&(t+=`font-style: oblique ${this.cssFontInfo.italicAngle}deg;`),e=`@font-face {font-family:"${this.cssFontInfo.fontFamily}";${t}src:${n}}`}else e=`@font-face {font-family:"${this.loadedName}";src:${n}}`;return this._inspectFont?.(this,n),e}getPathGenerator(e,t){let n;if(void 0!==this.compiledGlyphs[t])return this.compiledGlyphs[t];try{n=e.get(this.loadedName+"_path_"+t)}catch(e){C(`getPathGenerator - ignoring character: "${e}".`)}if(!Array.isArray(n)||0===n.length)return this.compiledGlyphs[t]=function(e,t){};let i=[];for(let e=0,t=n.length;ee.bezierCurveTo(t,r,o,s,a,l)),e+=6}break;case G.MOVE_TO:{let[t,r]=n.slice(e,e+2);i.push(e=>e.moveTo(t,r)),e+=2}break;case G.LINE_TO:{let[t,r]=n.slice(e,e+2);i.push(e=>e.lineTo(t,r)),e+=2}break;case G.QUADRATIC_CURVE_TO:{let[t,r,o,s]=n.slice(e,e+4);i.push(e=>e.quadraticCurveTo(t,r,o,s)),e+=4}break;case G.RESTORE:i.push(e=>e.restore());break;case G.SAVE:i.push(e=>e.save());break;case G.SCALE:E(2===i.length,"Scale command is only valid at the third position.");break;case G.TRANSFORM:{let[t,r,o,s,a,l]=n.slice(e,e+6);i.push(e=>e.transform(t,r,o,s,a,l)),e+=6}break;case G.TRANSLATE:{let[t,r]=n.slice(e,e+2);i.push(e=>e.translate(t,r)),e+=2}}return this.compiledGlyphs[t]=function(e,t){i[0](e),i[1](e),e.scale(t,-t);for(let t=2,n=i.length;t{let e,t;let n=await import("fs"),i=await import("http"),r=await import("https");return new Map(Object.entries({fs:n,http:i,https:r,url:await import("url"),canvas:e,path2d:t}))})().then(e=>{ez=e,eB.resolve()},e=>{C(`loadPackages: ${e}`),ez=new Map,eB.resolve()})}class eH{static get promise(){return eB.promise}static get(e){return ez?.get(e)}}let eV=function(e){return eH.get("fs").promises.readFile(e).then(e=>new Uint8Array(e))},eU={FILL:"Fill",STROKE:"Stroke",SHADING:"Shading"};function e$(e,t){if(!t)return;let n=t[2]-t[0],i=t[3]-t[1],r=new Path2D;r.rect(t[0],t[1],n,i),e.clip(r)}class eW{constructor(){this.constructor===eW&&A("Cannot initialize BaseShadingPattern.")}getPattern(){A("Abstract method `getPattern` called.")}}class eq extends eW{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;for(let n of("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)),this._colorStops))t.addColorStop(n[0],n[1]);return t}getPattern(e,t,n,i){let r;if(i===eU.STROKE||i===eU.FILL){let o=t.current.getClippedPathBoundingBox(i,eb(e))||[0,0,0,0],s=Math.ceil(o[2]-o[0])||1,a=Math.ceil(o[3]-o[1])||1,l=t.cachedCanvases.getCanvas("pattern",s,a,!0),d=l.context;d.clearRect(0,0,d.canvas.width,d.canvas.height),d.beginPath(),d.rect(0,0,d.canvas.width,d.canvas.height),d.translate(-o[0],-o[1]),n=V.transform(n,[1,0,0,1,o[0],o[1]]),d.transform(...t.baseTransform),this.matrix&&d.transform(...this.matrix),e$(d,this._bbox),d.fillStyle=this._createGradient(d),d.fill(),r=e.createPattern(l.canvas,"no-repeat");let c=new DOMMatrix(n);r.setTransform(c)}else e$(e,this._bbox),r=this._createGradient(e);return r}}function eG(e,t,n,i,r,o,s,a){let l,d,c,h,u,p,f,m,g;let v=t.coords,b=t.colors,y=e.data,x=4*e.width;v[n+1]>v[i+1]&&(l=n,n=i,i=l,l=o,o=s,s=l),v[i+1]>v[r+1]&&(l=i,i=r,r=l,l=s,s=a,a=l),v[n+1]>v[i+1]&&(l=n,n=i,i=l,l=o,o=s,s=l);let w=(v[n]+t.offsetX)*t.scaleX,_=(v[n+1]+t.offsetY)*t.scaleY,S=(v[i]+t.offsetX)*t.scaleX,C=(v[i+1]+t.offsetY)*t.scaleY,A=(v[r]+t.offsetX)*t.scaleX,E=(v[r+1]+t.offsetY)*t.scaleY;if(_>=E)return;let k=b[o],T=b[o+1],M=b[o+2],D=b[s],O=b[s+1],I=b[s+2],N=b[a],P=b[a+1],R=b[a+2],L=Math.round(_),j=Math.round(E);for(let e=L;e<=j;e++){let t;if(eE?1:C===E?0:(C-e)/(C-E)),c=D-(D-N)*t,h=O-(O-P)*t,u=I-(I-R)*t}p=w-(w-A)*(t=e<_?0:e>E?1:(_-e)/(_-E)),f=k-(k-N)*t,m=T-(T-P)*t,g=M-(M-R)*t;let n=Math.round(Math.min(d,p)),i=Math.round(Math.max(d,p)),r=x*e+4*n;for(let e=n;e<=i;e++)(t=(d-e)/(d-p))<0?t=0:t>1&&(t=1),y[r++]=c-(c-f)*t|0,y[r++]=h-(h-m)*t|0,y[r++]=u-(u-g)*t|0,y[r++]=255}}class eK extends eW{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){let i=Math.floor(this._bounds[0]),r=Math.floor(this._bounds[1]),o=Math.ceil(this._bounds[2])-i,s=Math.ceil(this._bounds[3])-r,a=Math.min(Math.ceil(Math.abs(o*e[0]*1.1)),3e3),l=Math.min(Math.ceil(Math.abs(s*e[1]*1.1)),3e3),d=o/a,c=s/l,h={coords:this._coords,colors:this._colors,offsetX:-i,offsetY:-r,scaleX:1/d,scaleY:1/c},u=a+4,p=l+4,f=n.getCanvas("mesh",u,p,!1),m=f.context,g=m.createImageData(a,l);if(t){let e=g.data;for(let n=0,i=e.length;n=i?r=i:n=r/e,{scale:n,size:r}}clipBbox(e,t,n,i,r){let o=i-t,s=r-n;e.ctx.rect(t,n,o,s),e.current.updateRectMinMax(eb(e.ctx),[t,n,i,r]),e.clip(),e.endPath()}setFillAndStrokeStyleToContext(e,t,n){let i=e.ctx,r=e.current;switch(t){case eY.COLORED:let o=this.ctx;i.fillStyle=o.fillStyle,i.strokeStyle=o.strokeStyle,r.fillColor=o.fillStyle,r.strokeColor=o.strokeStyle;break;case eY.UNCOLORED:let s=V.makeHexColor(n[0],n[1],n[2]);i.fillStyle=s,i.strokeStyle=s,r.fillColor=s,r.strokeColor=s;break;default:throw new R(`Unsupported paint type: ${t}`)}}getPattern(e,t,n,i){let r=n;i!==eU.SHADING&&(r=V.transform(r,t.baseTransform),this.matrix&&(r=V.transform(r,this.matrix)));let o=this.createPatternCanvas(t),s=new DOMMatrix(r);s=(s=s.translate(o.offsetX,o.offsetY)).scale(1/o.scaleX,1/o.scaleY);let a=e.createPattern(o.canvas,"repeat");return a.setTransform(s),a}}class eJ{constructor(e){this.canvasFactory=e,this.cache=Object.create(null)}getCanvas(e,t,n){let i;return void 0!==this.cache[e]?(i=this.cache[e],this.canvasFactory.reset(i,t,n)):(i=this.canvasFactory.create(t,n),this.cache[e]=i),i}delete(e){delete this.cache[e]}clear(){for(let e in this.cache){let t=this.cache[e];this.canvasFactory.destroy(t),delete this.cache[e]}}}function eQ(e,t,n,i,r,o,s,a,l,d){let[c,h,u,p,f,m]=eb(e);if(0===h&&0===u){let g=Math.round(s*c+f),v=Math.round(a*p+m),b=Math.abs(Math.round((s+l)*c+f)-g)||1,y=Math.abs(Math.round((a+d)*p+m)-v)||1;return e.setTransform(Math.sign(c),0,0,Math.sign(p),g,v),e.drawImage(t,n,i,r,o,0,0,b,y),e.setTransform(c,h,u,p,f,m),[b,y]}if(0===c&&0===p){let g=Math.round(a*u+f),v=Math.round(s*h+m),b=Math.abs(Math.round((a+d)*u+f)-g)||1,y=Math.abs(Math.round((s+l)*h+m)-v)||1;return e.setTransform(0,Math.sign(h),Math.sign(u),0,g,v),e.drawImage(t,n,i,r,o,0,0,y,b),e.setTransform(c,h,u,p,f,m),[y,b]}return e.drawImage(t,n,i,r,o,s,a,l,d),[Math.hypot(c,h)*l,Math.hypot(u,p)*d]}class e0{constructor(e,t){this.alphaIsShape=!1,this.fontSize=0,this.fontSizeScale=1,this.textMatrix=a,this.textMatrixScale=1,this.fontMatrix=l,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=f.FILL,this.textRise=0,this.fillColor="#000000",this.strokeColor="#000000",this.patternFill=!1,this.fillAlpha=1,this.strokeAlpha=1,this.lineWidth=1,this.activeSMask=null,this.transferMaps="none",this.startNewPathAndClipBox([0,0,e,t])}clone(){let 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]=V.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){let n=V.applyTransform(t,e),i=V.applyTransform(t.slice(2),e),r=V.applyTransform([t[0],t[3]],e),o=V.applyTransform([t[2],t[1]],e);this.minX=Math.min(this.minX,n[0],i[0],r[0],o[0]),this.minY=Math.min(this.minY,n[1],i[1],r[1],o[1]),this.maxX=Math.max(this.maxX,n[0],i[0],r[0],o[0]),this.maxY=Math.max(this.maxY,n[1],i[1],r[1],o[1])}updateScalingPathMinMax(e,t){V.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,i,r,o,s,a,l,d){let c=V.bezierBoundingBox(t,n,i,r,o,s,a,l,d);if(!d)this.updateRectMinMax(e,c)}getPathBoundingBox(e=eU.FILL,t=null){let n=[this.minX,this.minY,this.maxX,this.maxY];if(e===eU.STROKE){!t&&A("Stroke bounding box must include transform.");let e=V.singularValueDecompose2dScale(t),i=e[0]*this.lineWidth/2,r=e[1]*this.lineWidth/2;n[0]-=i,n[1]-=r,n[2]+=i,n[3]+=r}return n}updateClipFromPath(){let e=V.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=eU.FILL,t=null){return V.intersect(this.clipBox,this.getPathBoundingBox(e,t))}}function e1(e,t){let n,i,r,o;if("undefined"!=typeof ImageData&&t instanceof ImageData){e.putImageData(t,0,0);return}let s=t.height,a=t.width,l=s%16,d=(s-l)/16,c=0===l?d:d+1,h=e.createImageData(a,16),u=0,p,f=t.data,g=h.data;if(t.kind===m.GRAYSCALE_1BPP){let t=f.byteLength,o=new Uint32Array(g.buffer,0,g.byteLength>>2),s=o.length,m=a+7>>3,v=z.isLittleEndian?0xff000000:255;for(n=0;nm?a:8*e-7,r=-8&i,s=0,l=0;for(;n>=1}for(;p=d&&(o=a*(r=l)),p=0,i=o;i--;)g[p++]=f[u++],g[p++]=f[u++],g[p++]=f[u++],g[p++]=255;e.putImageData(h,0,16*n)}else throw Error(`bad image kind: ${t.kind}`)}function e2(e,t){if(t.bitmap){e.drawImage(t.bitmap,0,0);return}let n=t.height,i=t.width,r=n%16,o=(n-r)/16,s=0===r?o:o+1,a=e.createImageData(i,16),l=0,d=t.data,c=a.data;for(let t=0;t>3,h=7&i,u=e.length;n=new Uint32Array(n.buffer);let p=0;for(let i=0;i10&&"function"==typeof n,c=d?Date.now()+15:0,h=0,u=this.commonObjs,p=this.objs;for(;;){if(void 0!==i&&a===i.nextBreakPoint)return i.breakIt(a,n),a;if((r=s[a])!==x.dependency)this[r].apply(this,o[a]);else for(let e of o[a]){let t=e.startsWith("g_")?u:p;if(!t.has(e))return t.get(e,n),a}if(++a===l)return a;if(d&&++h>10){if(Date.now()>c)return n(),a;h=0}}}#tw(){for(;this.stateStack.length||this.inSMaskMode;)this.restore();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(){for(let e of(this.#tw(),this.cachedCanvases.clear(),this.cachedPatterns.clear(),this._cachedBitmapsMap.values())){for(let t of e.values())"undefined"!=typeof HTMLCanvasElement&&t instanceof HTMLCanvasElement&&(t.width=t.height=0);e.clear()}this._cachedBitmapsMap.clear(),this.#t_()}#t_(){if(this.pageColors){let e=this.filterFactory.addHCMFilter(this.pageColors.foreground,this.pageColors.background);if("none"!==e){let t=this.ctx.filter;this.ctx.filter=e,this.ctx.drawImage(this.ctx.canvas,0,0),this.ctx.filter=t}}}_scaleImage(e,t){let n,i;let r=e.width,o=e.height,s=Math.max(Math.hypot(t[0],t[1]),1),a=Math.max(Math.hypot(t[2],t[3]),1),l=r,d=o,c="prescale1";for(;s>2&&l>1||a>2&&d>1;){let t=l,r=d;s>2&&l>1&&(t=l>=16384?Math.floor(l/2)-1||1:Math.ceil(l/2),s/=l/t),a>2&&d>1&&(r=d>=16384?Math.floor(d/2)-1||1:Math.ceil(d)/2,a/=d/r),(i=(n=this.cachedCanvases.getCanvas(c,t,r)).context).clearRect(0,0,t,r),i.drawImage(e,0,0,l,d,0,0,t,r),e=n.canvas,l=t,d=r,c="prescale1"===c?"prescale2":"prescale1"}return{img:e,paintWidth:l,paintHeight:d}}_createMaskCanvas(e){let t,n,i,r;let o=this.ctx,{width:s,height:a}=e,l=this.current.fillColor,d=this.current.patternFill,c=eb(o);if((e.bitmap||e.data)&&e.count>1){let r=e.bitmap||e.data.buffer;n=JSON.stringify(d?c:[c.slice(0,4),l]),!(t=this._cachedBitmapsMap.get(r))&&(t=new Map,this._cachedBitmapsMap.set(r,t));let o=t.get(n);if(o&&!d){let e=Math.round(Math.min(c[0],c[2])+c[4]);return{canvas:o,offsetX:e,offsetY:Math.round(Math.min(c[1],c[3])+c[5])}}i=o}!i&&e2((r=this.cachedCanvases.getCanvas("maskCanvas",s,a)).context,e);let h=V.transform(c,[1/s,0,0,-1/a,0,0]);h=V.transform(h,[1,0,0,1,0,-a]);let[u,p,f,m]=V.getAxialAlignedBoundingBox([0,0,s,a],h),g=Math.round(f-u)||1,v=Math.round(m-p)||1,b=this.cachedCanvases.getCanvas("fillCanvas",g,v),y=b.context;y.translate(-u,-p),y.transform(...h),!i&&(i=(i=this._scaleImage(r.canvas,ey(y))).img,t&&d&&t.set(n,i)),y.imageSmoothingEnabled=e4(eb(y),e.interpolate),eQ(y,i,0,0,i.width,i.height,0,0,s,a),y.globalCompositeOperation="source-in";let x=V.transform(ey(y),[1,0,0,1,-u,-p]);return y.fillStyle=d?l.getPattern(o,this,x,eU.FILL):l,y.fillRect(0,0,s,a),t&&!d&&(this.cachedCanvases.delete("fillCanvas"),t.set(n,b.canvas)),{canvas:b.canvas,offsetX:Math.round(u),offsetY:Math.round(p)}}setLineWidth(e){e!==this.current.lineWidth&&(this._cachedScaleForStroking[0]=-1),this.current.lineWidth=e,this.ctx.lineWidth=e}setLineCap(e){this.ctx.lineCap=e6[e]}setLineJoin(e){this.ctx.lineJoin=e8[e]}setMiterLimit(e){this.ctx.miterLimit=e}setDash(e,t){let n=this.ctx;void 0!==n.setLineDash&&(n.setLineDash(e),n.lineDashOffset=t)}setRenderingIntent(e){}setFlatness(e){}setGState(e){for(let[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(){let e=this.inSMaskMode;this.current.activeSMask&&!e?this.beginSMaskMode():!this.current.activeSMask&&e&&this.endSMaskMode()}beginSMaskMode(){if(this.inSMaskMode)throw Error("beginSMaskMode called while already in smask mode");let e=this.ctx.canvas.width,t=this.ctx.canvas.height,n="smaskGroupAt"+this.groupLevel,i=this.cachedCanvases.getCanvas(n,e,t);this.suspendedCtx=this.ctx,this.ctx=i.context;let r=this.ctx;r.setTransform(...eb(this.suspendedCtx)),e5(this.suspendedCtx,r),!function(e,t){if(e._removeMirroring)throw 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,i,r,o,s){t.transform(e,n,i,r,o,s),this.__originalTransform(e,n,i,r,o,s)},e.setTransform=function(e,n,i,r,o,s){t.setTransform(e,n,i,r,o,s),this.__originalSetTransform(e,n,i,r,o,s)},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,i,r,o,s){t.bezierCurveTo(e,n,i,r,o,s),this.__originalBezierCurveTo(e,n,i,r,o,s)},e.rect=function(e,n,i,r){t.rect(e,n,i,r),this.__originalRect(e,n,i,r)},e.closePath=function(){t.closePath(),this.__originalClosePath()},e.beginPath=function(){t.beginPath(),this.__originalBeginPath()}}(r,this.suspendedCtx),this.setGState([["BM","source-over"],["ca",1],["CA",1]])}endSMaskMode(){if(!this.inSMaskMode)throw Error("endSMaskMode called while not in smask mode");this.ctx._removeMirroring(),e5(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];let 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,i){let r=i[0],o=i[1],s=i[2]-r,a=i[3]-o;if(0!==s&&0!==a)this.genericComposeSMask(t.context,n,s,a,t.subtype,t.backdrop,t.transferMap,r,o,t.offsetX,t.offsetY),e.save(),e.globalAlpha=1,e.globalCompositeOperation="source-over",e.setTransform(1,0,0,1,0,0),e.drawImage(n.canvas,0,0),e.restore()}genericComposeSMask(e,t,n,i,r,o,s,a,l,d,c){let h=e.canvas,u=a-d,p=l-c;if(o){if(u<0||p<0||u+n>h.width||p+i>h.height){let e=this.cachedCanvases.getCanvas("maskExtension",n,i),t=e.context;t.drawImage(h,-u,-p),o.some(e=>0!==e)&&(t.globalCompositeOperation="destination-atop",t.fillStyle=V.makeHexColor(...o),t.fillRect(0,0,n,i),t.globalCompositeOperation="source-over"),h=e.canvas,u=p=0}else if(o.some(e=>0!==e)){e.save(),e.globalAlpha=1,e.setTransform(1,0,0,1,0,0);let t=new Path2D;t.rect(u,p,n,i),e.clip(t),e.globalCompositeOperation="destination-atop",e.fillStyle=V.makeHexColor(...o),e.fillRect(u,p,n,i),e.restore()}}t.save(),t.globalAlpha=1,t.setTransform(1,0,0,1,0,0),"Alpha"===r&&s?t.filter=this.filterFactory.addAlphaFilter(s):"Luminosity"===r&&(t.filter=this.filterFactory.addLuminosityFilter(s));let f=new Path2D;f.rect(a,l,n,i),t.clip(f),t.globalCompositeOperation="destination-in",t.drawImage(h,u,p,n,i,a,l,n,i),t.restore()}save(){this.inSMaskMode?(e5(this.ctx,this.suspendedCtx),this.suspendedCtx.save()):this.ctx.save();let 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(),e5(this.suspendedCtx,this.ctx)):this.ctx.restore(),this.checkSMaskState(),this.pendingClip=null,this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null)}transform(e,t,n,i,r,o){this.ctx.transform(e,t,n,i,r,o),this._cachedScaleForStroking[0]=-1,this._cachedGetSinglePixelWidth=null}constructPath(e,t,n){let i,r;let o=this.ctx,s=this.current,a=s.x,l=s.y,d=eb(o),c=0===d[0]&&0===d[3]||0===d[1]&&0===d[2],h=c?n.slice(0):null;for(let n=0,u=0,p=e.length;n100&&(d=100),this.current.fontSizeScale=t/d,this.ctx.font=`${a} ${s} ${d}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,i,r,o){this.current.textMatrix=[e,t,n,i,r,o],this.current.textMatrixScale=Math.hypot(e,t),this.current.x=this.current.lineX=0,this.current.y=this.current.lineY=0}nextLine(){this.moveText(0,this.current.leading)}paintChar(e,t,n,i){let r;let o=this.ctx,s=this.current,a=s.font,l=s.textRenderingMode,d=s.fontSize/s.fontSizeScale,c=l&f.FILL_STROKE_MASK,h=!!(l&f.ADD_TO_PATH_FLAG),u=s.patternFill&&!a.missingFile;(a.disableFontFace||h||u)&&(r=a.getPathGenerator(this.commonObjs,e)),a.disableFontFace||u?(o.save(),o.translate(t,n),o.beginPath(),r(o,d),i&&o.setTransform(...i),(c===f.FILL||c===f.FILL_STROKE)&&o.fill(),(c===f.STROKE||c===f.FILL_STROKE)&&o.stroke(),o.restore()):((c===f.FILL||c===f.FILL_STROKE)&&o.fillText(e,t,n),(c===f.STROKE||c===f.FILL_STROKE)&&o.strokeText(e,t,n)),h&&(this.pendingTextPaths||=[]).push({transform:eb(o),x:t,y:n,fontSize:d,addToPath:r})}get isFontSubpixelAAEnabled(){let{context:e}=this.cachedCanvases.getCanvas("isFontSubpixelAAEnabled",10,10);e.scale(1.5,1),e.fillText("I",0,10);let t=e.getImageData(0,0,10,10).data,n=!1;for(let e=3;e0&&t[e]<255){n=!0;break}return T(this,"isFontSubpixelAAEnabled",n)}showText(e){let t;let n=this.current,i=n.font;if(i.isType3Font)return this.showType3Text(e);let r=n.fontSize;if(0===r)return;let o=this.ctx,s=n.fontSizeScale,a=n.charSpacing,l=n.wordSpacing,d=n.fontDirection,c=n.textHScale*d,h=e.length,u=i.vertical,p=u?1:-1,m=i.defaultVMetrics,g=r*n.fontMatrix[0],v=n.textRenderingMode===f.FILL&&!i.disableFontFace&&!n.patternFill;if(o.save(),o.transform(...n.textMatrix),o.translate(n.x,n.y+n.textRise),d>0?o.scale(c,-1):o.scale(c,1),n.patternFill){o.save();let e=n.fillColor.getPattern(o,this,ey(o),eU.FILL);t=eb(o),o.restore(),o.fillStyle=e}let b=n.lineWidth,y=n.textMatrixScale;if(0===y||0===b){let e=n.textRenderingMode&f.FILL_STROKE_MASK;(e===f.STROKE||e===f.FILL_STROKE)&&(b=this.getSinglePixelWidth())}else b/=y;if(1!==s&&(o.scale(s,s),b/=s),o.lineWidth=b,i.isInvalidPDFjsFont){let t=[],i=0;for(let n of e)t.push(n.unicode),i+=n.width;o.fillText(t.join(""),0,0),n.x+=i*g*c,o.restore(),this.compose();return}let x=0,w;for(w=0;w0){let e=1e3*o.measureText(y).width/r*s;if(Snew te(e,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:this.optionalContentConfig,markedContentStack:this.markedContentStack})},i)}else t=this._getPattern(e[1],e[2]);return t}setStrokeColorN(){this.current.strokeColor=this.getColorN_Pattern(arguments)}setFillColorN(){this.current.fillColor=this.getColorN_Pattern(arguments),this.current.patternFill=!0}setStrokeRGBColor(e,t,n){let i=V.makeHexColor(e,t,n);this.ctx.strokeStyle=i,this.current.strokeColor=i}setFillRGBColor(e,t,n){let i=V.makeHexColor(e,t,n);this.ctx.fillStyle=i,this.current.fillColor=i,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 eq(e);case"Mesh":return new eK(e);case"Dummy":return new eZ}throw 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;let t=this.ctx;this.save();let n=this._getPattern(e);t.fillStyle=n.getPattern(t,this,ey(t),eU.SHADING);let i=ey(t);if(i){let{width:e,height:n}=t.canvas,[r,o,s,a]=V.getAxialAlignedBoundingBox([0,0,e,n],i);this.ctx.fillRect(r,o,s-r,a-o)}else this.ctx.fillRect(-1e10,-1e10,2e10,2e10);this.compose(this.current.getClippedPathBoundingBox()),this.restore()}beginInlineImage(){A("Should not call beginInlineImage")}beginImageData(){A("Should not call beginImageData")}paintFormXObjectBegin(e,t){if(!!this.contentVisible){if(this.save(),this.baseTransformStack.push(this.baseTransform),e&&this.transform(...e),this.baseTransform=eb(this.ctx),t){let e=t[2]-t[0],n=t[3]-t[1];this.ctx.rect(t[0],t[1],e,n),this.current.updateRectMinMax(eb(this.ctx),t),this.clip(),this.endPath()}}}paintFormXObjectEnd(){if(!!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);let t=this.ctx;!e.isolated&&S("TODO: Support non-isolated groups."),e.knockout&&C("Knockout groups not supported.");let n=eb(t);if(e.matrix&&t.transform(...e.matrix),!e.bbox)throw Error("Bounding box is required.");let i=V.getAxialAlignedBoundingBox(e.bbox,eb(t)),r=[0,0,t.canvas.width,t.canvas.height],o=Math.floor((i=V.intersect(i,r)||[0,0,0,0])[0]),s=Math.floor(i[1]),a=Math.max(Math.ceil(i[2])-o,1),l=Math.max(Math.ceil(i[3])-s,1);this.current.startNewPathAndClipBox([0,0,a,l]);let d="groupAt"+this.groupLevel;e.smask&&(d+="_smask_"+this.smaskCounter++%2);let c=this.cachedCanvases.getCanvas(d,a,l),h=c.context;h.translate(-o,-s),h.transform(...n),e.smask?this.smaskStack.push({canvas:c.canvas,context:h,offsetX:o,offsetY:s,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,s),t.save()),e5(t,h),this.ctx=h,this.setGState([["BM","source-over"],["ca",1],["CA",1]]),this.groupStack.push(t),this.groupLevel++}endGroup(e){if(!this.contentVisible)return;this.groupLevel--;let 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();let e=eb(this.ctx);this.restore(),this.ctx.save(),this.ctx.setTransform(...e);let n=V.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,i,r){if(this.#tw(),e3(this.ctx),this.ctx.save(),this.save(),this.baseTransform&&this.ctx.setTransform(...this.baseTransform),t){let i=t[2]-t[0],o=t[3]-t[1];if(r&&this.annotationCanvasMap){n=n.slice(),n[4]-=t[0],n[5]-=t[1],(t=t.slice())[0]=t[1]=0,t[2]=i,t[3]=o;let[r,s]=V.singularValueDecompose2dScale(eb(this.ctx)),{viewportScale:a}=this,l=Math.ceil(i*this.outputScaleX*a),d=Math.ceil(o*this.outputScaleY*a);this.annotationCanvas=this.canvasFactory.create(l,d);let{canvas:c,context:h}=this.annotationCanvas;this.annotationCanvasMap.set(e,c),this.annotationCanvas.savedCtx=this.ctx,this.ctx=h,this.ctx.save(),this.ctx.setTransform(r,0,0,-s,0,o*s),e3(this.ctx)}else e3(this.ctx),this.ctx.rect(t[0],t[1],i,o),this.ctx.clip(),this.endPath()}this.current=new e0(this.ctx.canvas.width,this.ctx.canvas.height),this.transform(...n),this.transform(...i)}endAnnotation(){this.annotationCanvas&&(this.ctx.restore(),this.#t_(),this.ctx=this.annotationCanvas.savedCtx,delete this.annotationCanvas.savedCtx,delete this.annotationCanvas)}paintImageMaskXObject(e){if(!this.contentVisible)return;let t=e.count;(e=this.getObject(e.data,e)).count=t;let n=this.ctx,i=this.processingType3;if(i&&(void 0===i.compiled&&(i.compiled=function(e){let t,n,i;let{width:r,height:o}=e;if(r>1e3||o>1e3)return null;let s=new Uint8Array([0,2,4,0,1,0,5,4,8,10,0,8,0,2,1,0]),a=r+1,l=new Uint8Array(a*(o+1)),d=r+7&-8,c=new Uint8Array(d*o),h=0;for(let t of e.data){let e=128;for(;e>0;)c[h++]=t&e?0:255,e>>=1}let u=0;for(0!==c[h=0]&&(l[0]=1,++u),n=1;n>2)+(c[h+1]?4:0)+(c[h-d+1]?8:0)]&&(l[i+n]=s[e],++u),h++;if(c[h-d]!==c[h]&&(l[i+n]=c[h]?2:4,++u),u>1e3)return null}for(h=d*(o-1),i=t*a,0!==c[h]&&(l[i]=8,++u),n=1;n1e3)return null;let p=new Int32Array([0,a,-1,0,-a,0,0,0,1]),f=new Path2D;for(t=0;u&&t<=o;t++){let e=t*a,n=e+r;for(;e>4,l[e]&=o>>2|o<<2),f.lineTo(e%a,e/a|0),!l[e]&&--u}while(i!==e);--t}return c=null,l=null,function(e){e.save(),e.scale(1/r,-1/o),e.translate(0,-o),e.fill(f),e.beginPath(),e.restore()}}(e)),i.compiled)){i.compiled(n);return}let r=this._createMaskCanvas(e),o=r.canvas;n.save(),n.setTransform(1,0,0,1,0,0),n.drawImage(o,r.offsetX,r.offsetY),n.restore(),this.compose()}paintImageMaskXObjectRepeat(e,t,n=0,i=0,r,o){if(!this.contentVisible)return;e=this.getObject(e.data,e);let s=this.ctx;s.save();let a=eb(s);s.transform(t,n,i,r,0,0);let l=this._createMaskCanvas(e);s.setTransform(1,0,0,1,l.offsetX-a[4],l.offsetY-a[5]);for(let e=0,d=o.length;ei?d/i:1,t=l>i?l/i:1}}this._cachedScaleForStroking[0]=e,this._cachedScaleForStroking[1]=t}return this._cachedScaleForStroking}rescaleAndStroke(e){let{ctx:t}=this,{lineWidth:n}=this.current,[i,r]=this.getScaleForStroking();if(t.lineWidth=n||1,1===i&&1===r){t.stroke();return}let o=t.getLineDash();if(e&&t.save(),t.scale(i,r),o.length>0){let e=Math.max(i,r);t.setLineDash(o.map(t=>t/e)),t.lineDashOffset/=e}t.stroke(),e&&t.restore()}isContentVisible(){for(let e=this.markedContentStack.length-1;e>=0;e--)if(!this.markedContentStack[e].visible)return!1;return!0}}for(let e in x)void 0!==te.prototype[e]&&(te.prototype[x[e]]=te.prototype[e]);class tt{static #tS=null;static #tC="";static get workerPort(){return this.#tS}static set workerPort(e){if(!("undefined"!=typeof Worker&&e instanceof Worker)&&null!==e)throw Error("Invalid `workerPort` type.");this.#tS=e}static get workerSrc(){return this.#tC}static set workerSrc(e){if("string"!=typeof e)throw Error("Invalid `workerSrc` type.");this.#tC=e}}let tn={DATA:1,ERROR:2},ti={CANCEL:1,CANCEL_COMPLETE:2,CLOSE:3,ENQUEUE:4,ERROR:5,PULL:6,PULL_COMPLETE:7,START_COMPLETE:8};function tr(e){switch(!(e instanceof Error||"object"==typeof e&&null!==e)&&A('wrapReason: Expected "reason" to be a (possibly cloned) Error.'),e.name){case"AbortException":return new L(e.message);case"MissingPDFException":return new N(e.message);case"PasswordException":return new D(e.message,e.code);case"UnexpectedResponseException":return new P(e.message,e.status);case"UnknownErrorException":return new O(e.message,e.details);default:return new O(e.message,e.toString())}}class to{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),this._onComObjOnMessage=e=>{let t=e.data;if(t.targetName!==this.sourceName)return;if(t.stream){this.#tA(t);return}if(t.callback){let e=t.callbackId,n=this.callbackCapabilities[e];if(!n)throw Error(`Cannot resolve callback ${e}`);if(delete this.callbackCapabilities[e],t.callback===tn.DATA)n.resolve(t.data);else if(t.callback===tn.ERROR)n.reject(tr(t.reason));else throw Error("Unexpected callback case");return}let i=this.actionHandler[t.action];if(!i)throw Error(`Unknown action from worker: ${t.action}`);if(t.callbackId){let e=this.sourceName,r=t.sourceName;new Promise(function(e){e(i(t.data))}).then(function(i){n.postMessage({sourceName:e,targetName:r,callback:tn.DATA,callbackId:t.callbackId,data:i})},function(i){n.postMessage({sourceName:e,targetName:r,callback:tn.ERROR,callbackId:t.callbackId,reason:tr(i)})});return}if(t.streamId){this.#tE(t);return}i(t.data)},n.addEventListener("message",this._onComObjOnMessage)}on(e,t){let n=this.actionHandler;if(n[e])throw 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){let i=this.callbackId++,r=Promise.withResolvers();this.callbackCapabilities[i]=r;try{this.comObj.postMessage({sourceName:this.sourceName,targetName:this.targetName,action:e,callbackId:i,data:t},n)}catch(e){r.reject(e)}return r.promise}sendWithStream(e,t,n,i){let r=this.streamId++,o=this.sourceName,s=this.targetName,a=this.comObj;return new ReadableStream({start:n=>{let l=Promise.withResolvers();return this.streamControllers[r]={controller:n,startCall:l,pullCall:null,cancelCall:null,isClosed:!1},a.postMessage({sourceName:o,targetName:s,action:e,streamId:r,data:t,desiredSize:n.desiredSize},i),l.promise},pull:e=>{let t=Promise.withResolvers();return this.streamControllers[r].pullCall=t,a.postMessage({sourceName:o,targetName:s,stream:ti.PULL,streamId:r,desiredSize:e.desiredSize}),t.promise},cancel:e=>{E(e instanceof Error,"cancel must have a valid reason");let t=Promise.withResolvers();return this.streamControllers[r].cancelCall=t,this.streamControllers[r].isClosed=!0,a.postMessage({sourceName:o,targetName:s,stream:ti.CANCEL,streamId:r,reason:tr(e)}),t.promise}},n)}#tE(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,o=this,s=this.actionHandler[e.action],a={enqueue(e,o=1,s){if(this.isCancelled)return;let a=this.desiredSize;this.desiredSize-=o,a>0&&this.desiredSize<=0&&(this.sinkCapability=Promise.withResolvers(),this.ready=this.sinkCapability.promise),r.postMessage({sourceName:n,targetName:i,stream:ti.ENQUEUE,streamId:t,chunk:e},s)},close(){if(!this.isCancelled)this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:ti.CLOSE,streamId:t}),delete o.streamSinks[t]},error(e){if(E(e instanceof Error,"error must have a valid reason"),!this.isCancelled)this.isCancelled=!0,r.postMessage({sourceName:n,targetName:i,stream:ti.ERROR,streamId:t,reason:tr(e)})},sinkCapability:Promise.withResolvers(),onPull:null,onCancel:null,isCancelled:!1,desiredSize:e.desiredSize,ready:null};a.sinkCapability.resolve(),a.ready=a.sinkCapability.promise,this.streamSinks[t]=a,new Promise(function(t){t(s(e.data,a))}).then(function(){r.postMessage({sourceName:n,targetName:i,stream:ti.START_COMPLETE,streamId:t,success:!0})},function(e){r.postMessage({sourceName:n,targetName:i,stream:ti.START_COMPLETE,streamId:t,reason:tr(e)})})}#tA(e){let t=e.streamId,n=this.sourceName,i=e.sourceName,r=this.comObj,o=this.streamControllers[t],s=this.streamSinks[t];switch(e.stream){case ti.START_COMPLETE:e.success?o.startCall.resolve():o.startCall.reject(tr(e.reason));break;case ti.PULL_COMPLETE:e.success?o.pullCall.resolve():o.pullCall.reject(tr(e.reason));break;case ti.PULL:if(!s){r.postMessage({sourceName:n,targetName:i,stream:ti.PULL_COMPLETE,streamId:t,success:!0});break}s.desiredSize<=0&&e.desiredSize>0&&s.sinkCapability.resolve(),s.desiredSize=e.desiredSize,new Promise(function(e){e(s.onPull?.())}).then(function(){r.postMessage({sourceName:n,targetName:i,stream:ti.PULL_COMPLETE,streamId:t,success:!0})},function(e){r.postMessage({sourceName:n,targetName:i,stream:ti.PULL_COMPLETE,streamId:t,reason:tr(e)})});break;case ti.ENQUEUE:if(E(o,"enqueue should have stream controller"),o.isClosed)break;o.controller.enqueue(e.chunk);break;case ti.CLOSE:if(E(o,"close should have stream controller"),o.isClosed)break;o.isClosed=!0,o.controller.close(),this.#tk(o,t);break;case ti.ERROR:E(o,"error should have stream controller"),o.controller.error(tr(e.reason)),this.#tk(o,t);break;case ti.CANCEL_COMPLETE:e.success?o.cancelCall.resolve():o.cancelCall.reject(tr(e.reason)),this.#tk(o,t);break;case ti.CANCEL:if(!s)break;new Promise(function(t){t(s.onCancel?.(tr(e.reason)))}).then(function(){r.postMessage({sourceName:n,targetName:i,stream:ti.CANCEL_COMPLETE,streamId:t,success:!0})},function(e){r.postMessage({sourceName:n,targetName:i,stream:ti.CANCEL_COMPLETE,streamId:t,reason:tr(e)})}),s.sinkCapability.reject(tr(e.reason)),s.isCancelled=!0,delete this.streamSinks[t];break;default:throw Error("Unexpected stream case")}}async #tk(e,t){await Promise.allSettled([e.startCall?.promise,e.pullCall?.promise,e.cancelCall?.promise]),delete this.streamControllers[t]}destroy(){this.comObj.removeEventListener("message",this._onComObjOnMessage)}}class ts{#tT;#tM;constructor({parsedData:e,rawData:t}){this.#tT=e,this.#tM=t}getRaw(){return this.#tM}get(e){return this.#tT.get(e)??null}getAll(){return B(this.#tT)}has(e){return this.#tT.has(e)}}let ta=Symbol("INTERNAL");class tl{#tD=!1;#tO=!1;#tI=!1;#tN=!0;constructor(e,{name:t,intent:n,usage:i}){this.#tD=!!(e&d.DISPLAY),this.#tO=!!(e&d.PRINT),this.name=t,this.intent=n,this.usage=i}get visible(){if(this.#tI)return this.#tN;if(!this.#tN)return!1;let{print:e,view:t}=this.usage;return this.#tD?t?.viewState!=="OFF":!this.#tO||e?.printState!=="OFF"}_setVisible(e,t,n=!1){e!==ta&&A("Internal method `_setVisible` called."),this.#tI=n,this.#tN=t}}class td{#tP=null;#tR=new Map;#tL=null;#tj=null;constructor(e,t=d.DISPLAY){if(this.renderingIntent=t,this.name=null,this.creator=null,null===e)return;for(let n of(this.name=e.name,this.creator=e.creator,this.#tj=e.order,e.groups))this.#tR.set(n.id,new tl(t,n));if("OFF"===e.baseState)for(let e of this.#tR.values())e._setVisible(ta,!1);for(let t of e.on)this.#tR.get(t)._setVisible(ta,!0);for(let t of e.off)this.#tR.get(t)._setVisible(ta,!1);this.#tL=this.getHash()}#tF(e){let t=e.length;if(t<2)return!0;let n=e[0];for(let i=1;i0?B(this.#tR):null}getGroup(e){return this.#tR.get(e)||null}getHash(){if(null!==this.#tP)return this.#tP;let e=new eN;for(let[t,n]of this.#tR)e.update(`${t}:${n.visible}`);return this.#tP=e.hexdigest()}}class tc{constructor(e,{disableRange:t=!1,disableStream:n=!1}){E(e,'PDFDataTransportStream - missing required "pdfDataRangeTransport" argument.');let{length:i,initialData:r,progressiveDone:o,contentDispositionFilename:s}=e;if(this._queuedChunks=[],this._progressiveDone=o,this._contentDispositionFilename=s,r?.length>0){let e=r instanceof Uint8Array&&r.byteLength===r.buffer.byteLength?r.buffer:new Uint8Array(r).buffer;this._queuedChunks.push(e)}this._pdfDataRangeTransport=e,this._isStreamingSupported=!n,this._isRangeSupported=!t,this._contentLength=i,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}){let 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):E(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){let t=this._rangeReaders.indexOf(e);t>=0&&this._rangeReaders.splice(t,1)}getFullReader(){E(!this._fullRequestReader,"PDFDataTransportStream.getFullReader can only be called once.");let e=this._queuedChunks;return this._queuedChunks=null,new th(this,e,this._progressiveDone,this._contentDispositionFilename)}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=new tu(this,e,t);return this._pdfDataRangeTransport.requestDataRange(e,t),this._rangeReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeReaders.slice(0)))t.cancel(e);this._pdfDataRangeTransport.abort()}}class th{constructor(e,t,n=!1,i=null){for(let r of(this._stream=e,this._done=n||!1,this._filename=el(i)?i:null,this._queuedChunks=t||[],this._loaded=0,this._queuedChunks))this._loaded+=r.byteLength;this._requests=[],this._headersReady=Promise.resolve(),e._fullRequestReader=this,this.onProgress=null}_enqueue(e){if(!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};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0}progressiveDone(){if(!this._done)this._done=!0}}class tu{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{for(let t of(this._requests.shift().resolve({value:e,done:!1}),this._requests))t.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){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let e of(this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._stream._removeRangeReader(this)}}function tp({getResponseHeader:e,isHttp:t,rangeChunkSize:n,disableRange:i}){let r={allowRangeRequests:!1,suggestedLength:void 0},o=parseInt(e("Content-Length"),10);return Number.isInteger(o)?(r.suggestedLength=o,o<=2*n||i||!t||"bytes"!==e("Accept-Ranges")||"identity"!==(e("Content-Encoding")||"identity"))?r:(r.allowRangeRequests=!0,r):r}function tf(e){let t=e("Content-Disposition");if(t){let e=function(e){let t=!0,n=i("filename\\*","i").exec(e);if(n){let e=s(n=n[1]);return o(e=l(e=a(e=unescape(e))))}if(n=function(e){let t;let n=[],r=i("filename\\*((?!0\\d)\\d+)(\\*?)","ig");for(;null!==(t=r.exec(e));){let[,e,i,r]=t;if((e=parseInt(e,10))in n){if(0===e)break;continue}n[e]=[i,r]}let o=[];for(let e=0;e{if(!tg(e.status))throw tm(e.status,n);this._reader=e.body.getReader(),this._headersCapability.resolve();let t=t=>e.headers.get(t),{allowRangeRequests:i,suggestedLength:r}=tp({getResponseHeader:t,isHttp:this._stream.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=r||this._contentLength,this._filename=tf(t),!this._isStreamingSupported&&this._isRangeSupported&&this.cancel(new L("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;let{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:ty(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class t_{constructor(e,t,n){this._stream=e,this._reader=null,this._loaded=0;let i=e.source;this._withCredentials=i.withCredentials||!1,this._readCapability=Promise.withResolvers(),this._isStreamingSupported=!i.disableStream,this._abortController=new AbortController,this._headers=tb(this._stream.httpHeaders),this._headers.append("Range",`bytes=${t}-${n-1}`);let r=i.url;fetch(r,tv(this._headers,this._withCredentials,this._abortController)).then(e=>{if(!tg(e.status))throw tm(e.status,r);this._readCapability.resolve(),this._reader=e.body.getReader()}).catch(this._readCapability.reject),this.onProgress=null}get isStreamingSupported(){return this._isStreamingSupported}async read(){await this._readCapability.promise;let{value:e,done:t}=await this._reader.read();return t?{value:e,done:t}:(this._loaded+=e.byteLength,this.onProgress?.({loaded:this._loaded}),{value:ty(e),done:!1})}cancel(e){this._reader?.cancel(e),this._abortController.abort()}}class tS{constructor(e,t={}){this.url=e,this.isHttp=/^https?:/i.test(e),this.httpHeaders=this.isHttp&&t.httpHeaders||Object.create(null),this.withCredentials=t.withCredentials||!1,this.currXhrId=0,this.pendingRequests=Object.create(null)}requestRange(e,t,n){let i={begin:e,end:t};for(let e in n)i[e]=n[e];return this.request(i)}requestFull(e){return this.request(e)}request(e){let t=new XMLHttpRequest,n=this.currXhrId++,i=this.pendingRequests[n]={xhr:t};for(let e in t.open("GET",this.url),t.withCredentials=this.withCredentials,this.httpHeaders){let n=this.httpHeaders[e];if(void 0!==n)t.setRequestHeader(e,n)}return this.isHttp&&"begin"in e&&"end"in e?(t.setRequestHeader("Range",`bytes=${e.begin}-${e.end-1}`),i.expectedStatus=206):i.expectedStatus=200,t.responseType="arraybuffer",e.onError&&(t.onerror=function(n){e.onError(t.status)}),t.onreadystatechange=this.onStateChange.bind(this,n),t.onprogress=this.onProgress.bind(this,n),i.onHeadersReceived=e.onHeadersReceived,i.onDone=e.onDone,i.onError=e.onError,i.onProgress=e.onProgress,t.send(null),n}onProgress(e,t){let n=this.pendingRequests[e];if(!!n)n.onProgress?.(t)}onStateChange(e,t){let n=this.pendingRequests[e];if(!n)return;let i=n.xhr;if(i.readyState>=2&&n.onHeadersReceived&&(n.onHeadersReceived(),delete n.onHeadersReceived),4!==i.readyState||!(e in this.pendingRequests))return;if(delete this.pendingRequests[e],0===i.status&&this.isHttp){n.onError?.(i.status);return}let r=i.status||200;if(!(200===r&&206===n.expectedStatus)&&r!==n.expectedStatus){n.onError?.(i.status);return}let o=function(e){let t=e.response;return"string"!=typeof t?t:F(t).buffer}(i);if(206===r){let e=i.getResponseHeader("Content-Range"),t=/bytes (\d+)-(\d+)\/(\d+)/.exec(e);n.onDone({begin:parseInt(t[1],10),chunk:o})}else o?n.onDone({begin:0,chunk:o}):n.onError?.(i.status)}getRequestXhr(e){return this.pendingRequests[e].xhr}isPendingRequest(e){return e in this.pendingRequests}abortRequest(e){let t=this.pendingRequests[e].xhr;delete this.pendingRequests[e],t.abort()}}class tC{constructor(e){this._source=e,this._manager=new tS(e.url,{httpHeaders:e.httpHeaders,withCredentials:e.withCredentials}),this._rangeChunkSize=e.rangeChunkSize,this._fullRequestReader=null,this._rangeRequestReaders=[]}_onRangeRequestReaderClosed(e){let t=this._rangeRequestReaders.indexOf(e);t>=0&&this._rangeRequestReaders.splice(t,1)}getFullReader(){return E(!this._fullRequestReader,"PDFNetworkStream.getFullReader can only be called once."),this._fullRequestReader=new tA(this._manager,this._source),this._fullRequestReader}getRangeReader(e,t){let n=new tE(this._manager,e,t);return n.onClosed=this._onRangeRequestReaderClosed.bind(this),this._rangeRequestReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeRequestReaders.slice(0)))t.cancel(e)}}class tA{constructor(e,t){this._manager=e;let n={onHeadersReceived:this._onHeadersReceived.bind(this),onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=t.url,this._fullRequestId=e.requestFull(n),this._headersReceivedCapability=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(){let e=this._fullRequestId,t=this._manager.getRequestXhr(e),n=e=>t.getResponseHeader(e),{allowRangeRequests:i,suggestedLength:r}=tp({getResponseHeader:n,isHttp:this._manager.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});i&&(this._isRangeSupported=!0),this._contentLength=r||this._contentLength,this._filename=tf(n),this._isRangeSupported&&this._manager.abortRequest(e),this._headersReceivedCapability.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(let e of this._requests)e.resolve({value:void 0,done:!0});this._requests.length=0}}_onError(e){for(let t of(this._storedError=tm(e,this._url),this._headersReceivedCapability.reject(this._storedError),this._requests))t.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._headersReceivedCapability.promise}async read(){if(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};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let t of(this._done=!0,this._headersReceivedCapability.reject(e),this._requests))t.resolve({value:void 0,done:!0});this._requests.length=0,this._manager.isPendingRequest(this._fullRequestId)&&this._manager.abortRequest(this._fullRequestId),this._fullRequestReader=null}}class tE{constructor(e,t,n){this._manager=e;let i={onDone:this._onDone.bind(this),onError:this._onError.bind(this),onProgress:this._onProgress.bind(this)};this._url=e.url,this._requestId=e.requestRange(t,n,i),this._requests=[],this._queuedChunk=null,this._done=!1,this._storedError=void 0,this.onProgress=null,this.onClosed=null}_close(){this.onClosed?.(this)}_onDone(e){let t=e.chunk;for(let e of(this._requests.length>0?this._requests.shift().resolve({value:t,done:!1}):this._queuedChunk=t,this._done=!0,this._requests))e.resolve({value:void 0,done:!0});this._requests.length=0,this._close()}_onError(e){for(let t of(this._storedError=tm(e,this._url),this._requests))t.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){let e=this._queuedChunk;return this._queuedChunk=null,{value:e,done:!1}}if(this._done)return{value:void 0,done:!0};let e=Promise.withResolvers();return this._requests.push(e),e.promise}cancel(e){for(let e of(this._done=!0,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()}}let tk=/^file:\/\/\/[a-zA-Z]:\//;class tT{constructor(e){this.source=e,this.url=function(e){let t=eH.get("url"),n=t.parse(e);return"file:"===n.protocol||n.host?n:/^[a-z]:[/\\]/i.test(e)?t.parse(`file:///${e}`):(!n.host&&(n.protocol="file:"),n)}(e.url),this.isHttp="http:"===this.url.protocol||"https:"===this.url.protocol,this.isFsUrl="file:"===this.url.protocol,this.httpHeaders=this.isHttp&&e.httpHeaders||{},this._fullRequestReader=null,this._rangeRequestReaders=[]}get _progressiveDataLength(){return this._fullRequestReader?._loaded??0}getFullReader(){return E(!this._fullRequestReader,"PDFNodeStream.getFullReader can only be called once."),this._fullRequestReader=this.isFsUrl?new tP(this):new tI(this),this._fullRequestReader}getRangeReader(e,t){if(t<=this._progressiveDataLength)return null;let n=this.isFsUrl?new tR(this,e,t):new tN(this,e,t);return this._rangeRequestReaders.push(n),n}cancelAllRequests(e){for(let t of(this._fullRequestReader?.cancel(e),this._rangeRequestReaders.slice(0)))t.cancel(e)}}class tM{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null;let 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()}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;let 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){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(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 L("streaming is disabled")),this._storedError&&this._readableStream.destroy(this._storedError)}}class tD{constructor(e){this._url=e.url,this._done=!1,this._storedError=null,this.onProgress=null,this._loaded=0,this._readableStream=null,this._readCapability=Promise.withResolvers();let t=e.source;this._isStreamingSupported=!t.disableStream}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;let 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){if(!this._readableStream){this._error(e);return}this._readableStream.destroy(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)}}function tO(e,t){return{protocol:e.protocol,auth:e.auth,host:e.hostname,port:e.port,path:e.path,method:"GET",headers:t}}class tI extends tM{constructor(e){super(e);let t=t=>{if(404===t.statusCode){let e=new N(`Missing PDF "${this._url}".`);this._storedError=e,this._headersCapability.reject(e);return}this._headersCapability.resolve(),this._setReadableStream(t);let n=e=>this._readableStream.headers[e.toLowerCase()],{allowRangeRequests:i,suggestedLength:r}=tp({getResponseHeader:n,isHttp:e.isHttp,rangeChunkSize:this._rangeChunkSize,disableRange:this._disableRange});this._isRangeSupported=i,this._contentLength=r||this._contentLength,this._filename=tf(n)};if(this._request=null,"http:"===this._url.protocol){let n=eH.get("http");this._request=n.request(tO(this._url,e.httpHeaders),t)}else{let n=eH.get("https");this._request=n.request(tO(this._url,e.httpHeaders),t)}this._request.on("error",e=>{this._storedError=e,this._headersCapability.reject(e)}),this._request.end()}}class tN extends tD{constructor(e,t,n){for(let t in super(e),this._httpHeaders={},e.httpHeaders){let n=e.httpHeaders[t];if(void 0!==n)this._httpHeaders[t]=n}this._httpHeaders.Range=`bytes=${t}-${n-1}`;let i=e=>{if(404===e.statusCode){let e=new N(`Missing PDF "${this._url}".`);this._storedError=e;return}this._setReadableStream(e)};if(this._request=null,"http:"===this._url.protocol){let e=eH.get("http");this._request=e.request(tO(this._url,this._httpHeaders),i)}else{let e=eH.get("https");this._request=e.request(tO(this._url,this._httpHeaders),i)}this._request.on("error",e=>{this._storedError=e}),this._request.end()}}class tP extends tM{constructor(e){super(e);let t=decodeURIComponent(this._url.path);tk.test(this._url.href)&&(t=t.replace(/^\//,""));let n=eH.get("fs");n.promises.lstat(t).then(e=>{this._contentLength=e.size,this._setReadableStream(n.createReadStream(t)),this._headersCapability.resolve()},e=>{"ENOENT"===e.code&&(e=new N(`Missing PDF "${t}".`)),this._storedError=e,this._headersCapability.reject(e)})}}class tR extends tD{constructor(e,t,n){super(e);let i=decodeURIComponent(this._url.path);tk.test(this._url.href)&&(i=i.replace(/^\//,""));let r=eH.get("fs");this._setReadableStream(r.createReadStream(i,{start:t,end:n-1}))}}class tL{#tB=Promise.withResolvers();#eg=null;#tz=!1;#tH=!!globalThis.FontInspector?.enabled;#tV=null;#tU=null;#t$=0;#tW=0;#tq=null;#tG=null;#tK=0;#tZ=0;#tY=Object.create(null);#tX=[];#tJ=null;#tQ=[];#t0=new WeakMap;#t1=null;static #t2=new Map;static #t5=new Map;static #t3=null;static #t4=new Set;constructor({textContentSource:e,container:t,viewport:n}){if(e instanceof ReadableStream)this.#tJ=e;else if("object"==typeof e)this.#tJ=new ReadableStream({start(t){t.enqueue(e),t.close()}});else throw Error('No "textContentSource" parameter specified.');this.#eg=this.#tG=t,this.#tZ=n.scale*(globalThis.devicePixelRatio||1),this.#tK=n.rotation,this.#tU={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:null};let{pageWidth:i,pageHeight:r,pageX:o,pageY:s}=n.rawDims;this.#t1=[1,0,0,-1,-o,s+r],this.#tW=i,this.#t$=r,tL.#t6(),ex(t,n),this.#tB.promise.catch(()=>{}).then(()=>{tL.#t4.delete(this),this.#tU=null,this.#tY=null})}render(){let e=()=>{this.#tq.read().then(({value:t,done:n})=>{if(n){this.#tB.resolve();return}this.#tV??=t.lang,Object.assign(this.#tY,t.styles),this.#t8(t.items),e()},this.#tB.reject)};return this.#tq=this.#tJ.getReader(),tL.#t4.add(this),e(),this.#tB.promise}update({viewport:e,onBefore:t=null}){let n=e.scale*(globalThis.devicePixelRatio||1),i=e.rotation;if(i!==this.#tK&&(t?.(),this.#tK=i,ex(this.#tG,{rotation:i})),n!==this.#tZ){t?.(),this.#tZ=n;let e={prevFontSize:null,prevFontFamily:null,div:null,properties:null,ctx:tL.#t7(this.#tV)};for(let t of this.#tQ)e.properties=this.#t0.get(t),e.div=t,this.#t9(e)}}cancel(){let e=new L("TextLayer task cancelled.");this.#tq?.cancel(e).catch(()=>{}),this.#tq=null,this.#tB.reject(e)}get textDivs(){return this.#tQ}get textContentItemsStr(){return this.#tX}#t8(e){if(this.#tz)return;this.#tU.ctx??=tL.#t7(this.#tV);let t=this.#tQ,n=this.#tX;for(let i of e){if(t.length>1e5){C("Ignoring additional textDivs for performance reasons."),this.#tz=!0;return}if(void 0===i.str){if("beginMarkedContentProps"===i.type||"beginMarkedContent"===i.type){let e=this.#eg;this.#eg=document.createElement("span"),this.#eg.classList.add("markedContent"),null!==i.id&&this.#eg.setAttribute("id",`${i.id}`),e.append(this.#eg)}else"endMarkedContent"===i.type&&(this.#eg=this.#eg.parentNode);continue}n.push(i.str),this.#ne(i)}}#ne(e){let t,n;let i=document.createElement("span"),r={angle:0,canvasWidth:0,hasText:""!==e.str,hasEOL:e.hasEOL,fontSize:0};this.#tQ.push(i);let o=V.transform(this.#t1,e.transform),s=Math.atan2(o[1],o[0]),a=this.#tY[e.fontName];a.vertical&&(s+=Math.PI/2);let l=this.#tH&&a.fontSubstitution||a.fontFamily,d=Math.hypot(o[2],o[3]),c=d*tL.#nt(l,this.#tV);0===s?(t=o[4],n=o[5]-c):(t=o[4]+c*Math.sin(s),n=o[5]-c*Math.cos(s));let h="calc(var(--scale-factor)*",u=i.style;this.#eg===this.#tG?(u.left=`${(100*t/this.#tW).toFixed(2)}%`,u.top=`${(100*n/this.#t$).toFixed(2)}%`):(u.left=`${h}${t.toFixed(2)}px)`,u.top=`${h}${n.toFixed(2)}px)`),u.fontSize=`${h}${(tL.#t3*d).toFixed(2)}px)`,u.fontFamily=l,r.fontSize=d,i.setAttribute("role","presentation"),i.textContent=e.str,i.dir=e.dir,this.#tH&&(i.dataset.fontName=a.fontSubstitutionLoadedName||e.fontName),0!==s&&(r.angle=180/Math.PI*s);let p=!1;if(e.str.length>1)p=!0;else if(" "!==e.str&&e.transform[0]!==e.transform[3]){let t=Math.abs(e.transform[0]),n=Math.abs(e.transform[3]);t!==n&&Math.max(t,n)/Math.min(t,n)>1.5&&(p=!0)}if(p&&(r.canvasWidth=a.vertical?e.height:e.width),this.#t0.set(i,r),this.#tU.div=i,this.#tU.properties=r,this.#t9(this.#tU),r.hasText&&this.#eg.append(i),r.hasEOL){let e=document.createElement("br");e.setAttribute("role","presentation"),this.#eg.append(e)}}#t9(e){let{div:t,properties:n,ctx:i,prevFontSize:r,prevFontFamily:o}=e,{style:s}=t,a="";if(tL.#t3>1&&(a=`scale(${1/tL.#t3})`),0!==n.canvasWidth&&n.hasText){let{fontFamily:l}=s,{canvasWidth:d,fontSize:c}=n;(r!==c||o!==l)&&(i.font=`${c*this.#tZ}px ${l}`,e.prevFontSize=c,e.prevFontFamily=l);let{width:h}=i.measureText(t.textContent);h>0&&(a=`scaleX(${d*this.#tZ/h}) ${a}`)}0!==n.angle&&(a=`rotate(${n.angle}deg) ${a}`),a.length>0&&(s.transform=a)}static cleanup(){if(!(this.#t4.size>0)){for(let{canvas:e}of(this.#t2.clear(),this.#t5.values()))e.remove();this.#t5.clear()}}static #t7(e=null){let t=this.#t5.get(e||="");if(!t){let n=document.createElement("canvas");n.className="hiddenCanvasElement",n.lang=e,document.body.append(n),t=n.getContext("2d",{alpha:!1,willReadFrequently:!0}),this.#t5.set(e,t)}return t}static #t6(){if(null!==this.#t3)return;let e=document.createElement("div");e.style.opacity=0,e.style.lineHeight=1,e.style.fontSize="1px",e.textContent="X",document.body.append(e),this.#t3=e.getBoundingClientRect().height,e.remove()}static #nt(e,t){let n=this.#t2.get(e);if(n)return n;let i=this.#t7(t),r=i.font;i.canvas.width=i.canvas.height=30,i.font=`30px ${e}`;let o=i.measureText(""),s=o.fontBoundingBoxAscent,a=Math.abs(o.fontBoundingBoxDescent);if(s){let t=s/(s+a);return this.#t2.set(e,t),i.canvas.width=i.canvas.height=0,i.font=r,t}i.strokeStyle="red",i.clearRect(0,0,30,30),i.strokeText("g",0,0);let l=i.getImageData(0,0,30,30).data;a=0;for(let e=l.length-1-3;e>=0;e-=4)if(l[e]>0){a=Math.ceil(e/4/30);break}i.clearRect(0,0,30,30),i.strokeText("A",0,30),l=i.getImageData(0,0,30,30).data,s=0;for(let e=0,t=l.length;e0){s=30-Math.floor(e/4/30);break}i.canvas.width=i.canvas.height=0,i.font=r;let d=s?s/(s+a):.8;return this.#t2.set(e,d),d}}function tj(){ef("`renderTextLayer`, please use `TextLayer` instead.");let{textContentSource:e,container:t,viewport:n,...i}=arguments[0],r=Object.keys(i);r.length>0&&C("Ignoring `renderTextLayer` parameters: "+r.join(", "));let o=new tL({textContentSource:e,container:t,viewport:n}),{textDivs:s,textContentItemsStr:a}=o;return{promise:o.render(),textDivs:s,textContentItemsStr:a}}function tF(){ef("`updateTextLayer`, please use `TextLayer` instead.")}class tB{static textContent(e){let t=[],n={items:t,styles:Object.create(null)};return!function e(n){if(!n)return;let i=null,r=n.name;if("#text"===r)i=n.value;else{if(!tB.shouldBuildText(r))return;n?.attributes?.textContent?i=n.attributes.textContent:n.value&&(i=n.value)}if(null!==i&&t.push({str:i}),!!n.children)for(let t of n.children)e(t)}(e),n}static shouldBuildText(e){return!("textarea"===e||"input"===e||"option"===e||"select"===e)}}let tz=s?class e extends Z{_createCanvas(e,t){return eH.get("canvas").createCanvas(e,t)}}:class e extends Z{constructor({ownerDocument:e=globalThis.document,enableHWA:t=!1}={}){super({enableHWA:t}),this._document=e}_createCanvas(e,t){let n=this._document.createElement("canvas");return n.width=e,n.height=t,n}},tH=s?class e extends Y{_fetchData(e,t){return eV(e).then(e=>({cMapData:e,compressionType:t}))}}:en,tV=s?class e extends K{}:class e extends K{#nn;#ni;#nr;#no;#ns;#v=0;constructor({docId:e,ownerDocument:t=globalThis.document}={}){super(),this.#nr=e,this.#no=t}get #y(){return this.#nn||=new Map}get #na(){return this.#ns||=new Map}get #nl(){if(!this.#ni){let e=this.#no.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;let n=this.#no.createElementNS(Q,"svg");n.setAttribute("width",0),n.setAttribute("height",0),this.#ni=this.#no.createElementNS(Q,"defs"),e.append(n),n.append(this.#ni),this.#no.body.append(e)}return this.#ni}#nd(e){if(1===e.length){let t=e[0],n=Array(256);for(let e=0;e<256;e++)n[e]=t[e]/255;let i=n.join(",");return[i,i,i]}let[t,n,i]=e,r=Array(256),o=Array(256),s=Array(256);for(let e=0;e<256;e++)r[e]=t[e]/255,o[e]=n[e]/255,s[e]=i[e]/255;return[r.join(","),o.join(","),s.join(",")]}addFilter(e){if(!e)return"none";let t=this.#y.get(e);if(t)return t;let[n,i,r]=this.#nd(e),o=1===e.length?n:`${n}${i}${r}`;if(t=this.#y.get(o))return this.#y.set(e,t),t;let s=`g_${this.#nr}_transfer_map_${this.#v++}`,a=`url(#${s})`;this.#y.set(e,a),this.#y.set(o,a);let l=this.#nc(s);return this.#nh(n,i,r,l),a}addHCMFilter(e,t){let n=`${e}-${t}`,i="base",r=this.#na.get(i);if(r?.key===n)return r.url;if(r?(r.filter?.remove(),r.key=n,r.url="none",r.filter=null):(r={key:n,url:"none",filter:null},this.#na.set(i,r)),!e||!t)return r.url;let o=this.#nu(e);e=V.makeHexColor(...o);let s=this.#nu(t);if(t=V.makeHexColor(...s),this.#nl.style.color="","#000000"===e&&"#ffffff"===t||e===t)return r.url;let a=Array(256);for(let e=0;e<=255;e++){let t=e/255;a[e]=t<=.03928?t/12.92:((t+.055)/1.055)**2.4}let l=a.join(","),d=`g_${this.#nr}_hcm_filter`,c=r.filter=this.#nc(d);this.#nh(l,l,l,c),this.#np(c);let h=(e,t)=>{let n=o[e]/255,i=s[e]/255,r=Array(t+1);for(let e=0;e<=t;e++)r[e]=n+e/t*(i-n);return r.join(",")};return this.#nh(h(0,5),h(1,5),h(2,5),c),r.url=`url(#${d})`,r.url}addAlphaFilter(e){let t=this.#y.get(e);if(t)return t;let[n]=this.#nd([e]),i=`alpha_${n}`;if(t=this.#y.get(i))return this.#y.set(e,t),t;let r=`g_${this.#nr}_alpha_map_${this.#v++}`,o=`url(#${r})`;this.#y.set(e,o),this.#y.set(i,o);let s=this.#nc(r);return this.#nf(n,s),o}addLuminosityFilter(e){let t,n,i=this.#y.get(e||"luminosity");if(i)return i;if(e?([t]=this.#nd([e]),n=`luminosity_${t}`):n="luminosity",i=this.#y.get(n))return this.#y.set(e,i),i;let r=`g_${this.#nr}_luminosity_map_${this.#v++}`,o=`url(#${r})`;this.#y.set(e,o),this.#y.set(n,o);let s=this.#nc(r);return this.#nm(s),e&&this.#nf(t,s),o}addHighlightHCMFilter(e,t,n,i,r){let o=`${t}-${n}-${i}-${r}`,s=this.#na.get(e);if(s?.key===o)return s.url;if(s?(s.filter?.remove(),s.key=o,s.url="none",s.filter=null):(s={key:o,url:"none",filter:null},this.#na.set(e,s)),!t||!n)return s.url;let[a,l]=[t,n].map(this.#nu.bind(this)),d=Math.round(.2126*a[0]+.7152*a[1]+.0722*a[2]),c=Math.round(.2126*l[0]+.7152*l[1]+.0722*l[2]),[h,u]=[i,r].map(this.#nu.bind(this));c{let i=Array(256),r=(c-d)/n,o=e/255,s=(t-e)/(255*n),a=0;for(let e=0;e<=n;e++){let t=Math.round(d+e*r),n=o+e*s;for(let e=a;e<=t;e++)i[e]=n;a=t+1}for(let e=a;e<256;e++)i[e]=i[a-1];return i.join(",")},f=`g_${this.#nr}_hcm_${e}_filter`,m=s.filter=this.#nc(f);return this.#np(m),this.#nh(p(h[0],u[0],5),p(h[1],u[1],5),p(h[2],u[2],5),m),s.url=`url(#${f})`,s.url}destroy(e=!1){if(!e||0===this.#na.size)this.#ni&&(this.#ni.parentNode.parentNode.remove(),this.#ni=null),this.#nn&&(this.#nn.clear(),this.#nn=null),this.#v=0}#nm(e){let t=this.#no.createElementNS(Q,"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)}#np(e){let t=this.#no.createElementNS(Q,"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)}#nc(e){let t=this.#no.createElementNS(Q,"filter");return t.setAttribute("color-interpolation-filters","sRGB"),t.setAttribute("id",e),this.#nl.append(t),t}#ng(e,t,n){let i=this.#no.createElementNS(Q,t);i.setAttribute("type","discrete"),i.setAttribute("tableValues",n),e.append(i)}#nh(e,t,n,i){let r=this.#no.createElementNS(Q,"feComponentTransfer");i.append(r),this.#ng(r,"feFuncR",e),this.#ng(r,"feFuncG",t),this.#ng(r,"feFuncB",n)}#nf(e,t){let n=this.#no.createElementNS(Q,"feComponentTransfer");t.append(n),this.#ng(n,"feFuncA",e)}#nu(e){return this.#nl.style.color=e,ev(getComputedStyle(this.#nl).getPropertyValue("color"))}},tU=s?class e extends X{_fetchData(e){return eV(e)}}:ei;function t$(e={}){var t;"string"==typeof e||e instanceof URL?e={url:e}:(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let n=new tq,{docId:i}=n,r=e.url?function(e){if(e instanceof URL)return e.href;try{return new URL(e,window.location).href}catch{if(s&&"string"==typeof e)return e}throw Error("Invalid PDF url data: either string or URL-object is expected in the url property.")}(e.url):null,o=e.data?function(e){if(s&&"undefined"!=typeof Buffer&&e instanceof Buffer)throw 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 F(e);if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)||"object"==typeof e&&!isNaN(e?.length))return new Uint8Array(e);throw Error("Invalid PDF binary data: either TypedArray, string, or array-like object is expected in the data property.")}(e.data):null,a=e.httpHeaders||null,l=!0===e.withCredentials,d=e.password??null,c=e.range instanceof tG?e.range:null,h=Number.isInteger(e.rangeChunkSize)&&e.rangeChunkSize>0?e.rangeChunkSize:65536,u=e.worker instanceof tJ?e.worker:null,p=e.verbosity,f="string"!=typeof e.docBaseUrl||ea(e.docBaseUrl)?null:e.docBaseUrl,m="string"==typeof e.cMapUrl?e.cMapUrl:null,g=!1!==e.cMapPacked,v=e.CMapReaderFactory||tH,b="string"==typeof e.standardFontDataUrl?e.standardFontDataUrl:null,y=e.StandardFontDataFactory||tU,x=!0!==e.stopAtErrors,w=Number.isInteger(e.maxImageSize)&&e.maxImageSize>-1?e.maxImageSize:-1,S=!1!==e.isEvalSupported,C="boolean"==typeof e.isOffscreenCanvasSupported?e.isOffscreenCanvasSupported:!s,A=Number.isInteger(e.canvasMaxAreaInBytes)?e.canvasMaxAreaInBytes:-1,E="boolean"==typeof e.disableFontFace?e.disableFontFace:s,k=!0===e.fontExtraProperties,T=!0===e.enableXfa,M=e.ownerDocument||globalThis.document,D=!0===e.disableRange,O=!0===e.disableStream,I=!0===e.disableAutoFetch,N=!0===e.pdfBug,P=!0===e.enableHWA,R=c?c.length:e.length??NaN,L="boolean"==typeof e.useSystemFonts?e.useSystemFonts:!s&&!E,j="boolean"==typeof e.useWorkerFetch?e.useWorkerFetch:v===en&&y===ei&&m&&b&&eu(m,document.baseURI)&&eu(b,document.baseURI),B=e.canvasFactory||new tz({ownerDocument:M,enableHWA:P}),z=e.filterFactory||new tV({docId:i,ownerDocument:M});Number.isInteger(t=p)&&(_=t);let H={canvasFactory:B,filterFactory:z};if(!j&&(H.cMapReaderFactory=new v({baseUrl:m,isCompressed:g}),H.standardFontDataFactory=new y({baseUrl:b})),!u){let e={verbosity:p,port:tt.workerPort};u=e.port?tJ.fromPort(e):new tJ(e),n._worker=u}let V={docId:i,apiVersion:"4.4.168",data:o,password:d,disableAutoFetch:I,rangeChunkSize:h,length:R,docBaseUrl:f,enableXfa:T,evaluatorOptions:{maxImageSize:w,disableFontFace:E,ignoreErrors:x,isEvalSupported:S,isOffscreenCanvasSupported:C,canvasMaxAreaInBytes:A,fontExtraProperties:k,useSystemFonts:L,cMapUrl:j?m:null,standardFontDataUrl:j?b:null}},U={disableFontFace:E,fontExtraProperties:k,ownerDocument:M,pdfBug:N,styleElement:null,loadingParams:{disableAutoFetch:I,enableXfa:T}};return u.promise.then(function(){let e;if(n.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let t=u.messageHandler.sendWithPromise("GetDocRequest",V,o?[o.buffer]:null);if(c)e=new tc(c,{disableRange:D,disableStream:O});else if(!o){var d;if(!r)throw Error("getDocument - no `url` parameter provided.");d={url:r,length:R,httpHeaders:a,withCredentials:l,rangeChunkSize:h,disableRange:D,disableStream:O},e=s?"undefined"!=typeof fetch&&"undefined"!=typeof Response&&"body"in Response.prototype&&eu(d.url)?new tx(d):new tT(d):eu(d.url)?new tx(d):new tC(d)}return t.then(t=>{if(n.destroyed)throw Error("Loading aborted");if(u.destroyed)throw Error("Worker was destroyed");let r=new to(i,t,u.port),o=new tQ(r,n,e,U,H);n._transport=o,r.send("Ready",null)})}).catch(n._capability.reject),n}function tW(e){return"object"==typeof e&&Number.isInteger(e?.num)&&e.num>=0&&Number.isInteger(e?.gen)&&e.gen>=0}class tq{static #nr=0;constructor(){this._capability=Promise.withResolvers(),this._transport=null,this._worker=null,this.docId=`d${tq.#nr++}`,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&&(this._worker.destroy(),this._worker=null)}}class tG{constructor(e,t,n=!1,i=null){this.length=e,this.initialData=t,this.progressiveDone=n,this.contentDispositionFilename=i,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(let n of this._rangeListeners)n(e,t)}onDataProgress(e,t){this._readyCapability.promise.then(()=>{for(let n of this._progressListeners)n(e,t)})}onDataProgressiveRead(e){this._readyCapability.promise.then(()=>{for(let t of this._progressiveReadListeners)t(e)})}onDataProgressiveDone(){this._readyCapability.promise.then(()=>{for(let e of this._progressiveDoneListeners)e()})}transportReady(){this._readyCapability.resolve()}requestDataRange(e,t){A("Abstract method PDFDataRangeTransport.requestDataRange")}abort(){}}class tK{constructor(e,t){this._pdfInfo=e,this._transport=t}get annotationStorage(){return this._transport.annotationStorage}get filterFactory(){return this._transport.filterFactory}get numPages(){return this._pdfInfo.numPages}get fingerprints(){return this._pdfInfo.fingerprints}get isPureXfa(){return T(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"}={}){let{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 tZ{#nv=null;#nb=!1;constructor(e,t,n,i=!1){this._pageIndex=e,this._pageInfo=t,this._transport=n,this._stats=i?new eh:null,this._pdfBug=i,this.commonObjs=n.commonObjs,this.objs=new t1,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:i=0,dontFlip:r=!1}={}){return new eo({viewBox:this.view,scale:e,rotation:t,offsetX:n,offsetY:i,dontFlip:r})}getAnnotations({intent:e="display"}={}){let{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 T(this,"isPureXfa",!!this._transport._htmlForXfa)}async getXfa(){return this._transport._htmlForXfa?.children[this._pageIndex]||null}render({canvasContext:e,viewport:t,intent:n="display",annotationMode:i=c.ENABLE,transform:r=null,background:o=null,optionalContentConfigPromise:s=null,annotationCanvasMap:a=null,pageColors:l=null,printAnnotationStorage:h=null}){this._stats?.time("Overall");let u=this._transport.getRenderingIntent(n,i,h),{renderingIntent:p,cacheKey:f}=u;this.#nb=!1,this.#ny(),s||=this._transport.getOptionalContentConfig(p);let m=this._intentStates.get(f);!m&&(m=Object.create(null),this._intentStates.set(f,m)),m.streamReaderCancelTimeout&&(clearTimeout(m.streamReaderCancelTimeout),m.streamReaderCancelTimeout=null);let g=!!(p&d.PRINT);!m.displayReadyCapability&&(m.displayReadyCapability=Promise.withResolvers(),m.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(u));let v=e=>{m.renderTasks.delete(b),(this._maybeCleanupAfterRender||g)&&(this.#nb=!0),this.#nx(!g),e?(b.capability.reject(e),this._abortOperatorList({intentState:m,reason:e instanceof Error?e:Error(e)})):b.capability.resolve(),this._stats&&(this._stats.timeEnd("Rendering"),this._stats.timeEnd("Overall"),globalThis.Stats?.enabled&&globalThis.Stats.add(this.pageNumber,this._stats))},b=new t5({callback:v,params:{canvasContext:e,viewport:t,transform:r,background:o},objs:this.objs,commonObjs:this.commonObjs,annotationCanvasMap:a,operatorList:m.operatorList,pageIndex:this._pageIndex,canvasFactory:this._transport.canvasFactory,filterFactory:this._transport.filterFactory,useRequestAnimationFrame:!g,pdfBug:this._pdfBug,pageColors:l});(m.renderTasks||=new Set).add(b);let y=b.task;return Promise.all([m.displayReadyCapability.promise,s]).then(([e,t])=>{if(this.destroyed){v();return}if(this._stats?.time("Rendering"),!(t.renderingIntent&p))throw Error("Must use the same `intent`-argument when calling the `PDFPageProxy.render` and `PDFDocumentProxy.getOptionalContentConfig` methods.");b.initializeGraphics({transparency:e,optionalContentConfig:t}),b.operatorListChanged()}).catch(v),y}getOperatorList({intent:e="display",annotationMode:t=c.ENABLE,printAnnotationStorage:n=null}={}){let i;let r=this._transport.getRenderingIntent(e,t,n,!0),o=this._intentStates.get(r.cacheKey);return!o&&(o=Object.create(null),this._intentStates.set(r.cacheKey,o)),!o.opListReadCapability&&((i=Object.create(null)).operatorListChanged=function(){o.operatorList.lastChunk&&(o.opListReadCapability.resolve(o.operatorList),o.renderTasks.delete(i))},o.opListReadCapability=Promise.withResolvers(),(o.renderTasks||=new Set).add(i),o.operatorList={fnArray:[],argsArray:[],lastChunk:!1,separateAnnots:null},this._stats?.time("Page Request"),this._pumpOperatorList(r)),o.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=>tB.textContent(e));let t=this.streamTextContent(e);return new Promise(function(e,n){let i=t.getReader(),r={items:[],styles:Object.create(null),lang:null};!function t(){i.read().then(function({value:n,done:i}){if(i){e(r);return}r.lang??=n.lang,Object.assign(r.styles,n.styles),r.items.push(...n.items),t()},n)}()})}getStructTree(){return this._transport.getStructTree(this._pageIndex)}_destroy(){this.destroyed=!0;let e=[];for(let t of this._intentStates.values()){if(this._abortOperatorList({intentState:t,reason:Error("Page was destroyed."),force:!0}),!t.opListReadCapability)for(let n of t.renderTasks)e.push(n.completed),n.cancel()}return this.objs.clear(),this.#nb=!1,this.#ny(),Promise.all(e)}cleanup(e=!1){this.#nb=!0;let t=this.#nx(!1);return e&&t&&(this._stats&&=new eh),t}#nx(e=!1){if(this.#ny(),!this.#nb||this.destroyed)return!1;if(e)return this.#nv=setTimeout(()=>{this.#nv=null,this.#nx(!1)},5e3),!1;for(let{renderTasks:e,operatorList:t}of this._intentStates.values())if(e.size>0||!t.lastChunk)return!1;return this._intentStates.clear(),this.objs.clear(),this.#nb=!1,!0}#ny(){this.#nv&&(clearTimeout(this.#nv),this.#nv=null)}_startRenderPage(e,t){let n=this._intentStates.get(t);if(!!n)this._stats?.timeEnd("Page Request"),n.displayReadyCapability?.resolve(e)}_renderPageChunk(e,t){for(let n=0,i=e.length;n{o.read().then(({value:e,done:t})=>{if(t){s.streamReader=null;return}if(!this._transport.destroyed)this._renderPageChunk(e,s),a()},e=>{if(s.streamReader=null,!this._transport.destroyed){if(s.operatorList){for(let e of(s.operatorList.lastChunk=!0,s.renderTasks))e.operatorListChanged();this.#nx(!0)}if(s.displayReadyCapability)s.displayReadyCapability.reject(e);else if(s.opListReadCapability)s.opListReadCapability.reject(e);else throw e}})};a()}_abortOperatorList({intentState:e,reason:t,force:n=!1}){if(!e.streamReader)return;if(e.streamReaderCancelTimeout&&(clearTimeout(e.streamReaderCancelTimeout),e.streamReaderCancelTimeout=null),!n){if(e.renderTasks.size>0)return;if(t instanceof es){let n=100;t.extraDelay>0&&t.extraDelay<1e3&&(n+=t.extraDelay),e.streamReaderCancelTimeout=setTimeout(()=>{e.streamReaderCancelTimeout=null,this._abortOperatorList({intentState:e,reason:t,force:!0})},n);return}}if(e.streamReader.cancel(new L(t.message)).catch(()=>{}),e.streamReader=null,!this._transport.destroyed){for(let[t,n]of this._intentStates)if(n===e){this._intentStates.delete(t);break}this.cleanup()}}get stats(){return this._stats}}class tY{#nw=new Set;#n_=Promise.resolve();postMessage(e,t){let n={data:structuredClone(e,t?{transfer:t}:null)};this.#n_.then(()=>{for(let e of this.#nw)e.call(this,n)})}addEventListener(e,t){this.#nw.add(t)}removeEventListener(e,t){this.#nw.delete(t)}terminate(){this.#nw.clear()}}let tX={isWorkerDisabled:!1,fakeWorkerId:0};s&&(tX.isWorkerDisabled=!0,tt.workerSrc||="./pdf.worker.mjs"),tX.isSameOrigin=function(e,t){let n;try{if(!(n=new URL(e)).origin||"null"===n.origin)return!1}catch{return!1}let i=new URL(t,n);return n.origin===i.origin},tX.createCDNWrapper=function(e){let t=`await import("${e}");`;return URL.createObjectURL(new Blob([t],{type:"text/javascript"}))};class tJ{static #nS;constructor({name:e=null,port:t=null,verbosity:n=_}={}){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(tJ.#nS?.has(t))throw Error("Cannot use more than one PDFWorker per port.");(tJ.#nS||=new WeakMap).set(t,this),this._initializeFromPort(t);return}this._initialize()}get promise(){return s?Promise.all([eH.promise,this._readyCapability.promise]):this._readyCapability.promise}#nC(){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 to("main","worker",e),this._messageHandler.on("ready",function(){}),this.#nC()}_initialize(){if(tX.isWorkerDisabled||tJ.#nA){this._setupFakeWorker();return}let{workerSrc:e}=tJ;try{!tX.isSameOrigin(window.location.href,e)&&(e=tX.createCDNWrapper(new URL(e,window.location).href));let t=new Worker(e,{type:"module"}),n=new to("main","worker",t),i=()=>{r.abort(),n.destroy(),t.terminate(),this.destroyed?this._readyCapability.reject(Error("Worker was destroyed")):this._setupFakeWorker()},r=new AbortController;t.addEventListener("error",()=>{!this._webWorker&&i()},{signal:r.signal}),n.on("test",e=>{if(r.abort(),this.destroyed||!e){i();return}this._messageHandler=n,this._port=t,this._webWorker=t,this.#nC()}),n.on("ready",e=>{if(r.abort(),this.destroyed){i();return}try{o()}catch{this._setupFakeWorker()}});let o=()=>{let e=new Uint8Array;n.send("test",e,[e.buffer])};o();return}catch{S("The worker has been disabled.")}this._setupFakeWorker()}_setupFakeWorker(){!tX.isWorkerDisabled&&(C("Setting up fake worker."),tX.isWorkerDisabled=!0),tJ._setupFakeWorkerGlobal.then(e=>{if(this.destroyed){this._readyCapability.reject(Error("Worker was destroyed"));return}let t=new tY;this._port=t;let n=`fake${tX.fakeWorkerId++}`,i=new to(n+"_worker",n,t);e.setup(i,t),this._messageHandler=new to(n,n+"_worker",t),this.#nC()}).catch(e=>{this._readyCapability.reject(Error(`Setting up fake worker failed: "${e.message}".`))})}destroy(){this.destroyed=!0,this._webWorker&&(this._webWorker.terminate(),this._webWorker=null),tJ.#nS?.delete(this._port),this._port=null,this._messageHandler&&(this._messageHandler.destroy(),this._messageHandler=null)}static fromPort(e){if(!e?.port)throw Error("PDFWorker.fromPort - invalid method signature.");let t=this.#nS?.get(e.port);if(t){if(t._pendingDestroy)throw Error("PDFWorker.fromPort - the worker is being destroyed.\nPlease remember to await `PDFDocumentLoadingTask.destroy()`-calls.");return t}return new tJ(e)}static get workerSrc(){if(tt.workerSrc)return tt.workerSrc;throw Error('No "GlobalWorkerOptions.workerSrc" specified.')}static get #nA(){try{return globalThis.pdfjsWorker?.WorkerMessageHandler||null}catch{return null}}static get _setupFakeWorkerGlobal(){return T(this,"_setupFakeWorkerGlobal",(async()=>this.#nA?this.#nA:(await import(this.workerSrc)).WorkerMessageHandler)())}}class tQ{#nE=new Map;#nk=new Map;#nT=new Map;#nM=new Map;#nD=null;constructor(e,t,n,i,r){this.messageHandler=e,this.loadingTask=t,this.commonObjs=new t1,this.fontLoader=new ej({ownerDocument:i.ownerDocument,styleElement:i.styleElement}),this.loadingParams=i.loadingParams,this._params=i,this.canvasFactory=r.canvasFactory,this.filterFactory=r.filterFactory,this.cMapReaderFactory=r.cMapReaderFactory,this.standardFontDataFactory=r.standardFontDataFactory,this.destroyed=!1,this.destroyCapability=null,this._networkStream=n,this._fullReader=null,this._lastProgress=null,this.downloadInfoCapability=Promise.withResolvers(),this.setupMessageHandler()}#nO(e,t=null){let n=this.#nE.get(e);if(n)return n;let i=this.messageHandler.sendWithPromise(e,t);return this.#nE.set(e,i),i}get annotationStorage(){return T(this,"annotationStorage",new eR)}getRenderingIntent(e,t=c.ENABLE,n=null,i=!1){let r=d.DISPLAY,o=eP;switch(e){case"any":r=d.ANY;break;case"display":break;case"print":r=d.PRINT;break;default:C(`getRenderingIntent - invalid intent: ${e}`)}switch(t){case c.DISABLE:r+=d.ANNOTATIONS_DISABLE;break;case c.ENABLE:break;case c.ENABLE_FORMS:r+=d.ANNOTATIONS_FORMS;break;case c.ENABLE_STORAGE:o=((r+=d.ANNOTATIONS_STORAGE)&d.PRINT&&n instanceof eL?n:this.annotationStorage).serializable;break;default:C(`getRenderingIntent - invalid annotationMode: ${t}`)}return i&&(r+=d.OPLIST),{renderingIntent:r,cacheKey:`${r}_${o.hash}`,annotationStorageSerializable:o}}destroy(){if(this.destroyCapability)return this.destroyCapability.promise;this.destroyed=!0,this.destroyCapability=Promise.withResolvers(),this.#nD?.reject(Error("Worker was destroyed during onPassword callback"));let e=[];for(let t of this.#nk.values())e.push(t._destroy());this.#nk.clear(),this.#nT.clear(),this.#nM.clear(),this.hasOwnProperty("annotationStorage")&&this.annotationStorage.resetModified();let t=this.messageHandler.sendWithPromise("Terminate",null);return e.push(t),Promise.all(e).then(()=>{this.commonObjs.clear(),this.fontLoader.clear(),this.#nE.clear(),this.filterFactory.destroy(),tL.cleanup(),this._networkStream?.cancelAllRequests(new L("Worker was terminated.")),this.messageHandler&&(this.messageHandler.destroy(),this.messageHandler=null),this.destroyCapability.resolve()},this.destroyCapability.reject),this.destroyCapability.promise}setupMessageHandler(){let{messageHandler:e,loadingTask:t}=this;e.on("GetReader",(e,t)=>{E(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}){if(n){t.close();return}E(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",e=>{let n=Promise.withResolvers(),i=this._fullReader;return i.headersReady.then(()=>{(!i.isStreamingSupported||!i.isRangeSupported)&&(this._lastProgress&&t.onProgress?.(this._lastProgress),i.onProgress=e=>{t.onProgress?.({loaded:e.loaded,total:e.total})}),n.resolve({isStreamingSupported:i.isStreamingSupported,isRangeSupported:i.isRangeSupported,contentLength:i.contentLength})},n.reject),n.promise}),e.on("GetRangeReader",(e,t)=>{E(this._networkStream,"GetRangeReader - no `IPDFStream` instance available.");let n=this._networkStream.getRangeReader(e.begin,e.end);if(!n){t.close();return}t.onPull=()=>{n.read().then(function({value:e,done:n}){if(n){t.close();return}E(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})}}),e.on("GetDoc",({pdfInfo:e})=>{this._numPages=e.numPages,this._htmlForXfa=e.htmlForXfa,delete e.htmlForXfa,t._capability.resolve(new tK(e,this))}),e.on("DocException",function(e){let n;switch(e.name){case"PasswordException":n=new D(e.message,e.code);break;case"InvalidPDFException":n=new I(e.message);break;case"MissingPDFException":n=new N(e.message);break;case"UnexpectedResponseException":n=new P(e.message,e.status);break;case"UnknownErrorException":n=new O(e.message,e.details);break;default:A("DocException - expected a valid Error.")}t._capability.reject(n)}),e.on("PasswordRequest",e=>{if(this.#nD=Promise.withResolvers(),t.onPassword)try{t.onPassword(e=>{e instanceof Error?this.#nD.reject(e):this.#nD.resolve({password:e})},e.code)}catch(e){this.#nD.reject(e)}else this.#nD.reject(new D(e.message,e.code));return this.#nD.promise}),e.on("DataLoaded",e=>{t.onProgress?.({loaded:e.length,total:e.length}),this.downloadInfoCapability.resolve(e)}),e.on("StartRenderPage",e=>{if(!this.destroyed)this.#nk.get(e.pageIndex)._startRenderPage(e.transparency,e.cacheKey)}),e.on("commonobj",([t,n,i])=>{if(this.destroyed||this.commonObjs.has(t))return null;switch(n){case"Font":let{disableFontFace:r,fontExtraProperties:o,pdfBug:s}=this._params;if("error"in i){let e=i.error;C(`Error during font loading: ${e}`),this.commonObjs.resolve(t,e);break}let a=new eF(i,{disableFontFace:r,inspectFont:s&&globalThis.FontInspector?.enabled?(e,t)=>globalThis.FontInspector.fontAdded(e,t):null});this.fontLoader.bind(a).catch(()=>e.sendWithPromise("FontFallback",{id:t})).finally(()=>{!o&&a.data&&(a.data=null),this.commonObjs.resolve(t,a)});break;case"CopyLocalImage":let{imageRef:l}=i;for(let e of(E(l,"The imageRef must be defined."),this.#nk.values()))for(let[,n]of e.objs){if(n?.ref===l){if(!n.dataLen)return null;return this.commonObjs.resolve(t,structuredClone(n)),n.dataLen}}break;case"FontPath":case"Image":case"Pattern":this.commonObjs.resolve(t,i);break;default:throw Error(`Got unknown common object type ${n}`)}return null}),e.on("obj",([e,t,n,i])=>{if(this.destroyed)return;let r=this.#nk.get(t);if(!r.objs.has(e)){if(0===r._intentStates.size){i?.bitmap?.close();return}switch(n){case"Image":r.objs.resolve(e,i),i?.dataLen>1e7&&(r._maybeCleanupAfterRender=!0);break;case"Pattern":r.objs.resolve(e,i);break;default:throw Error(`Got unknown object type ${n}`)}}}),e.on("DocProgress",e=>{if(!this.destroyed)t.onProgress?.({loaded:e.loaded,total:e.total})}),e.on("FetchBuiltInCMap",e=>this.destroyed?Promise.reject(Error("Worker was destroyed.")):this.cMapReaderFactory?this.cMapReaderFactory.fetch(e):Promise.reject(Error("CMapReaderFactory not initialized, see the `useWorkerFetch` parameter."))),e.on("FetchStandardFontData",e=>this.destroyed?Promise.reject(Error("Worker was destroyed.")):this.standardFontDataFactory?this.standardFontDataFactory.fetch(e):Promise.reject(Error("StandardFontDataFactory not initialized, see the `useWorkerFetch` parameter.")))}getData(){return this.messageHandler.sendWithPromise("GetData",null)}saveDocument(){this.annotationStorage.size<=0&&C("saveDocument called while `annotationStorage` is empty, please use the getData-method instead.");let{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(Error("Invalid page request."));let t=e-1,n=this.#nT.get(t);if(n)return n;let i=this.messageHandler.sendWithPromise("GetPage",{pageIndex:t}).then(n=>{if(this.destroyed)throw Error("Transport destroyed");n.refStr&&this.#nM.set(n.refStr,e);let i=new tZ(t,n,this,this._params.pdfBug);return this.#nk.set(t,i),i});return this.#nT.set(t,i),i}getPageIndex(e){return tW(e)?this.messageHandler.sendWithPromise("GetPageIndex",{num:e.num,gen:e.gen}):Promise.reject(Error("Invalid pageIndex request."))}getAnnotations(e,t){return this.messageHandler.sendWithPromise("GetAnnotations",{pageIndex:e,intent:t})}getFieldObjects(){return this.#nO("GetFieldObjects")}hasJSActions(){return this.#nO("HasJSActions")}getCalculationOrderIds(){return this.messageHandler.sendWithPromise("GetCalculationOrderIds",null)}getDestinations(){return this.messageHandler.sendWithPromise("GetDestinations",null)}getDestination(e){return"string"!=typeof e?Promise.reject(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.#nO("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.#nO("GetOptionalContentConfig").then(t=>new td(t,e))}getPermissions(){return this.messageHandler.sendWithPromise("GetPermissions",null)}getMetadata(){let e="GetMetadata",t=this.#nE.get(e);if(t)return t;let n=this.messageHandler.sendWithPromise(e,null).then(e=>({info:e[0],metadata:e[1]?new ts(e[1]):null,contentDispositionFilename:this._fullReader?.filename??null,contentLength:this._fullReader?.contentLength??null}));return this.#nE.set(e,n),n}getMarkInfo(){return this.messageHandler.sendWithPromise("GetMarkInfo",null)}async startCleanup(e=!1){if(!this.destroyed){for(let e of(await this.messageHandler.sendWithPromise("Cleanup",null),this.#nk.values()))if(!e.cleanup())throw Error(`startCleanup: Page ${e.pageNumber} is currently rendering.`);this.commonObjs.clear(),!e&&this.fontLoader.clear(),this.#nE.clear(),this.filterFactory.destroy(!0),tL.cleanup()}}cachedPageNumber(e){if(!tW(e))return null;let t=0===e.gen?`${e.num}R`:`${e.num}R${e.gen}`;return this.#nM.get(t)??null}}let t0=Symbol("INITIAL_DATA");class t1{#nI=Object.create(null);#nN(e){return this.#nI[e]||={...Promise.withResolvers(),data:t0}}get(e,t=null){if(t){let n=this.#nN(e);return n.promise.then(()=>t(n.data)),null}let n=this.#nI[e];if(!n||n.data===t0)throw Error(`Requesting object that isn't resolved yet ${e}.`);return n.data}has(e){let t=this.#nI[e];return!!t&&t.data!==t0}resolve(e,t=null){let n=this.#nN(e);n.data=t,n.resolve()}clear(){for(let e in this.#nI){let{data:t}=this.#nI[e];t?.bitmap?.close()}this.#nI=Object.create(null)}*[Symbol.iterator](){for(let e in this.#nI){let{data:t}=this.#nI[e];if(t!==t0)yield[e,t]}}}class t2{#nP=null;constructor(e){this.#nP=e,this.onContinue=null}get promise(){return this.#nP.capability.promise}cancel(e=0){this.#nP.cancel(null,e)}get separateAnnots(){let{separateAnnots:e}=this.#nP.operatorList;if(!e)return!1;let{annotationCanvasMap:t}=this.#nP;return e.form||e.canvas&&t?.size>0}}class t5{#nR=null;static #nL=new WeakSet;constructor({callback:e,params:t,objs:n,commonObjs:i,annotationCanvasMap:r,operatorList:o,pageIndex:s,canvasFactory:a,filterFactory:l,useRequestAnimationFrame:d=!1,pdfBug:c=!1,pageColors:h=null}){this.callback=e,this.params=t,this.objs=n,this.commonObjs=i,this.annotationCanvasMap=r,this.operatorListIdx=null,this.operatorList=o,this._pageIndex=s,this.canvasFactory=a,this.filterFactory=l,this._pdfBug=c,this.pageColors=h,this.running=!1,this.graphicsReadyCallback=null,this.graphicsReady=!1,this._useRequestAnimationFrame=!0===d&&"undefined"!=typeof window,this.cancelled=!1,this.capability=Promise.withResolvers(),this.task=new t2(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(t5.#nL.has(this._canvas))throw Error("Cannot use the same canvas during multiple render() operations. Use different canvas or ensure previous operations were cancelled or completed.");t5.#nL.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());let{canvasContext:n,viewport:i,transform:r,background:o}=this.params;this.gfx=new te(n,this.commonObjs,this.objs,this.canvasFactory,this.filterFactory,{optionalContentConfig:t},this.annotationCanvasMap,this.pageColors),this.gfx.beginDrawing({transform:r,viewport:i,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.#nR&&(window.cancelAnimationFrame(this.#nR),this.#nR=null),t5.#nL.delete(this._canvas),this.callback(e||new es(`Rendering cancelled, page ${this._pageIndex+1}`,t))}operatorListChanged(){if(!this.graphicsReady){this.graphicsReadyCallback||=this._continueBound;return}if(this.stepper?.updateOperatorList(this.operatorList),!this.running)this._continue()}_continue(){if(this.running=!0,!this.cancelled)this.task.onContinue?this.task.onContinue(this._scheduleNextBound):this._scheduleNext()}_scheduleNext(){this._useRequestAnimationFrame?this.#nR=window.requestAnimationFrame(()=>{this.#nR=null,this._nextBound().catch(this._cancelBound)}):Promise.resolve().then(this._nextBound).catch(this._cancelBound)}async _next(){if(!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(),t5.#nL.delete(this._canvas),this.callback()))}}let t3="4.4.168",t4="19fbc8998";function t6(e){return Math.floor(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0")}function t8(e){return Math.max(0,Math.min(255,255*e))}class t7{static CMYK_G([e,t,n,i]){return["G",1-Math.min(1,.3*e+.59*n+.11*t+i)]}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=t8(e),e,e]}static G_HTML([e]){let t=t6(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(t8)}static RGB_HTML(e){return`#${e.map(t6).join("")}`}static T_HTML(){return"#00000000"}static T_rgb(){return[null]}static CMYK_RGB([e,t,n,i]){return["RGB",1-Math.min(1,e+i),1-Math.min(1,n+i),1-Math.min(1,t+i)]}static CMYK_rgb([e,t,n,i]){return[t8(1-Math.min(1,e+i)),t8(1-Math.min(1,n+i)),t8(1-Math.min(1,t+i))]}static CMYK_HTML(e){let t=this.CMYK_RGB(e).slice(1);return this.RGB_HTML(t)}static RGB_CMYK([e,t,n]){let i=1-e,r=1-t,o=1-n,s=Math.min(i,r,o);return["CMYK",i,r,o,s]}}class t9{static setupStorage(e,t,n,i,r){let o=i.getValue(t,{value:null});switch(n.name){case"textarea":if(null!==o.value&&(e.textContent=o.value),"print"===r)break;e.addEventListener("input",e=>{i.setValue(t,{value:e.target.value})});break;case"input":if("radio"===n.attributes.type||"checkbox"===n.attributes.type){if(o.value===n.attributes.xfaOn?e.setAttribute("checked",!0):o.value===n.attributes.xfaOff&&e.removeAttribute("checked"),"print"===r)break;e.addEventListener("change",e=>{i.setValue(t,{value:e.target.checked?e.target.getAttribute("xfaOn"):e.target.getAttribute("xfaOff")})})}else{if(null!==o.value&&e.setAttribute("value",o.value),"print"===r)break;e.addEventListener("input",e=>{i.setValue(t,{value:e.target.value})})}break;case"select":if(null!==o.value)for(let t of(e.setAttribute("value",o.value),n.children))t.attributes.value===o.value?t.attributes.selected=!0:t.attributes.hasOwnProperty("selected")&&delete t.attributes.selected;e.addEventListener("input",e=>{let n=e.target.options,r=-1===n.selectedIndex?"":n[n.selectedIndex].value;i.setValue(t,{value:r})})}}static setAttributes({html:e,element:t,storage:n=null,intent:i,linkService:r}){let{attributes:o}=t,s=e instanceof HTMLAnchorElement;for(let[t,n]of("radio"===o.type&&(o.name=`${o.name}-${i}`),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:(!s||"href"!==t&&"newWindow"!==t)&&e.setAttribute(t,n)}}s&&r.addLinkAttributes(e,o.href,o.newWindow),n&&o.dataId&&this.setupStorage(e,o.dataId,t,n)}static render(e){let t=e.annotationStorage,n=e.linkService,i=e.xfaHtml,r=e.intent||"display",o=document.createElement(i.name);i.attributes&&this.setAttributes({html:o,element:i,intent:r,linkService:n});let s="richText"!==r,a=e.div;if(a.append(o),e.viewport){let t=`matrix(${e.viewport.transform.join(",")})`;a.style.transform=t}s&&a.setAttribute("class","xfaLayer xfaFont");let l=[];if(0===i.children.length){if(i.value){let e=document.createTextNode(i.value);o.append(e),s&&tB.shouldBuildText(i.name)&&l.push(e)}return{textDivs:l}}let d=[[i,-1,o]];for(;d.length>0;){let[e,i,o]=d.at(-1);if(i+1===e.children.length){d.pop();continue}let a=e.children[++d.at(-1)[1]];if(null===a)continue;let{name:c}=a;if("#text"===c){let e=document.createTextNode(a.value);l.push(e),o.append(e);continue}let h=a?.attributes?.xmlns?document.createElementNS(a.attributes.xmlns,c):document.createElement(c);if(o.append(h),a.attributes&&this.setAttributes({html:h,element:a,storage:t,intent:r,linkService:n}),a.children?.length>0)d.push([a,-1,h]);else if(a.value){let e=document.createTextNode(a.value);s&&tB.shouldBuildText(c)&&l.push(e),h.append(e)}}for(let e of a.querySelectorAll(".xfaNonInteractive input, .xfaNonInteractive textarea"))e.setAttribute("readOnly",!0);return{textDivs:l}}static update(e){let t=`matrix(${e.viewport.transform.join(",")})`;e.div.style.transform=t,e.div.hidden=!1}}let ne=new WeakSet;function nt(e){return{width:e[2]-e[0],height:e[3]-e[1]}}class nn{static create(e){switch(e.data.annotationType){case g.LINK:return new nr(e);case g.TEXT:return new no(e);case g.WIDGET:switch(e.data.fieldType){case"Tx":return new na(e);case"Btn":if(e.data.radioButton)return new nc(e);if(e.data.checkBox)return new nd(e);return new nh(e);case"Ch":return new nu(e);case"Sig":return new nl(e)}return new ns(e);case g.POPUP:return new np(e);case g.FREETEXT:return new nm(e);case g.LINE:return new ng(e);case g.SQUARE:return new nv(e);case g.CIRCLE:return new nb(e);case g.POLYLINE:return new ny(e);case g.CARET:return new nw(e);case g.INK:return new n_(e);case g.POLYGON:return new nx(e);case g.HIGHLIGHT:return new nS(e);case g.UNDERLINE:return new nC(e);case g.SQUIGGLY:return new nA(e);case g.STRIKEOUT:return new nE(e);case g.STAMP:return new nk(e);case g.FILEATTACHMENT:return new nT(e);default:return new ni(e)}}}class ni{#nj=null;#nF=!1;#nB=null;constructor(e,{isRenderable:t=!1,ignoreBorder:n=!1,createQuadrilaterals:i=!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)),i&&this._createQuadrilaterals()}static _hasPopupData({titleObj:e,contentsObj:t,richText:n}){return!!(e?.str||t?.str||n?.str)}get hasPopupData(){return ni._hasPopupData(this.data)}updateEdited(e){if(!this.container)return;this.#nj||={rect:this.data.rect.slice(0)};let{rect:t}=e;t&&this.#nz(t),this.#nB?.popup.updateEdited(e)}resetEdited(){if(!!this.#nj)this.#nz(this.#nj.rect),this.#nB?.popup.resetEdited(),this.#nj=null}#nz(e){let{container:{style:t},data:{rect:n,rotation:i},parent:{viewport:{rawDims:{pageWidth:r,pageHeight:o,pageX:s,pageY:a}}}}=this;n?.splice(0,4,...e);let{width:l,height:d}=nt(e);t.left=`${100*(e[0]-s)/r}%`,t.top=`${100*(o-e[3]+a)/o}%`,0===i?(t.width=`${100*l/r}%`,t.height=`${100*d/o}%`):this.setRotation(i)}_createContainer(e){let{data:t,parent:{page:n,viewport:i}}=this,r=document.createElement("section");r.setAttribute("data-annotation-id",t.id),!(this instanceof ns)&&(r.tabIndex=1e3);let{style:o}=r;if(o.zIndex=this.parent.zIndex++,t.popupRef&&r.setAttribute("aria-haspopup","dialog"),t.alternativeText&&(r.title=t.alternativeText),t.noRotate&&r.classList.add("norotate"),!t.rect||this instanceof np){let{rotation:e}=t;return!t.hasOwnCanvas&&0!==e&&this.setRotation(e,r),r}let{width:s,height:a}=nt(t.rect);if(!e&&t.borderStyle.width>0){o.borderWidth=`${t.borderStyle.width}px`;let e=t.borderStyle.horizontalCornerRadius,n=t.borderStyle.verticalCornerRadius;if(e>0||n>0){let t=`calc(${e}px * var(--scale-factor)) / calc(${n}px * var(--scale-factor))`;o.borderRadius=t}else if(this instanceof nc){let e=`calc(${s}px * var(--scale-factor)) / calc(${a}px * var(--scale-factor))`;o.borderRadius=e}switch(t.borderStyle.style){case v.SOLID:o.borderStyle="solid";break;case v.DASHED:o.borderStyle="dashed";break;case v.BEVELED:C("Unimplemented border style: beveled");break;case v.INSET:C("Unimplemented border style: inset");break;case v.UNDERLINE:o.borderBottomStyle="solid"}let i=t.borderColor||null;i?(this.#nF=!0,o.borderColor=V.makeHexColor(0|i[0],0|i[1],0|i[2])):o.borderWidth=0}let l=V.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:d,pageHeight:c,pageX:h,pageY:u}=i.rawDims;o.left=`${100*(l[0]-h)/d}%`,o.top=`${100*(l[1]-u)/c}%`;let{rotation:p}=t;return t.hasOwnCanvas||0===p?(o.width=`${100*s/d}%`,o.height=`${100*a/c}%`):this.setRotation(p,r),r}setRotation(e,t=this.container){let n,i;if(!this.data.rect)return;let{pageWidth:r,pageHeight:o}=this.parent.viewport.rawDims,{width:s,height:a}=nt(this.data.rect);e%180==0?(n=100*s/r,i=100*a/o):(n=100*a/r,i=100*s/o),t.style.width=`${n}%`,t.style.height=`${i}%`,t.setAttribute("data-main-rotation",(360-e)%360)}get _commonActions(){let e=(e,t,n)=>{let i=n.detail[e],r=i[0],o=i.slice(1);n.target.style[t]=t7[`${r}_HTML`](o),this.annotationStorage.setValue(this.data.id,{[t]:t7[`${r}_rgb`](o)})};return T(this,"_commonActions",{display:e=>{let{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=>{let{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=>{let t=e.detail.rotation;this.setRotation(t),this.annotationStorage.setValue(this.data.id,{rotation:t})}})}_dispatchEventFromSandbox(e,t){let n=this._commonActions;for(let i of Object.keys(t.detail)){let r=e[i]||n[i];r?.(t)}}_setDefaultPropertiesFromJS(e){if(!this.enableScripting)return;let t=this.annotationStorage.getRawValue(this.data.id);if(!t)return;let n=this._commonActions;for(let[i,r]of Object.entries(t)){let o=n[i];o&&(o({detail:{[i]:r},target:e}),delete t[i])}}_createQuadrilaterals(){let e;if(!this.container)return;let{quadPoints:t}=this.data;if(!t)return;let[n,i,r,o]=this.data.rect.map(e=>Math.fround(e));if(8===t.length){let[e,s,a,l]=t.subarray(2,6);if(r===e&&o===s&&n===a&&i===l)return}let{style:s}=this.container;if(this.#nF){let{borderColor:t,borderWidth:n}=s;s.borderWidth=0,e=["url('data:image/svg+xml;utf8,",'',``],this.container.classList.add("hasBorder")}let a=r-n,l=o-i,{svgFactory:d}=this,c=d.createElement("svg");c.classList.add("quadrilateralsContainer"),c.setAttribute("width",0),c.setAttribute("height",0);let h=d.createElement("defs");c.append(h);let u=d.createElement("clipPath"),p=`clippath_${this.data.id}`;u.setAttribute("id",p),u.setAttribute("clipPathUnits","objectBoundingBox"),h.append(u);for(let i=2,r=t.length;i`)}this.#nF&&(e.push("')"),s.backgroundImage=e.join("")),this.container.append(c),this.container.style.clipPath=`url(#${p})`}_createPopup(){let{container:e,data:t}=this;e.setAttribute("aria-haspopup","dialog");let n=this.#nB=new np({data:{color:t.color,titleObj:t.titleObj,modificationDate:t.modificationDate,contentsObj:t.contentsObj,richText:t.richText,parentRect:t.rect,borderStyle:0,id:`popup_${t.id}`,rotation:t.rotation},parent:this.parent,elements:[this]});this.parent.div.append(n.render())}render(){A("Abstract method `AnnotationElement.render` called")}_getElementsByName(e,t=null){let n=[];if(this._fieldObjects){let i=this._fieldObjects[e];if(i)for(let{page:e,id:r,exportValues:o}of i){if(-1===e||r===t)continue;let i="string"==typeof o?o:null,s=document.querySelector(`[data-element-id="${r}"]`);if(s&&!ne.has(s)){C(`_getElementsByName - element not allowed: ${r}`);continue}n.push({id:r,exportValue:i,domElement:s})}return n}for(let i of document.getElementsByName(e)){let{exportValue:e}=i,r=i.getAttribute("data-element-id");if(r!==t&&!!ne.has(i))n.push({id:r,exportValue:e,domElement:i})}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(){let e=this.getElementsToTriggerPopup();if(Array.isArray(e))for(let t of e)t.classList.add("highlightArea");else e.classList.add("highlightArea")}get _isEditable(){return!1}_editOnDoubleClick(){if(!this._isEditable)return;let{annotationEditorType:e,data:{id:t}}=this;this.container.addEventListener("dblclick",()=>{this.linkService.eventBus?.dispatch("switchannotationeditormode",{source:this,mode:e,editId:t})})}}class nr extends ni{constructor(e,t=null){super(e,{isRenderable:!0,ignoreBorder:!!t?.ignoreBorder,createQuadrilaterals:!0}),this.isTooltipOnly=e.data.isTooltipOnly}render(){let{data:e,linkService:t}=this,n=document.createElement("a");n.setAttribute("data-element-id",e.id);let i=!1;return e.url?(t.addLinkAttributes(n,e.url,e.newWindow),i=!0):e.action?(this._bindNamedAction(n,e.action),i=!0):e.attachment?(this.#nH(n,e.attachment,e.attachmentDest),i=!0):e.setOCGState?(this.#nV(n,e.setOCGState),i=!0):e.dest?(this._bindLink(n,e.dest),i=!0):(e.actions&&(e.actions.Action||e.actions["Mouse Up"]||e.actions["Mouse Down"])&&this.enableScripting&&this.hasJSActions&&(this._bindJSAction(n,e),i=!0),e.resetForm?(this._bindResetFormAction(n,e.resetForm),i=!0):this.isTooltipOnly&&!i&&(this._bindLink(n,""),i=!0)),this.container.classList.add("linkAnnotation"),i&&this.container.append(n),this.container}#nU(){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.#nU()}_bindNamedAction(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeNamedAction(t),!1),this.#nU()}#nH(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.#nU()}#nV(e,t){e.href=this.linkService.getAnchorUrl(""),e.onclick=()=>(this.linkService.executeSetOCGState(t),!1),this.#nU()}_bindJSAction(e,t){e.href=this.linkService.getAnchorUrl("");let n=new Map([["Action","onclick"],["Mouse Up","onmouseup"],["Mouse Down","onmousedown"]]);for(let i of Object.keys(t.actions)){let r=n.get(i);if(!!r)e[r]=()=>(this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t.id,name:i}}),!1)}!e.onclick&&(e.onclick=()=>!1),this.#nU()}_bindResetFormAction(e,t){let n=e.onclick;if(!n&&(e.href=this.linkService.getAnchorUrl("")),this.#nU(),!this._fieldObjects){C('_bindResetFormAction - "resetForm" action not supported, ensure that the `fieldObjects` parameter is provided.'),!n&&(e.onclick=()=>!1);return}e.onclick=()=>{n?.();let{fields:e,refs:i,include:r}=t,o=[];if(0!==e.length||0!==i.length){let t=new Set(i);for(let n of e)for(let{id:e}of this._fieldObjects[n]||[])t.add(e);for(let e of Object.values(this._fieldObjects))for(let n of e)t.has(n.id)===r&&o.push(n)}else for(let e of Object.values(this._fieldObjects))o.push(...e);let s=this.annotationStorage,a=[];for(let e of o){let{id:t}=e;switch(a.push(t),e.type){case"text":{let n=e.defaultValue||"";s.setValue(t,{value:n});break}case"checkbox":case"radiobutton":{let n=e.defaultValue===e.exportValues;s.setValue(t,{value:n});break}case"combobox":case"listbox":{let n=e.defaultValue||"";s.setValue(t,{value:n});break}default:continue}let n=document.querySelector(`[data-element-id="${t}"]`);if(!!n){if(!ne.has(n)){C(`_bindResetFormAction - element not allowed: ${t}`);continue}n.dispatchEvent(new Event("resetform"))}}return this.enableScripting&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:"app",ids:a,name:"ResetForm"}}),!1}}}class no extends ni{constructor(e){super(e,{isRenderable:!0})}render(){this.container.classList.add("textAnnotation");let 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 ns extends ni{render(){return this.container}showElementAndHideCanvas(e){this.data.hasOwnCanvas&&(e.previousSibling?.nodeName==="CANVAS"&&(e.previousSibling.hidden=!0),e.hidden=!1)}_getKeyModifier(e){return z.platform.isMac?e.metaKey:e.ctrlKey}_setEventListener(e,t,n,i,r){n.includes("mouse")?e.addEventListener(n,e=>{this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(e),shift:e.shiftKey,modifier:this._getKeyModifier(e)}})}):e.addEventListener(n,e=>{if("blur"===n){if(!t.focused||!e.relatedTarget)return;t.focused=!1}else if("focus"===n){if(t.focused)return;t.focused=!0}if(!!r)this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:this.data.id,name:i,value:r(e)}})})}_setEventListeners(e,t,n,i){for(let[r,o]of n)("Action"===o||this.data.actions?.[o])&&(("Focus"===o||"Blur"===o)&&(t||={focused:!1}),this._setEventListener(e,t,r,o,i),"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){let t=this.data.backgroundColor||null;e.style.backgroundColor=null===t?"transparent":V.makeHexColor(t[0],t[1],t[2])}_setTextStyle(e){let t;let{fontColor:n}=this.data.defaultAppearanceData,i=this.data.defaultAppearanceData.fontSize||9,r=e.style,o=e=>Math.round(10*e)/10;if(this.data.multiLine){let e=Math.abs(this.data.rect[3]-this.data.rect[1]-2),n=Math.round(e/(1.35*i))||1;t=Math.min(i,o(e/n/1.35))}else t=Math.min(i,o(Math.abs(this.data.rect[3]-this.data.rect[1]-2)/1.35));r.fontSize=`calc(${t}px * var(--scale-factor))`,r.color=V.makeHexColor(n[0],n[1],n[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 na extends ns{constructor(e){super(e,{isRenderable:e.renderForms||e.data.hasOwnCanvas||!e.data.hasAppearance&&!!e.data.fieldValue})}setPropertyOnSiblings(e,t,n,i){let r=this.annotationStorage;for(let o of this._getElementsByName(e.name,e.id))o.domElement&&(o.domElement[t]=n),r.setValue(o.id,{[i]:n})}render(){let e=this.annotationStorage,t=this.data.id;this.container.classList.add("textWidgetAnnotation");let n=null;if(this.renderForms){let i=e.getValue(t,{value:this.data.fieldValue}),r=i.value||"",o=e.getValue(t,{charLimit:this.data.maxLen}).charLimit;o&&r.length>o&&(r=r.slice(0,o));let s=i.formattedValue||this.data.textContent?.join("\n")||null;s&&this.data.comb&&(s=s.replaceAll(/\s+/g,""));let a={userValue:r,formattedValue:s,lastCommittedValue:null,commitKey:1,focused:!1};this.data.multiLine?((n=document.createElement("textarea")).textContent=s??r,this.data.doNotScroll&&(n.style.overflowY="hidden")):((n=document.createElement("input")).type="text",n.setAttribute("value",s??r),this.data.doNotScroll&&(n.style.overflowX="hidden")),this.data.hasOwnCanvas&&(n.hidden=!0),ne.add(n),n.setAttribute("data-element-id",t),n.disabled=this.data.readOnly,n.name=this.data.fieldName,n.tabIndex=1e3,this._setRequired(n,this.data.required),o&&(n.maxLength=o),n.addEventListener("input",i=>{e.setValue(t,{value:i.target.value}),this.setPropertyOnSiblings(n,"value",i.target.value,"value"),a.formattedValue=null}),n.addEventListener("resetform",e=>{let t=this.data.defaultFieldValue??"";n.value=a.userValue=t,a.formattedValue=null});let l=e=>{let{formattedValue:t}=a;null!=t&&(e.target.value=t),e.target.scrollLeft=0};if(this.enableScripting&&this.hasJSActions){n.addEventListener("focus",e=>{if(a.focused)return;let{target:t}=e;a.userValue&&(t.value=a.userValue),a.lastCommittedValue=t.value,a.commitKey=1,!this.data.actions?.Focus&&(a.focused=!0)}),n.addEventListener("updatefromsandbox",n=>{this.showElementAndHideCanvas(n.target);this._dispatchEventFromSandbox({value(n){a.userValue=n.detail.value??"",e.setValue(t,{value:a.userValue.toString()}),n.target.value=a.userValue},formattedValue(n){let{formattedValue:i}=n.detail;a.formattedValue=i,null!=i&&n.target!==document.activeElement&&(n.target.value=i),e.setValue(t,{formattedValue:i})},selRange(e){e.target.setSelectionRange(...e.detail.selRange)},charLimit:n=>{let{charLimit:i}=n.detail,{target:r}=n;if(0===i){r.removeAttribute("maxLength");return}r.setAttribute("maxLength",i);let o=a.userValue;if(!!o&&!(o.length<=i))o=o.slice(0,i),r.value=a.userValue=o,e.setValue(t,{value:o}),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:o,willCommit:!0,commitKey:1,selStart:r.selectionStart,selEnd:r.selectionEnd}})}},n)}),n.addEventListener("keydown",e=>{a.commitKey=1;let n=-1;if("Escape"===e.key?n=0:"Enter"!==e.key||this.data.multiLine?"Tab"===e.key&&(a.commitKey=3):n=2,-1===n)return;let{value:i}=e.target;if(a.lastCommittedValue!==i)a.lastCommittedValue=i,a.userValue=i,this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:i,willCommit:!0,commitKey:n,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}})});let i=l;l=null,n.addEventListener("blur",e=>{if(!a.focused||!e.relatedTarget)return;!this.data.actions?.Blur&&(a.focused=!1);let{value:n}=e.target;a.userValue=n,a.lastCommittedValue!==n&&this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:n,willCommit:!0,commitKey:a.commitKey,selStart:e.target.selectionStart,selEnd:e.target.selectionEnd}}),i(e)}),this.data.actions?.Keystroke&&n.addEventListener("beforeinput",e=>{a.lastCommittedValue=null;let{data:n,target:i}=e,{value:r,selectionStart:o,selectionEnd:s}=i,l=o,d=s;switch(e.inputType){case"deleteWordBackward":{let e=r.substring(0,o).match(/\w*[^\w]*$/);e&&(l-=e[0].length);break}case"deleteWordForward":{let e=r.substring(o).match(/^[^\w]*\w*/);e&&(d+=e[0].length);break}case"deleteContentBackward":o===s&&(l-=1);break;case"deleteContentForward":o===s&&(d+=1)}e.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:r,change:n||"",willCommit:!1,selStart:l,selEnd:d}})}),this._setEventListeners(n,a,[["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){let 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")).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 nl extends ns{constructor(e){super(e,{isRenderable:!!e.data.hasOwnCanvas})}}class nd extends ns{constructor(e){super(e,{isRenderable:e.renderForms})}render(){let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.exportValue===t.fieldValue}).value;"string"==typeof i&&(i="Off"!==i,e.setValue(n,{value:i})),this.container.classList.add("buttonWidgetAnnotation","checkBox");let r=document.createElement("input");return ne.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="checkbox",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.setAttribute("exportValue",t.exportValue),r.tabIndex=1e3,r.addEventListener("change",i=>{let{name:r,checked:o}=i.target;for(let i of this._getElementsByName(r,n)){let n=o&&i.exportValue===t.exportValue;i.domElement&&(i.domElement.checked=n),e.setValue(i.id,{value:n})}e.setValue(n,{value:o})}),r.addEventListener("resetform",e=>{let n=t.defaultFieldValue||"Off";e.target.checked=n===t.exportValue}),this.enableScripting&&this.hasJSActions&&(r.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({value(t){t.target.checked="Off"!==t.detail.value,e.setValue(n,{value:t.target.checked})}},t)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)),this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nc extends ns{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("buttonWidgetAnnotation","radioButton");let e=this.annotationStorage,t=this.data,n=t.id,i=e.getValue(n,{value:t.fieldValue===t.buttonValue}).value;if("string"==typeof i&&(i=i!==t.buttonValue,e.setValue(n,{value:i})),i)for(let i of this._getElementsByName(t.fieldName,n))e.setValue(i.id,{value:!1});let r=document.createElement("input");if(ne.add(r),r.setAttribute("data-element-id",n),r.disabled=t.readOnly,this._setRequired(r,this.data.required),r.type="radio",r.name=t.fieldName,i&&r.setAttribute("checked",!0),r.tabIndex=1e3,r.addEventListener("change",t=>{let{name:i,checked:r}=t.target;for(let t of this._getElementsByName(i,n))e.setValue(t.id,{value:!1});e.setValue(n,{value:r})}),r.addEventListener("resetform",e=>{let n=t.defaultFieldValue;e.target.checked=null!=n&&n===t.buttonValue}),this.enableScripting&&this.hasJSActions){let i=t.buttonValue;r.addEventListener("updatefromsandbox",t=>{this._dispatchEventFromSandbox({value:t=>{let r=i===t.detail.value;for(let i of this._getElementsByName(t.target.name)){let t=r&&i.id===n;i.domElement&&(i.domElement.checked=t),e.setValue(i.id,{value:t})}}},t)}),this._setEventListeners(r,null,[["change","Validate"],["change","Action"],["focus","Focus"],["blur","Blur"],["mousedown","Mouse Down"],["mouseenter","Mouse Enter"],["mouseleave","Mouse Exit"],["mouseup","Mouse Up"]],e=>e.target.checked)}return this._setBackgroundColor(r),this._setDefaultPropertiesFromJS(r),this.container.append(r),this.container}}class nh extends nr{constructor(e){super(e,{ignoreBorder:e.data.hasAppearance})}render(){let e=super.render();e.classList.add("buttonWidgetAnnotation","pushButton");let t=e.lastChild;return this.enableScripting&&this.hasJSActions&&t&&(this._setDefaultPropertiesFromJS(t),t.addEventListener("updatefromsandbox",e=>{this._dispatchEventFromSandbox({},e)})),e}}class nu extends ns{constructor(e){super(e,{isRenderable:e.renderForms})}render(){this.container.classList.add("choiceWidgetAnnotation");let e=this.annotationStorage,t=this.data.id,n=e.getValue(t,{value:this.data.fieldValue}),i=document.createElement("select");ne.add(i),i.setAttribute("data-element-id",t),i.disabled=this.data.readOnly,this._setRequired(i,this.data.required),i.name=this.data.fieldName,i.tabIndex=1e3;let r=this.data.combo&&this.data.options.length>0;for(let e of(!this.data.combo&&(i.size=this.data.options.length,this.data.multiSelect&&(i.multiple=!0)),i.addEventListener("resetform",e=>{let t=this.data.defaultFieldValue;for(let e of i.options)e.selected=e.value===t}),this.data.options)){let t=document.createElement("option");t.textContent=e.displayValue,t.value=e.exportValue,n.value.includes(e.exportValue)&&(t.setAttribute("selected",!0),r=!1),i.append(t)}let o=null;if(r){let e=document.createElement("option");e.value=" ",e.setAttribute("hidden",!0),e.setAttribute("selected",!0),i.prepend(e),o=()=>{e.remove(),i.removeEventListener("input",o),o=null},i.addEventListener("input",o)}let s=e=>{let t=e?"value":"textContent",{options:n,multiple:r}=i;return r?Array.prototype.filter.call(n,e=>e.selected).map(e=>e[t]):-1===n.selectedIndex?null:n[n.selectedIndex][t]},a=s(!1),l=e=>{let t=e.target.options;return Array.prototype.map.call(t,e=>({displayValue:e.textContent,exportValue:e.value}))};return this.enableScripting&&this.hasJSActions?(i.addEventListener("updatefromsandbox",n=>{this._dispatchEventFromSandbox({value(n){o?.();let r=n.detail.value,l=new Set(Array.isArray(r)?r:[r]);for(let e of i.options)e.selected=l.has(e.value);e.setValue(t,{value:s(!0)}),a=s(!1)},multipleSelection(e){i.multiple=!0},remove(n){let r=i.options,o=n.detail.remove;r[o].selected=!1,i.remove(o),r.length>0&&-1===Array.prototype.findIndex.call(r,e=>e.selected)&&(r[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),a=s(!1)},clear(n){for(;0!==i.length;)i.remove(0);e.setValue(t,{value:null,items:[]}),a=s(!1)},insert(n){let{index:r,displayValue:o,exportValue:d}=n.detail.insert,c=i.children[r],h=document.createElement("option");h.textContent=o,h.value=d,c?c.before(h):i.append(h),e.setValue(t,{value:s(!0),items:l(n)}),a=s(!1)},items(n){let{items:r}=n.detail;for(;0!==i.length;)i.remove(0);for(let e of r){let{displayValue:t,exportValue:n}=e,r=document.createElement("option");r.textContent=t,r.value=n,i.append(r)}i.options.length>0&&(i.options[0].selected=!0),e.setValue(t,{value:s(!0),items:l(n)}),a=s(!1)},indices(n){let i=new Set(n.detail.indices);for(let e of n.target.options)e.selected=i.has(e.index);e.setValue(t,{value:s(!0)}),a=s(!1)},editable(e){e.target.disabled=!e.detail.editable}},n)}),i.addEventListener("input",n=>{let i=s(!0),r=s(!1);e.setValue(t,{value:i}),n.preventDefault(),this.linkService.eventBus?.dispatch("dispatcheventinsandbox",{source:this,detail:{id:t,name:"Keystroke",value:a,change:r,changeEx:i,willCommit:!1,commitKey:1,keyDown:!1}})}),this._setEventListeners(i,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)):i.addEventListener("input",function(n){e.setValue(t,{value:s(!0)})}),this.data.combo&&this._setTextStyle(i),this._setBackgroundColor(i),this._setDefaultPropertiesFromJS(i),this.container.append(i),this.container}}class np extends ni{constructor(e){let{data:t,elements:n}=e;super(e,{isRenderable:ni._hasPopupData(t)}),this.elements=n,this.popup=null}render(){this.container.classList.add("popupAnnotation");let e=this.popup=new nf({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(let n of this.elements)n.popup=e,t.push(n.data.id),n.addHighlightArea();return this.container.setAttribute("aria-controls",t.map(e=>`${q}${e}`).join(",")),this.container}}class nf{#n$=this.#nW.bind(this);#nq=this.#nG.bind(this);#nK=this.#nZ.bind(this);#nY=this.#nX.bind(this);#nJ=null;#eg=null;#nQ=null;#n0=null;#n1=null;#n2=null;#n5=null;#n3=!1;#n4=null;#C=null;#n6=null;#n8=null;#n7=null;#nj=null;#n9=!1;constructor({container:e,color:t,elements:n,titleObj:i,modificationDate:r,contentsObj:o,richText:s,parent:a,rect:l,parentRect:d,open:c}){for(let c of(this.#eg=e,this.#n7=i,this.#nQ=o,this.#n8=s,this.#n2=a,this.#nJ=t,this.#n6=l,this.#n5=d,this.#n1=n,this.#n0=em.toDateObject(r),this.trigger=n.flatMap(e=>e.getElementsToTriggerPopup()),this.trigger))c.addEventListener("click",this.#nY),c.addEventListener("mouseenter",this.#nK),c.addEventListener("mouseleave",this.#nq),c.classList.add("popupTriggerArea");for(let e of n)e.container?.addEventListener("keydown",this.#n$);this.#eg.hidden=!0,c&&this.#nX()}render(){if(this.#n4)return;let e=this.#n4=document.createElement("div");if(e.className="popup",this.#nJ){let t=e.style.outlineColor=V.makeHexColor(...this.#nJ);CSS.supports("background-color","color-mix(in srgb, red 30%, white)")?e.style.backgroundColor=`color-mix(in srgb, ${t} 30%, white)`:e.style.backgroundColor=V.makeHexColor(...this.#nJ.map(e=>Math.floor(.7*(255-e)+e)))}let t=document.createElement("span");t.className="header";let n=document.createElement("h1");if(t.append(n),{dir:n.dir,str:n.textContent}=this.#n7,e.append(t),this.#n0){let e=document.createElement("span");e.classList.add("popupDate"),e.setAttribute("data-l10n-id","pdfjs-annotation-date-string"),e.setAttribute("data-l10n-args",JSON.stringify({date:this.#n0.toLocaleDateString(),time:this.#n0.toLocaleTimeString()})),t.append(e)}let i=this.#ie;if(i)t9.render({xfaHtml:i,intent:"richText",div:e}),e.lastChild.classList.add("richText","popupContent");else{let t=this._formatContents(this.#nQ);e.append(t)}this.#eg.append(e)}get #ie(){let e=this.#n8,t=this.#nQ;return e?.str&&(!t?.str||t.str===e.str)&&this.#n8.html||null}get #it(){return this.#ie?.attributes?.style?.fontSize||0}get #ii(){return this.#ie?.attributes?.style?.color||null}#ir(e){let t=[],n={style:{color:this.#ii,fontSize:this.#it?`calc(${this.#it}px * var(--scale-factor))`:""}};for(let i of e.split("\n"))t.push({name:"span",value:i,attributes:n});return{str:e,html:{name:"div",attributes:{dir:"auto"},children:[{name:"p",children:t}]}}}_formatContents({str:e,dir:t}){let n=document.createElement("p");n.classList.add("popupContent"),n.dir=t;let i=e.split(/(?:\r\n?|\n)/);for(let e=0,t=i.length;e{"Enter"===e.key&&(i?e.metaKey:e.ctrlKey)&&this.#iu()}),!n.popupRef&&this.hasPopupData?this._createPopup():e.classList.add("popupTriggerArea"),t.append(e),t}getElementsToTriggerPopup(){return this.#ih}addHighlightArea(){this.container.classList.add("highlightArea")}#iu(){this.downloadManager?.openOrDownloadData(this.content,this.filename)}}class nM{#ip=null;#im=null;#ig=new Map;constructor({div:e,accessibilityManager:t,annotationCanvasMap:n,annotationEditorUIManager:i,page:r,viewport:o}){this.div=e,this.#ip=t,this.#im=n,this.page=r,this.viewport=o,this.zIndex=0,this._annotationEditorUIManager=i}#iv(e,t){let n=e.firstChild||e;n.id=`${q}${t}`,this.div.append(e),this.#ip?.moveElementInDOM(this.div,e,n,!1)}async render(e){let{annotations:t}=e,n=this.div;ex(n,this.viewport);let i=new Map,r={data:null,layer:n,linkService:e.linkService,downloadManager:e.downloadManager,imageResourcesPath:e.imageResourcesPath||"",renderForms:!1!==e.renderForms,svgFactory:new er,annotationStorage:e.annotationStorage||new eR,enableScripting:!0===e.enableScripting,hasJSActions:e.hasJSActions,fieldObjects:e.fieldObjects,parent:this,elements:null};for(let e of t){if(e.noHTML)continue;let t=e.annotationType===g.POPUP;if(t){let t=i.get(e.id);if(!t)continue;r.elements=t}else{let{width:t,height:n}=nt(e.rect);if(t<=0||n<=0)continue}r.data=e;let n=nn.create(r);if(!n.isRenderable)continue;if(!t&&e.popupRef){let t=i.get(e.popupRef);t?t.push(n):i.set(e.popupRef,[n])}let o=n.render();e.hidden&&(o.style.visibility="hidden"),this.#iv(o,e.id),n.annotationEditorType>0&&(this.#ig.set(n.data.id,n),this._annotationEditorUIManager?.renderAnnotationElement(n))}this.#ib()}update({viewport:e}){let t=this.div;this.viewport=e,ex(t,{rotation:e.rotation}),this.#ib(),t.hidden=!1}#ib(){if(!this.#im)return;let e=this.div;for(let[t,n]of this.#im){let i=e.querySelector(`[data-annotation-id="${t}"]`);if(!i)continue;n.className="annotationContent";let{firstChild:r}=i;r?"CANVAS"===r.nodeName?r.replaceWith(n):r.classList.contains("annotationContent")?r.after(n):r.before(n):i.append(n)}this.#im.clear()}getEditableAnnotations(){return Array.from(this.#ig.values())}getEditableAnnotation(e){return this.#ig.get(e)}}let nD=/\r\n?|\n/g;class nO extends eO{#iy=this.editorDivBlur.bind(this);#ix=this.editorDivFocus.bind(this);#iw=this.editorDivInput.bind(this);#i_=this.editorDivKeydown.bind(this);#iS=this.editorDivPaste.bind(this);#nJ;#iC="";#iA=`${this.id}-editor`;#it;#iE=null;static _freeTextDefaultContent="";static _internalPadding=0;static _defaultColor=null;static _defaultFontSize=10;static get _keyboardManager(){let e=nO.prototype,t=e=>e.isEmpty(),n=eM.TRANSLATE_SMALL,i=eM.TRANSLATE_BIG;return T(this,"_keyboardManager",new ek([[["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:[-i,0],checker:t}],[["ArrowRight","mac+ArrowRight"],e._translateEmpty,{args:[n,0],checker:t}],[["ctrl+ArrowRight","mac+shift+ArrowRight"],e._translateEmpty,{args:[i,0],checker:t}],[["ArrowUp","mac+ArrowUp"],e._translateEmpty,{args:[0,-n],checker:t}],[["ctrl+ArrowUp","mac+shift+ArrowUp"],e._translateEmpty,{args:[0,-i],checker:t}],[["ArrowDown","mac+ArrowDown"],e._translateEmpty,{args:[0,n],checker:t}],[["ctrl+ArrowDown","mac+shift+ArrowDown"],e._translateEmpty,{args:[0,i],checker:t}]]))}static _type="freetext";static _editorType=h.FREETEXT;constructor(e){super({...e,name:"freeTextEditor"}),this.#nJ=e.color||nO._defaultColor||eO._defaultLineColor,this.#it=e.fontSize||nO._defaultFontSize}static initialize(e,t){eO.initialize(e,t,{strings:["pdfjs-free-text-default-content"]});let n=getComputedStyle(document.documentElement);this._internalPadding=parseFloat(n.getPropertyValue("--freetext-padding"))}static updateDefaultParams(e,t){switch(e){case u.FREETEXT_SIZE:nO._defaultFontSize=t;break;case u.FREETEXT_COLOR:nO._defaultColor=t}}updateParams(e,t){switch(e){case u.FREETEXT_SIZE:this.#ik(t);break;case u.FREETEXT_COLOR:this.#iT(t)}}static get defaultPropertiesToUpdate(){return[[u.FREETEXT_SIZE,nO._defaultFontSize],[u.FREETEXT_COLOR,nO._defaultColor||eO._defaultLineColor]]}get propertiesToUpdate(){return[[u.FREETEXT_SIZE,this.#it],[u.FREETEXT_COLOR,this.#nJ]]}#ik(e){let t=e=>{this.editorDiv.style.fontSize=`calc(${e}px * var(--scale-factor))`,this.translate(0,-(e-this.#it)*this.parentScale),this.#it=e,this.#iM()},n=this.#it;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_SIZE,overwriteIfSameType:!0,keepUndo:!0})}#iT(e){let t=e=>{this.#nJ=this.editorDiv.style.color=e},n=this.#nJ;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.FREETEXT_COLOR,overwriteIfSameType:!0,keepUndo:!0})}_translateEmpty(e,t){this._uiManager.translateSelectedEditors(e,t,!0)}getInitialTranslation(){let e=this.parentScale;return[-nO._internalPadding*e,-(nO._internalPadding+this.#it)*e]}rebuild(){if(!this.parent)return;if(super.rebuild(),null!==this.div)!this.isAttachedToDOM&&this.parent.add(this)}enableEditMode(){if(this.isInEditMode())return;this.parent.setEditingState(!1),this.parent.updateToolbar(h.FREETEXT),super.enableEditMode(),this.overlayDiv.classList.remove("enabled"),this.editorDiv.contentEditable=!0,this._isDraggable=!1,this.div.removeAttribute("aria-activedescendant");let e=this._uiManager._signal;this.editorDiv.addEventListener("keydown",this.#i_,{signal:e}),this.editorDiv.addEventListener("focus",this.#ix,{signal:e}),this.editorDiv.addEventListener("blur",this.#iy,{signal:e}),this.editorDiv.addEventListener("input",this.#iw,{signal:e}),this.editorDiv.addEventListener("paste",this.#iS,{signal:e})}disableEditMode(){if(!!this.isInEditMode())this.parent.setEditingState(!0),super.disableEditMode(),this.overlayDiv.classList.add("enabled"),this.editorDiv.contentEditable=!1,this.div.setAttribute("aria-activedescendant",this.#iA),this._isDraggable=!0,this.editorDiv.removeEventListener("keydown",this.#i_),this.editorDiv.removeEventListener("focus",this.#ix),this.editorDiv.removeEventListener("blur",this.#iy),this.editorDiv.removeEventListener("input",this.#iw),this.editorDiv.removeEventListener("paste",this.#iS),this.div.focus({preventScroll:!0}),this.isEditing=!1,this.parent.div.classList.add("freetextEditing")}focusin(e){if(!!this._focusEventsAllowed)super.focusin(e),e.target!==this.editorDiv&&this.editorDiv.focus()}onceAdded(){if(!this.width)this.enableEditMode(),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()}#iD(){let e=[];for(let t of(this.editorDiv.normalize(),this.editorDiv.childNodes))e.push(nO.#iO(t));return e.join("\n")}#iM(){let e;let[t,n]=this.parentDimensions;if(this.isAttachedToDOM)e=this.div.getBoundingClientRect();else{let{currentLayer:t,div:n}=this,i=n.style.display,r=n.classList.contains("hidden");n.classList.remove("hidden"),n.style.display="hidden",t.div.append(this.div),e=n.getBoundingClientRect(),n.remove(),n.style.display=i,n.classList.toggle("hidden",r)}this.rotation%180==this.parentRotation%180?(this.width=e.width/t,this.height=e.height/n):(this.width=e.height/t,this.height=e.width/n),this.fixAndSetPosition()}commit(){if(!this.isInEditMode())return;super.commit(),this.disableEditMode();let e=this.#iC,t=this.#iC=this.#iD().trimEnd();if(e===t)return;let n=e=>{if(this.#iC=e,!e){this.remove();return}this.#iI(),this._uiManager.rebuild(this),this.#iM()};this.addCommands({cmd:()=>{n(t)},undo:()=>{n(e)},mustExec:!1}),this.#iM()}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){nO._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(){let e,t;if(this.div)return this.div;this.width&&(e=this.x,t=this.y),super.render(),this.editorDiv=document.createElement("div"),this.editorDiv.className="internal",this.editorDiv.setAttribute("id",this.#iA),this.editorDiv.setAttribute("data-l10n-id","pdfjs-free-text"),this.enableEditing(),eO._l10nPromise.get("pdfjs-free-text-default-content").then(e=>this.editorDiv?.setAttribute("default-content",e)),this.editorDiv.contentEditable=!0;let{style:n}=this.editorDiv;if(n.fontSize=`calc(${this.#it}px * var(--scale-factor))`,n.color=this.#nJ,this.div.append(this.editorDiv),this.overlayDiv=document.createElement("div"),this.overlayDiv.classList.add("overlay","enabled"),this.div.append(this.overlayDiv),eS(this,this.div,["dblclick","keydown"]),this.width){let[n,i]=this.parentDimensions;if(this.annotationElementId){let r,o;let{position:s}=this.#iE,[a,l]=this.getInitialTranslation();[a,l]=this.pageTranslationToScreen(a,l);let[d,c]=this.pageDimensions,[h,u]=this.pageTranslation;switch(this.rotation){case 0:r=e+(s[0]-h)/d,o=t+this.height-(s[1]-u)/c;break;case 90:r=e+(s[0]-h)/d,o=t-(s[1]-u)/c,[a,l]=[l,-a];break;case 180:r=e-this.width+(s[0]-h)/d,o=t-(s[1]-u)/c,[a,l]=[-a,-l];break;case 270:r=e+(s[0]-h-this.height*c)/d,o=t+(s[1]-u-this.width*d)/c,[a,l]=[-l,a]}this.setAt(r*n,o*i,a,l)}else this.setAt(e*n,t*i,this.width*n,this.height*i);this.#iI(),this._isDraggable=!0,this.editorDiv.contentEditable=!1}else this._isDraggable=!1,this.editorDiv.contentEditable=!0;return this.div}static #iO(e){return(e.nodeType===Node.TEXT_NODE?e.nodeValue:e.innerText).replaceAll(nD,"")}editorDivPaste(e){let t=e.clipboardData||window.clipboardData,{types:n}=t;if(1===n.length&&"text/plain"===n[0])return;e.preventDefault();let i=nO.#iN(t.getData("text")||"").replaceAll(nD,"\n");if(!i)return;let r=window.getSelection();if(!r.rangeCount)return;this.editorDiv.normalize(),r.deleteFromDocument();let o=r.getRangeAt(0);if(!i.includes("\n")){o.insertNode(document.createTextNode(i)),this.editorDiv.normalize(),r.collapseToStart();return}let{startContainer:s,startOffset:a}=o,l=[],d=[];if(s.nodeType===Node.TEXT_NODE){let e=s.parentElement;if(d.push(s.nodeValue.slice(a).replaceAll(nD,"")),e!==this.editorDiv){let t=l;for(let n of this.editorDiv.childNodes){if(n===e){t=d;continue}t.push(nO.#iO(n))}}l.push(s.nodeValue.slice(0,a).replaceAll(nD,""))}else if(s===this.editorDiv){let e=l,t=0;for(let n of this.editorDiv.childNodes)t++===a&&(e=d),e.push(nO.#iO(n))}this.#iC=`${l.join("\n")}${i}${d.join("\n")}`,this.#iI();let c=new Range,h=l.reduce((e,t)=>e+t.length,0);for(let{firstChild:e}of this.editorDiv.childNodes)if(e.nodeType===Node.TEXT_NODE){let t=e.nodeValue.length;if(h<=t){c.setStart(e,h),c.setEnd(e,h);break}h-=t}r.removeAllRanges(),r.addRange(c)}#iI(){if(this.editorDiv.replaceChildren(),!!this.#iC)for(let e of this.#iC.split("\n")){let t=document.createElement("div");t.append(e?document.createTextNode(e):document.createElement("br")),this.editorDiv.append(t)}}#iP(){return this.#iC.replaceAll("\xa0"," ")}static #iN(e){return e.replaceAll(" ","\xa0")}get contentDiv(){return this.editorDiv}static deserialize(e,t,n){let i=null;if(e instanceof nm){let{data:{defaultAppearanceData:{fontSize:t,fontColor:n},rect:r,rotation:o,id:s},textContent:a,textPosition:l,parent:{page:{pageNumber:d}}}=e;if(!a||0===a.length)return null;i=e={annotationType:h.FREETEXT,color:Array.from(n),fontSize:t,value:a.join("\n"),position:l,pageIndex:d-1,rect:r.slice(0),rotation:o,id:s,deleted:!1}}let r=super.deserialize(e,t,n);return r.#it=e.fontSize,r.#nJ=V.makeHexColor(...e.color),r.#iC=nO.#iN(e.value),r.annotationElementId=e.id||null,r.#iE=i,r}serialize(e=!1){if(this.isEmpty())return null;if(this.deleted)return{pageIndex:this.pageIndex,id:this.annotationElementId,deleted:!0};let t=nO._internalPadding*this.parentScale,n=this.getRect(t,t),i=eO._colorManager.convert(this.isAttachedToDOM?getComputedStyle(this.editorDiv).color:this.#nJ),r={annotationType:h.FREETEXT,color:i,fontSize:this.#it,value:this.#iP(),pageIndex:this.pageIndex,rect:n,rotation:this.rotation,structTreeParentId:this._structTreeParentId};return e?r:this.annotationElementId&&!this.#iR(r)?null:(r.id=this.annotationElementId,r)}#iR(e){let{value:t,fontSize:n,color:i,pageIndex:r}=this.#iE;return this._hasBeenMoved||e.value!==t||e.fontSize!==n||e.color.some((e,t)=>e!==i[t])||e.pageIndex!==r}renderAnnotationElement(e){let t=super.renderAnnotationElement(e);if(this.deleted)return t;let{style:n}=t;for(let e of(n.fontSize=`calc(${this.#it}px * var(--scale-factor))`,n.color=this.#nJ,t.replaceChildren(),this.#iC.split("\n"))){let n=document.createElement("div");n.append(e?document.createTextNode(e):document.createElement("br")),t.append(n)}let i=nO._internalPadding*this.parentScale;return e.updateEdited({rect:this.getRect(i,i),popupContent:this.#iC}),t}resetAnnotationElement(e){super.resetAnnotationElement(e),e.resetEdited()}}class nI{#iL;#ij=[];#iF=[];constructor(e,t=0,n=0,i=!0){let r=1/0,o=-1/0,s=1/0,a=-1/0;for(let{x:n,y:i,width:l,height:d}of e){let e=1e-4*Math.floor((n-t)/1e-4),c=1e-4*Math.ceil((n+l+t)/1e-4),h=1e-4*Math.floor((i-t)/1e-4),u=1e-4*Math.ceil((i+d+t)/1e-4),p=[e,h,u,!0],f=[c,h,u,!1];this.#ij.push(p,f),r=Math.min(r,e),o=Math.max(o,c),s=Math.min(s,h),a=Math.max(a,u)}let l=o-r+2*n,d=a-s+2*n,c=r-n,h=s-n,u=this.#ij.at(i?-1:-2),p=[u[0],u[2]];for(let e of this.#ij){let[t,n,i]=e;e[0]=(t-c)/l,e[1]=(n-h)/d,e[2]=(i-h)/d}this.#iL={x:c,y:h,width:l,height:d,lastPoint:p}}getOutlines(){this.#ij.sort((e,t)=>e[0]-t[0]||e[1]-t[1]||e[2]-t[2]);let e=[];for(let t of this.#ij)t[3]?(e.push(...this.#iB(t)),this.#iz(t)):(this.#iH(t),e.push(...this.#iB(t)));return this.#iV(e)}#iV(e){let t;let n=[],i=new Set;for(let t of e){let[e,i,r]=t;n.push([e,i,t],[e,r,t])}n.sort((e,t)=>e[1]-t[1]||e[0]-t[0]);for(let e=0,t=n.length;e0;){let e=i.values().next().value,[n,o,s,a,l]=e;i.delete(e);let d=n,c=o;for(t=[n,s],r.push(t);;){let e;if(i.has(a))e=a;else if(i.has(l))e=l;else break;i.delete(e),[n,o,s,a,l]=e,d!==n&&(t.push(d,c,n,c===o?o:s),d=n),c=c===o?s:o}t.push(d,c)}return new nP(r,this.#iL)}#iU(e){let t=this.#iF,n=0,i=t.length-1;for(;n<=i;){let r=n+i>>1,o=t[r][0];if(o===e)return r;o=0;i--){let[n,r]=this.#iF[i];if(n!==e)break;if(n===e&&r===t){this.#iF.splice(i,1);return}}}#iB(e){let[t,n,i]=e,r=[[t,n,i]],o=this.#iU(i);for(let e=0;e=n){if(a>i)r[e][1]=i;else{if(1===o)return[];r.splice(e,1),e--,o--}continue}r[e][2]=n,a>i&&r.push([t,i,a])}}}return r}}class nN{toSVGPath(){throw Error("Abstract method `toSVGPath` must be implemented.")}get box(){throw Error("Abstract getter `box` must be implemented.")}serialize(e,t){throw Error("Abstract method `serialize` must be implemented.")}get free(){return this instanceof nL}}class nP extends nN{#iL;#i$;constructor(e,t){super(),this.#i$=e,this.#iL=t}toSVGPath(){let e=[];for(let t of this.#i$){let[n,i]=t;e.push(`M${n} ${i}`);for(let r=2;r=6;e-=6)isNaN(t[e])?u.push(`L${t[e+4]} ${t[e+5]}`):u.push(`C${t[e]} ${t[e+1]} ${t[e+2]} ${t[e+3]} ${t[e+4]} ${t[e+5]}`);return u.push(`L${t[4]} ${t[5]} Z`),u.join(" ")}getOutlines(){let e=this.#iK,t=this.#iW,n=this.#iZ,i=n.subarray(4,6),r=n.subarray(16,18),[o,s,a,l]=this.#iL,d=new Float64Array((this.#i2?.length??0)+2);for(let e=0,t=d.length-2;e=6;e-=6)for(let n=0;n<6;n+=2){if(isNaN(t[e+n])){f[m]=f[m+1]=NaN,m+=2;continue}f[m]=t[e+n],f[m+1]=t[e+n+1],m+=2}return f.set([NaN,NaN,NaN,NaN,t[4],t[5]],m),new nL(f,d,this.#iL,this.#i0,this.#iq,this.#iG)}}class nL extends nN{#iL;#i8=null;#iq;#iG;#i2;#i0;#i7;constructor(e,t,n,i,r,o){super(),this.#i7=e,this.#i2=t,this.#iL=n,this.#i0=i,this.#iq=r,this.#iG=o,this.#i9(o);let{x:s,y:a,width:l,height:d}=this.#i8;for(let t=0,n=e.length;t-1?(this.#rC=!0,this.#rO(e),this.#rI()):(this.#rm=e.anchorNode,this.#rg=e.anchorOffset,this.#rx=e.focusNode,this.#rw=e.focusOffset,this.#rN(),this.#rI(),this.rotate(this.rotation))}get telemetryInitialData(){return{action:"added",type:this.#rC?"free_highlight":"highlight",color:this._uiManager.highlightColorNames.get(this.color),thickness:this.#i1,methodOfCreation:this.#rD}}get telemetryFinalData(){return{type:"highlight",color:this._uiManager.highlightColorNames.get(this.color)}}static computeTelemetryFinalData(e){return{numberOfColors:e.get("color").size}}#rN(){let e=new nI(this.#rv,.001);this.#rS=e.getOutlines(),{x:this.x,y:this.y,width:this.width,height:this.height}=this.#rS.box;let t=new nI(this.#rv,.0025,.001,"ltr"===this._uiManager.direction);this.#ry=t.getOutlines();let{lastPoint:n}=this.#ry.box;this.#rE=[(n[0]-this.x)/this.width,(n[1]-this.y)/this.height]}#rO({highlightOutlines:e,highlightId:t,clipPathId:n}){this.#rS=e;if(this.#ry=e.getNewOutline(this.#i1/2+1.5,.0025),t>=0)this.#v=t,this.#rb=n,this.parent.drawLayer.finalizeLine(t,e),this.#rT=this.parent.drawLayer.highlightOutline(this.#ry);else if(this.parent){let t=this.parent.viewport.rotation;this.parent.drawLayer.updateLine(this.#v,e),this.parent.drawLayer.updateBox(this.#v,nF.#rP(this.#rS.box,(t-this.rotation+360)%360)),this.parent.drawLayer.updateLine(this.#rT,this.#ry),this.parent.drawLayer.updateBox(this.#rT,nF.#rP(this.#ry.box,t))}let{x:i,y:r,width:o,height:s}=e.box;switch(this.rotation){case 0:this.x=i,this.y=r,this.width=o,this.height=s;break;case 90:{let[e,t]=this.parentDimensions;this.x=r,this.y=1-i,this.width=o*t/e,this.height=s*e/t;break}case 180:this.x=1-i,this.y=1-r,this.width=o,this.height=s;break;case 270:{let[e,t]=this.parentDimensions;this.x=1-r,this.y=i,this.width=o*t/e,this.height=s*e/t}}let{lastPoint:a}=this.#ry.box;this.#rE=[(a[0]-i)/o,(a[1]-r)/s]}static initialize(e,t){eO.initialize(e,t),nF._defaultColor||=t.highlightColors?.values().next().value||"#fff066"}static updateDefaultParams(e,t){switch(e){case u.HIGHLIGHT_DEFAULT_COLOR:nF._defaultColor=t;break;case u.HIGHLIGHT_THICKNESS:nF._defaultThickness=t}}translateInPage(e,t){}get toolbarPosition(){return this.#rE}updateParams(e,t){switch(e){case u.HIGHLIGHT_COLOR:this.#iT(t);break;case u.HIGHLIGHT_THICKNESS:this.#rR(t)}}static get defaultPropertiesToUpdate(){return[[u.HIGHLIGHT_DEFAULT_COLOR,nF._defaultColor],[u.HIGHLIGHT_THICKNESS,nF._defaultThickness]]}get propertiesToUpdate(){return[[u.HIGHLIGHT_COLOR,this.color||nF._defaultColor],[u.HIGHLIGHT_THICKNESS,this.#i1||nF._defaultThickness],[u.HIGHLIGHT_FREE,this.#rC]]}#iT(e){let t=e=>{this.color=e,this.parent?.drawLayer.changeColor(this.#v,e),this.#r?.updateColor(e)},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.HIGHLIGHT_COLOR,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"color_changed",color:this._uiManager.highlightColorNames.get(e)},!0)}#rR(e){let t=this.#i1,n=e=>{this.#i1=e,this.#rL(e)};this.addCommands({cmd:n.bind(this,e),undo:n.bind(this,t),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0}),this._reportTelemetry({action:"thickness_changed",thickness:e},!0)}async addEditToolbar(){let e=await super.addEditToolbar();return e?(this._uiManager.highlightColors&&(this.#r=new nj({editor:this}),e.addColorPicker(this.#r)),e):null}disableEditing(){super.disableEditing(),this.div.classList.toggle("disabled",!0)}enableEditing(){super.enableEditing(),this.div.classList.toggle("disabled",!1)}fixAndSetPosition(){return super.fixAndSetPosition(this.#rj())}getBaseTranslation(){return[0,0]}getRect(e,t){return super.getRect(e,t,this.#rj())}onceAdded(){this.parent.addUndoableEditor(this),this.div.focus()}remove(){this.#rF(),this._reportTelemetry({action:"deleted"}),super.remove()}rebuild(){if(!this.parent)return;if(super.rebuild(),null!==this.div)this.#rI(),!this.isAttachedToDOM&&this.parent.add(this)}setParent(e){let t=!1;this.parent&&!e?this.#rF():e&&(this.#rI(e),t=!this.parent&&this.div?.classList.contains("selectedEditor")),super.setParent(e),this.show(this._isVisible),t&&this.select()}#rL(e){if(!this.#rC)return;this.#rO({highlightOutlines:this.#rS.getNewOutline(e/2)}),this.fixAndSetPosition();let[t,n]=this.parentDimensions;this.setDims(this.width*t,this.height*n)}#rF(){if(null!==this.#v&&!!this.parent)this.parent.drawLayer.remove(this.#v),this.#v=null,this.parent.drawLayer.remove(this.#rT),this.#rT=null}#rI(e=this.parent){if(null===this.#v)({id:this.#v,clipPathId:this.#rb}=e.drawLayer.highlight(this.#rS,this.color,this.#rk)),this.#rT=e.drawLayer.highlightOutline(this.#ry),this.#r_&&(this.#r_.style.clipPath=this.#rb)}static #rP({x:e,y:t,width:n,height:i},r){switch(r){case 90:return{x:1-t-i,y:e,width:i,height:n};case 180:return{x:1-e-n,y:1-t-i,width:n,height:i};case 270:return{x:t,y:1-e-n,width:i,height:n}}return{x:e,y:t,width:n,height:i}}rotate(e){let t;let{drawLayer:n}=this.parent;this.#rC?(e=(e-this.rotation+360)%360,t=nF.#rP(this.#rS.box,e)):t=nF.#rP(this,e),n.rotate(this.#v,e),n.rotate(this.#rT,e),n.updateBox(this.#v,t),n.updateBox(this.#rT,nF.#rP(this.#ry.box,e))}render(){if(this.div)return this.div;let e=super.render();this.#rM&&(e.setAttribute("aria-label",this.#rM),e.setAttribute("role","mark")),this.#rC?e.classList.add("free"):this.div.addEventListener("keydown",this.#ea,{signal:this._uiManager._signal});let t=this.#r_=document.createElement("div");e.append(t),t.setAttribute("aria-hidden","true"),t.className="internal",t.style.clipPath=this.#rb;let[n,i]=this.parentDimensions;return this.setDims(this.width*n,this.height*i),eS(this,this.#r_,["pointerover","pointerleave"]),this.enableEditing(),e}pointerover(){this.parent.drawLayer.addClass(this.#rT,"hovered")}pointerleave(){this.parent.drawLayer.removeClass(this.#rT,"hovered")}#rA(e){nF._keyboardManager.exec(this,e)}_moveCaret(e){switch(this.parent.unselect(this),e){case 0:case 2:this.#rB(!0);break;case 1:case 3:this.#rB(!1)}}#rB(e){if(!this.#rm)return;let t=window.getSelection();e?t.setPosition(this.#rm,this.#rg):t.setPosition(this.#rx,this.#rw)}select(){if(super.select(),!!this.#rT)this.parent?.drawLayer.removeClass(this.#rT,"hovered"),this.parent?.drawLayer.addClass(this.#rT,"selected")}unselect(){if(super.unselect(),!!this.#rT)this.parent?.drawLayer.removeClass(this.#rT,"selected"),!this.#rC&&this.#rB(!1)}get _mustFixPosition(){return!this.#rC}show(e=this._isVisible){super.show(e),this.parent&&(this.parent.drawLayer.show(this.#v,e),this.parent.drawLayer.show(this.#rT,e))}#rj(){return this.#rC?this.rotation:0}#rz(){if(this.#rC)return null;let[e,t]=this.pageDimensions,n=this.#rv,i=new Float32Array(8*n.length),r=0;for(let{x:o,y:s,width:a,height:l}of n){let n=o*e,d=(1-s-l)*t;i[r]=i[r+4]=n,i[r+1]=i[r+3]=d,i[r+2]=i[r+6]=n+a*e,i[r+5]=i[r+7]=d+l*t,r+=8}return i}#rH(e){return this.#rS.serialize(e,this.#rj())}static startHighlighting(e,t,{target:n,x:i,y:r}){let{x:o,y:s,width:a,height:l}=n.getBoundingClientRect(),d=t=>{this.#rV(e,t)},c=e._signal,h={capture:!0,passive:!1,signal:c},u=e=>{e.preventDefault(),e.stopPropagation()},p=t=>{n.removeEventListener("pointermove",d),window.removeEventListener("blur",p),window.removeEventListener("pointerup",p),window.removeEventListener("pointerdown",u,h),window.removeEventListener("contextmenu",ep),this.#rU(e,t)};window.addEventListener("blur",p,{signal:c}),window.addEventListener("pointerup",p,{signal:c}),window.addEventListener("pointerdown",u,h),window.addEventListener("contextmenu",ep,{signal:c}),n.addEventListener("pointermove",d,{signal:c}),this._freeHighlight=new nR({x:i,y:r},[o,s,a,l],e.scale,this._defaultThickness/2,t,.001),{id:this._freeHighlightId,clipPathId:this._freeHighlightClipId}=e.drawLayer.highlight(this._freeHighlight,this._defaultColor,this._defaultOpacity,!0)}static #rV(e,t){this._freeHighlight.add(t)&&e.drawLayer.updatePath(this._freeHighlightId,this._freeHighlight)}static #rU(e,t){this._freeHighlight.isEmpty()?e.drawLayer.removeFreeHighlight(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 deserialize(e,t,n){let i=super.deserialize(e,t,n),{rect:[r,o,s,a],color:l,quadPoints:d}=e;i.color=V.makeHexColor(...l),i.#rk=e.opacity;let[c,h]=i.pageDimensions;i.width=(s-r)/c,i.height=(a-o)/h;let u=i.#rv=[];for(let e=0;e{this.thickness=e,this.#r6()},n=this.thickness;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_THICKNESS,overwriteIfSameType:!0,keepUndo:!0})}#iT(e){let t=e=>{this.color=e,this.#r8()},n=this.color;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_COLOR,overwriteIfSameType:!0,keepUndo:!0})}#r4(e){let t=e=>{this.opacity=e,this.#r8()};e/=100;let n=this.opacity;this.addCommands({cmd:t.bind(this,e),undo:t.bind(this,n),post:this._uiManager.updateUI.bind(this._uiManager,this),mustExec:!0,type:u.INK_OPACITY,overwriteIfSameType:!0,keepUndo:!0})}rebuild(){if(!this.parent)return;if(super.rebuild(),null!==this.div)!this.canvas&&(this.#r7(),this.#r9()),!this.isAttachedToDOM&&(this.parent.add(this),this.#oe()),this.#r6()}remove(){if(null!==this.canvas)!this.isEmpty()&&this.commit(),this.canvas.width=this.canvas.height=0,this.canvas.remove(),this.canvas=null,this.#rY&&(clearTimeout(this.#rY),this.#rY=null),this.#r1?.disconnect(),this.#r1=null,super.remove()}setParent(e){!this.parent&&e?this._uiManager.removeShouldRescale(this):this.parent&&null===e&&this._uiManager.addShouldRescale(this),super.setParent(e)}onScaleChanging(){let[e,t]=this.parentDimensions,n=this.width*e,i=this.height*t;this.setDimensions(n,i)}enableEditMode(){if(!this.#rJ&&null!==this.canvas)super.enableEditMode(),this._isDraggable=!1,this.canvas.addEventListener("pointerdown",this.#rZ,{signal:this._uiManager._signal})}disableEditMode(){if(!!this.isInEditMode()&&null!==this.canvas)super.disableEditMode(),this._isDraggable=!this.isEmpty(),this.div.classList.remove("editing"),this.canvas.removeEventListener("pointerdown",this.#rZ)}onceAdded(){this._isDraggable=!this.isEmpty()}isEmpty(){return 0===this.paths.length||1===this.paths.length&&0===this.paths[0].length}#ot(){let{parentRotation:e,parentDimensions:[t,n]}=this;switch(e){case 90:return[0,n,n,t];case 180:return[t,n,t,n];case 270:return[t,0,n,t];default:return[0,0,t,n]}}#on(){let{ctx:e,color:t,opacity:n,thickness:i,parentScale:r,scaleFactor:o}=this;e.lineWidth=i*r/o,e.lineCap="round",e.lineJoin="round",e.miterLimit=10,e.strokeStyle=`${t}${Math.round(Math.min(255,Math.max(1,255*n))).toString(16).padStart(2,"0")}`}#oi(e,t){let n=this._uiManager._signal;this.canvas.addEventListener("contextmenu",ep,{signal:n}),this.canvas.addEventListener("pointerleave",this.#rG,{signal:n}),this.canvas.addEventListener("pointermove",this.#rq,{signal:n}),this.canvas.addEventListener("pointerup",this.#rK,{signal:n}),this.canvas.removeEventListener("pointerdown",this.#rZ),this.isEditing=!0,!this.#r0&&(this.#r0=!0,this.#oe(),this.thickness||=nB._defaultThickness,this.color||=nB._defaultColor||eO._defaultLineColor,this.opacity??=nB._defaultOpacity),this.currentPath.push([e,t]),this.#rQ=!1,this.#on(),this.#r3=()=>{this.#or(),this.#r3&&window.requestAnimationFrame(this.#r3)},window.requestAnimationFrame(this.#r3)}#oo(e,t){let[n,i]=this.currentPath.at(-1);if(this.currentPath.length>1&&e===n&&t===i)return;let r=this.currentPath,o=this.#rX;if(r.push([e,t]),this.#rQ=!0,r.length<=2){o.moveTo(...r[0]),o.lineTo(e,t);return}3===r.length&&(this.#rX=o=new Path2D,o.moveTo(...r[0])),this.#os(o,...r.at(-3),...r.at(-2),e,t)}#oa(){if(0===this.currentPath.length)return;let e=this.currentPath.at(-1);this.#rX.lineTo(...e)}#ol(e,t){let n;if(this.#r3=null,e=Math.min(Math.max(e,0),this.canvas.width),t=Math.min(Math.max(t,0),this.canvas.height),this.#oo(e,t),this.#oa(),1!==this.currentPath.length)n=this.#od();else{let i=[e,t];n=[[i,i.slice(),i.slice(),i]]}let i=this.#rX,r=this.currentPath;this.currentPath=[],this.#rX=new Path2D;this.addCommands({cmd:()=>{this.allRawPaths.push(r),this.paths.push(n),this.bezierPath2D.push(i),this._uiManager.rebuild(this)},undo:()=>{this.allRawPaths.pop(),this.paths.pop(),this.bezierPath2D.pop(),0===this.paths.length?this.remove():(!this.canvas&&(this.#r7(),this.#r9()),this.#r6())},mustExec:!0})}#or(){if(!this.#rQ)return;this.#rQ=!1,this.thickness,this.parentScale;let e=this.currentPath.slice(-3);e.map(e=>e[0]),e.map(e=>e[1]);let{ctx:t}=this;for(let e of(t.save(),t.clearRect(0,0,this.canvas.width,this.canvas.height),this.bezierPath2D))t.stroke(e);t.stroke(this.#rX),t.restore()}#os(e,t,n,i,r,o,s){let a=(t+i)/2,l=(n+r)/2,d=(i+o)/2,c=(r+s)/2;e.bezierCurveTo(a+2*(i-a)/3,l+2*(r-l)/3,d+2*(i-d)/3,c+2*(r-c)/3,d,c)}#od(){let e;let t=this.currentPath;if(t.length<=2)return[[t[0],t[0],t.at(-1),t.at(-1)]];let n=[],[i,r]=t[0];for(e=1;e{this.#rY=null,this.canvas.removeEventListener("contextmenu",ep)},10),this.#ol(e.offsetX,e.offsetY),this.addToAnnotationStorage(),this.setInBackground()}#r7(){this.canvas=document.createElement("canvas"),this.canvas.width=this.canvas.height=0,this.canvas.className="inkEditorCanvas",this.canvas.setAttribute("data-l10n-id","pdfjs-ink-canvas"),this.div.append(this.canvas),this.ctx=this.canvas.getContext("2d")}#r9(){this.#r1=new ResizeObserver(e=>{let t=e[0].contentRect;t.width&&t.height&&this.setDimensions(t.width,t.height)}),this.#r1.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#r1?.disconnect(),this.#r1=null},{once:!0})}get isResizable(){return!this.isEmpty()&&this.#rJ}render(){let e,t;if(this.div)return this.div;this.width&&(e=this.x,t=this.y),super.render(),this.div.setAttribute("data-l10n-id","pdfjs-ink");let[n,i,r,o]=this.#ot();if(this.setAt(n,i,0,0),this.setDims(r,o),this.#r7(),this.width){let[n,i]=this.parentDimensions;this.setAspectRatio(this.width*n,this.height*i),this.setAt(e*n,t*i,this.width*n,this.height*i),this.#r0=!0,this.#oe(),this.setDims(this.width*n,this.height*i),this.#r8(),this.div.classList.add("disabled")}else this.div.classList.add("editing"),this.enableEditMode();return this.#r9(),this.div}#oe(){if(!this.#r0)return;let[e,t]=this.parentDimensions;this.canvas.width=Math.ceil(this.width*e),this.canvas.height=Math.ceil(this.height*t),this.#oc()}setDimensions(e,t){let n=Math.round(e),i=Math.round(t);if(this.#r2===n&&this.#r5===i)return;this.#r2=n,this.#r5=i,this.canvas.style.visibility="hidden";let[r,o]=this.parentDimensions;this.width=e/r,this.height=t/o,this.fixAndSetPosition(),this.#rJ&&this.#ou(e,t),this.#oe(),this.#r8(),this.canvas.style.visibility="visible",this.fixDims()}#ou(e,t){let n=this.#op(),i=(e-n)/this.#rW,r=(t-n)/this.#r$;this.scaleFactor=Math.min(i,r)}#oc(){let e=this.#op()/2;this.ctx.setTransform(this.scaleFactor,0,0,this.scaleFactor,this.translationX*this.scaleFactor+e,this.translationY*this.scaleFactor+e)}static #of(e){let t=new Path2D;for(let n=0,i=e.length;n`image/${e}`))}static get supportedTypesStr(){return T(this,"supportedTypesStr",this.supportedTypes.join(","))}static isHandlingMimeForPasting(e){return this.supportedTypes.includes(e)}static paste(e,t){t.pasteEditor(h.STAMP,{bitmapFile:e.getAsFile()})}#oM(e,t=!1){if(!e){this.remove();return}this.#oy=e.bitmap,!t&&(this.#ox=e.id,this.#ok=e.isSvg),e.file&&(this.#oC=e.file.name),this.#r7()}#oD(){this.#ow=null,this._uiManager.enableWaiting(!1),this.#oA&&this.div.focus()}#oO(){if(this.#ox){this._uiManager.enableWaiting(!0),this._uiManager.imageManager.getFromId(this.#ox).then(e=>this.#oM(e,!0)).finally(()=>this.#oD());return}if(this.#o_){let e=this.#o_;this.#o_=null,this._uiManager.enableWaiting(!0),this.#ow=this._uiManager.imageManager.getFromUrl(e).then(e=>this.#oM(e)).finally(()=>this.#oD());return}if(this.#oS){let e=this.#oS;this.#oS=null,this._uiManager.enableWaiting(!0),this.#ow=this._uiManager.imageManager.getFromFile(e).then(e=>this.#oM(e)).finally(()=>this.#oD());return}let e=document.createElement("input");e.type="file",e.accept=nz.supportedTypesStr;let t=this._uiManager._signal;this.#ow=new Promise(n=>{e.addEventListener("change",async()=>{if(e.files&&0!==e.files.length){this._uiManager.enableWaiting(!0);let t=await this._uiManager.imageManager.getFromFile(e.files[0]);this.#oM(t)}else this.remove();n()},{signal:t}),e.addEventListener("cancel",()=>{this.remove(),n()},{signal:t})}).finally(()=>this.#oD()),e.click()}remove(){this.#ox&&(this.#oy=null,this._uiManager.imageManager.deleteId(this.#ox),this.#oA?.remove(),this.#oA=null,this.#r1?.disconnect(),this.#r1=null,this.#oE&&(clearTimeout(this.#oE),this.#oE=null)),super.remove()}rebuild(){if(!this.parent){this.#ox&&this.#oO();return}if(super.rebuild(),null!==this.div)this.#ox&&null===this.#oA&&this.#oO(),!this.isAttachedToDOM&&this.parent.add(this)}onceAdded(){this._isDraggable=!0,this.div.focus()}isEmpty(){return!(this.#ow||this.#oy||this.#o_||this.#oS||this.#ox)}get isResizable(){return!0}render(){let e,t;if(this.div)return this.div;if(this.width&&(e=this.x,t=this.y),super.render(),this.div.hidden=!0,this.addAltTextButton(),this.#oy?this.#r7():this.#oO(),this.width){let[n,i]=this.parentDimensions;this.setAt(e*n,t*i,this.width*n,this.height*i)}return this.div}#r7(){let{div:e}=this,{width:t,height:n}=this.#oy,[i,r]=this.pageDimensions;if(this.width)t=this.width*i,n=this.height*r;else if(t>.75*i||n>.75*r){let e=Math.min(.75*i/t,.75*r/n);t*=e,n*=e}let[o,s]=this.parentDimensions;this.setDims(t*o/i,n*s/r),this._uiManager.enableWaiting(!1);let a=this.#oA=document.createElement("canvas");e.append(a),e.hidden=!1,this.#oI(t,n),this.#r9(),!this.#oT&&(this.parent.addUndoableEditor(this),this.#oT=!0),this._reportTelemetry({action:"inserted_image"}),this.#oC&&a.setAttribute("aria-label",this.#oC)}#oN(e,t){let[n,i]=this.parentDimensions;this.width=e/n,this.height=t/i,this.setDims(e,t),this._initialOptions?.isCentered?this.center():this.fixAndSetPosition(),this._initialOptions=null,null!==this.#oE&&clearTimeout(this.#oE);this.#oE=setTimeout(()=>{this.#oE=null,this.#oI(e,t)},200)}#oP(e,t){let{width:n,height:i}=this.#oy,r=n,o=i,s=this.#oy;for(;r>2*e||o>2*t;){let n=r,i=o;r>2*e&&(r=r>=16384?Math.floor(r/2)-1:Math.ceil(r/2)),o>2*t&&(o=o>=16384?Math.floor(o/2)-1:Math.ceil(o/2));let a=new OffscreenCanvas(r,o);a.getContext("2d").drawImage(s,0,0,n,i,0,0,r,o),s=a.transferToImageBitmap()}return s}#oI(e,t){e=Math.ceil(e),t=Math.ceil(t);let n=this.#oA;if(!n||n.width===e&&n.height===t)return;n.width=e,n.height=t;let i=this.#ok?this.#oy:this.#oP(e,t);if(this._uiManager.hasMLManager&&!this.hasAltText()){let n=new OffscreenCanvas(e,t).getContext("2d");n.drawImage(i,0,0,i.width,i.height,0,0,e,t),this._uiManager.mlGuess({service:"image-to-text",request:{data:n.getImageData(0,0,e,t).data,width:e,height:t,channels:4}}).then(e=>{let t=e?.output||"";this.parent&&t&&!this.hasAltText()&&(this.altTextData={altText:t,decorative:!1})})}let r=n.getContext("2d");r.filter=this._uiManager.hcmFilter,r.drawImage(i,0,0,i.width,i.height,0,0,e,t)}getImageForAltText(){return this.#oA}#oR(e){if(e){if(this.#ok){let e=this._uiManager.imageManager.getSvgUrl(this.#ox);if(e)return e}let e=document.createElement("canvas");return{width:e.width,height:e.height}=this.#oy,e.getContext("2d").drawImage(this.#oy,0,0),e.toDataURL()}if(this.#ok){let[e,t]=this.pageDimensions,n=Math.round(this.width*e*ee.PDF_TO_CSS_UNITS),i=Math.round(this.height*t*ee.PDF_TO_CSS_UNITS),r=new OffscreenCanvas(n,i);return r.getContext("2d").drawImage(this.#oy,0,0,this.#oy.width,this.#oy.height,0,0,n,i),r.transferToImageBitmap()}return structuredClone(this.#oy)}#r9(){if(!!this._uiManager._signal)this.#r1=new ResizeObserver(e=>{let t=e[0].contentRect;t.width&&t.height&&this.#oN(t.width,t.height)}),this.#r1.observe(this.div),this._uiManager._signal.addEventListener("abort",()=>{this.#r1?.disconnect(),this.#r1=null},{once:!0})}static deserialize(e,t,n){if(e instanceof nk)return null;let i=super.deserialize(e,t,n),{rect:r,bitmapUrl:o,bitmapId:s,isSvg:a,accessibilityData:l}=e;s&&n.imageManager.isValidId(s)?i.#ox=s:i.#o_=o,i.#ok=a;let[d,c]=i.pageDimensions;return i.width=(r[2]-r[0])/d,i.height=(r[3]-r[1])/c,l&&(i.altTextData=l),i}serialize(e=!1,t=null){if(this.isEmpty())return null;let n={annotationType:h.STAMP,bitmapId:this.#ox,pageIndex:this.pageIndex,rect:this.getRect(0,0),rotation:this.rotation,isSvg:this.#ok,structTreeParentId:this._structTreeParentId};if(e)return n.bitmapUrl=this.#oR(!0),n.accessibilityData=this.altTextData,n;let{decorative:i,altText:r}=this.altTextData;if(!i&&r&&(n.accessibilityData={type:"Figure",alt:r}),null===t)return n;t.stamps||=new Map;let o=this.#ok?(n.rect[2]-n.rect[0])*(n.rect[3]-n.rect[1]):null;if(t.stamps.has(this.#ox)){if(this.#ok){let e=t.stamps.get(this.#ox);o>e.area&&(e.area=o,e.serialized.bitmap.close(),e.serialized.bitmap=this.#oR(!1))}}else t.stamps.set(this.#ox,{area:o,serialized:n}),n.bitmap=this.#oR(!1);return n}}class nH{#ip;#oL=!1;#oj=null;#oF=null;#oB=null;#oz=null;#oH=null;#oV=new Map;#oU=!1;#o$=!1;#oW=!1;#oq=null;#p;static _initialized=!1;static #j=new Map([nO,nB,nz,nF].map(e=>[e._editorType,e]));constructor({uiManager:e,pageIndex:t,div:n,accessibilityManager:i,annotationLayer:r,drawLayer:o,textLayer:s,viewport:a,l10n:l}){let d=[...nH.#j.values()];if(!nH._initialized)for(let t of(nH._initialized=!0,d))t.initialize(l,e);e.registerEditorTypes(d),this.#p=e,this.pageIndex=t,this.div=n,this.#ip=i,this.#oj=r,this.viewport=a,this.#oq=s,this.drawLayer=o,this.#p.addLayer(this)}get isEmpty(){return 0===this.#oV.size}get isInvisible(){return this.isEmpty&&this.#p.getMode()===h.NONE}updateToolbar(e){this.#p.updateToolbar(e)}updateMode(e=this.#p.getMode()){switch(this.#oG(),e){case h.NONE:this.disableTextSelection(),this.togglePointerEvents(!1),this.toggleAnnotationLayerPointerEvents(!0),this.disableClick();return;case h.INK:this.addInkEditorIfNeeded(!1),this.disableTextSelection(),this.togglePointerEvents(!0),this.disableClick();break;case h.HIGHLIGHT:this.enableTextSelection(),this.togglePointerEvents(!1),this.disableClick();break;default:this.disableTextSelection(),this.togglePointerEvents(!0),this.enableClick()}this.toggleAnnotationLayerPointerEvents(!1);let{classList:t}=this.div;for(let n of nH.#j.values())t.toggle(`${n._type}Editing`,e===n._editorType);this.div.hidden=!1}hasTextLayer(e){return e===this.#oq?.div}addInkEditorIfNeeded(e){if(this.#p.getMode()===h.INK){if(!e){for(let e of this.#oV.values())if(e.isEmpty()){e.setInBackground();return}}this.createAndAddNewEditor({offsetX:0,offsetY:0},!1).setInBackground()}}setEditingState(e){this.#p.setEditingState(e)}addCommands(e){this.#p.addCommands(e)}togglePointerEvents(e=!1){this.div.classList.toggle("disabled",!e)}toggleAnnotationLayerPointerEvents(e=!1){this.#oj?.div.classList.toggle("disabled",!e)}enable(){this.div.tabIndex=0,this.togglePointerEvents(!0);let e=new Set;for(let t of this.#oV.values())t.enableEditing(),t.show(!0),t.annotationElementId&&(this.#p.removeChangedExistingAnnotation(t),e.add(t.annotationElementId));if(!!this.#oj)for(let t of this.#oj.getEditableAnnotations()){if(t.hide(),this.#p.isDeletedAnnotationElement(t.data.id)||e.has(t.data.id))continue;let n=this.deserialize(t);if(!!n)this.addOrRebuild(n),n.enableEditing()}}disable(){this.#oW=!0,this.div.tabIndex=-1,this.togglePointerEvents(!1);let e=new Map,t=new Map;for(let n of this.#oV.values()){if(n.disableEditing(),!!n.annotationElementId){if(null!==n.serialize()){e.set(n.annotationElementId,n);continue}t.set(n.annotationElementId,n);this.getEditableAnnotation(n.annotationElementId)?.show(),n.remove()}}if(this.#oj)for(let n of this.#oj.getEditableAnnotations()){let{id:i}=n.data;if(this.#p.isDeletedAnnotationElement(i))continue;let r=t.get(i);if(r){r.resetAnnotationElement(n),r.show(!1),n.show();continue}(r=e.get(i))&&(this.#p.addChangedExistingAnnotation(r),r.renderAnnotationElement(n),r.show(!1)),n.show()}this.#oG(),this.isEmpty&&(this.div.hidden=!0);let{classList:n}=this.div;for(let e of nH.#j.values())n.remove(`${e._type}Editing`);this.disableTextSelection(),this.toggleAnnotationLayerPointerEvents(!0),this.#oW=!1}getEditableAnnotation(e){return this.#oj?.getEditableAnnotation(e)||null}setActiveEditor(e){if(this.#p.getActive()!==e)this.#p.setActiveEditor(e)}enableTextSelection(){this.div.tabIndex=-1,this.#oq?.div&&!this.#oz&&(this.#oz=this.#oK.bind(this),this.#oq.div.addEventListener("pointerdown",this.#oz,{signal:this.#p._signal}),this.#oq.div.classList.add("highlighting"))}disableTextSelection(){this.div.tabIndex=0,this.#oq?.div&&this.#oz&&(this.#oq.div.removeEventListener("pointerdown",this.#oz),this.#oz=null,this.#oq.div.classList.remove("highlighting"))}#oK(e){if(this.#p.unselectAll(),e.target===this.#oq.div){let{isMac:t}=z.platform;if(0===e.button&&(!e.ctrlKey||!t))this.#p.showAllEditors("highlight",!0,!0),this.#oq.div.classList.add("free"),nF.startHighlighting(this,"ltr"===this.#p.direction,e),this.#oq.div.addEventListener("pointerup",()=>{this.#oq.div.classList.remove("free")},{once:!0,signal:this.#p._signal}),e.preventDefault()}}enableClick(){if(this.#oB)return;let e=this.#p._signal;this.#oB=this.pointerdown.bind(this),this.#oF=this.pointerup.bind(this),this.div.addEventListener("pointerdown",this.#oB,{signal:e}),this.div.addEventListener("pointerup",this.#oF,{signal:e})}disableClick(){if(!!this.#oB)this.div.removeEventListener("pointerdown",this.#oB),this.div.removeEventListener("pointerup",this.#oF),this.#oB=null,this.#oF=null}attach(e){this.#oV.set(e.id,e);let{annotationElementId:t}=e;t&&this.#p.isDeletedAnnotationElement(t)&&this.#p.removeDeletedAnnotationElement(e)}detach(e){this.#oV.delete(e.id),this.#ip?.removePointerInTextLayer(e.contentDiv),!this.#oW&&e.annotationElementId&&this.#p.addDeletedAnnotationElement(e)}remove(e){this.detach(e),this.#p.removeEditor(e),e.div.remove(),e.isAttachedToDOM=!1,!this.#o$&&this.addInkEditorIfNeeded(!1)}changeParent(e){if(e.parent!==this)e.parent&&e.annotationElementId&&(this.#p.addDeletedAnnotationElement(e.annotationElementId),eO.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.#p.addEditor(e),this.attach(e),!e.isAttachedToDOM){let t=e.render();this.div.append(t),e.isAttachedToDOM=!0}e.fixAndSetPosition(),e.onceAdded(),this.#p.addToAnnotationStorage(e),e._reportTelemetry(e.telemetryInitialData)}}moveEditorInDOM(e){if(!e.isAttachedToDOM)return;let{activeElement:t}=document;e.div.contains(t)&&!this.#oH&&(e._focusEventsAllowed=!1,this.#oH=setTimeout(()=>{this.#oH=null,e.div.contains(document.activeElement)?e._focusEventsAllowed=!0:(e.div.addEventListener("focusin",()=>{e._focusEventsAllowed=!0},{once:!0,signal:this.#p._signal}),t.focus())},0)),e._structTreeParentId=this.#ip?.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.#p.getId()}get #oZ(){return nH.#j.get(this.#p.getMode())}get _signal(){return this.#p._signal}#oY(e){let t=this.#oZ;return t?new t.prototype.constructor(e):null}canCreateNewEmptyEditor(){return this.#oZ?.canCreateNewEmptyEditor()}pasteEditor(e,t){this.#p.updateToolbar(e),this.#p.updateMode(e);let{offsetX:n,offsetY:i}=this.#oX(),r=this.getNextId(),o=this.#oY({parent:this,id:r,x:n,y:i,uiManager:this.#p,isCentered:!0,...t});o&&this.add(o)}deserialize(e){return nH.#j.get(e.annotationType??e.annotationEditorType)?.deserialize(e,this,this.#p)||null}createAndAddNewEditor(e,t,n={}){let i=this.getNextId(),r=this.#oY({parent:this,id:i,x:e.offsetX,y:e.offsetY,uiManager:this.#p,isCentered:t,...n});return r&&this.add(r),r}#oX(){let{x:e,y:t,width:n,height:i}=this.div.getBoundingClientRect(),r=Math.max(0,e),o=Math.max(0,t),s=Math.min(window.innerWidth,e+n),a=Math.min(window.innerHeight,t+i),l=(r+s)/2-e,d=(o+a)/2-t,[c,h]=this.viewport.rotation%180==0?[l,d]:[d,l];return{offsetX:c,offsetY:h}}addNewEditor(){this.createAndAddNewEditor(this.#oX(),!0)}setSelected(e){this.#p.setSelected(e)}toggleSelected(e){this.#p.toggleSelected(e)}isSelected(e){return this.#p.isSelected(e)}unselect(e){this.#p.unselect(e)}pointerup(e){let{isMac:t}=z.platform;if(0===e.button&&(!e.ctrlKey||!t)&&e.target===this.div&&!!this.#oU){if(this.#oU=!1,!this.#oL){this.#oL=!0;return}if(this.#p.getMode()===h.STAMP){this.#p.unselectAll();return}this.createAndAddNewEditor(e,!1)}}pointerdown(e){if(this.#p.getMode()===h.HIGHLIGHT&&this.enableTextSelection(),this.#oU){this.#oU=!1;return}let{isMac:t}=z.platform;if(0!==e.button||e.ctrlKey&&t||e.target!==this.div)return;this.#oU=!0;let n=this.#p.getActive();this.#oL=!n||n.isEmpty()}findNewParent(e,t,n){let i=this.#p.findParent(t,n);return null!==i&&i!==this&&(i.changeParent(e),!0)}destroy(){for(let e of(this.#p.getActive()?.parent===this&&(this.#p.commitOrRemove(),this.#p.setActiveEditor(null)),this.#oH&&(clearTimeout(this.#oH),this.#oH=null),this.#oV.values()))this.#ip?.removePointerInTextLayer(e.contentDiv),e.setParent(null),e.isAttachedToDOM=!1,e.div.remove();this.div=null,this.#oV.clear(),this.#p.removeLayer(this)}#oG(){for(let e of(this.#o$=!0,this.#oV.values()))e.isEmpty()&&e.remove();this.#o$=!1}render({viewport:e}){for(let t of(this.viewport=e,ex(this.div,e),this.#p.getEditors(this.pageIndex)))this.add(t),t.rebuild();this.updateMode()}update({viewport:e}){this.#p.commitOrRemove(),this.#oG();let t=this.viewport.rotation,n=e.rotation;if(this.viewport=e,ex(this.div,{rotation:n}),t!==n)for(let e of this.#oV.values())e.rotate(n);this.addInkEditorIfNeeded(!1)}get pageDimensions(){let{pageWidth:e,pageHeight:t}=this.viewport.rawDims;return[e,t]}get scale(){return this.#p.viewParameters.realScale}}class nV{#n2=null;#v=0;#oJ=new Map;#oQ=new Map;constructor({pageIndex:e}){this.pageIndex=e}setParent(e){if(!this.#n2){this.#n2=e;return}if(this.#n2!==e){if(this.#oJ.size>0)for(let t of this.#oJ.values())t.remove(),e.append(t);this.#n2=e}}static get _svgFactory(){return T(this,"_svgFactory",new er)}static #o0(e,{x:t=0,y:n=0,width:i=1,height:r=1}={}){let{style:o}=e;o.top=`${100*n}%`,o.left=`${100*t}%`,o.width=`${100*i}%`,o.height=`${100*r}%`}#o1(e){let t=nV._svgFactory.create(1,1,!0);return this.#n2.append(t),t.setAttribute("aria-hidden",!0),nV.#o0(t,e),t}#o2(e,t){let n=nV._svgFactory.createElement("clipPath");e.append(n);let i=`clip_${t}`;n.setAttribute("id",i),n.setAttribute("clipPathUnits","objectBoundingBox");let r=nV._svgFactory.createElement("use");return n.append(r),r.setAttribute("href",`#${t}`),r.classList.add("clip"),i}highlight(e,t,n,i=!1){let r=this.#v++,o=this.#o1(e.box);o.classList.add("highlight"),e.free&&o.classList.add("free");let s=nV._svgFactory.createElement("defs");o.append(s);let a=nV._svgFactory.createElement("path");s.append(a);let l=`path_p${this.pageIndex}_${r}`;a.setAttribute("id",l),a.setAttribute("d",e.toSVGPath()),i&&this.#oQ.set(r,a);let d=this.#o2(s,l),c=nV._svgFactory.createElement("use");return o.append(c),o.setAttribute("fill",t),o.setAttribute("fill-opacity",n),c.setAttribute("href",`#${l}`),this.#oJ.set(r,o),{id:r,clipPathId:`url(#${d})`}}highlightOutline(e){let t;let n=this.#v++,i=this.#o1(e.box);i.classList.add("highlightOutline");let r=nV._svgFactory.createElement("defs");i.append(r);let o=nV._svgFactory.createElement("path");r.append(o);let s=`path_p${this.pageIndex}_${n}`;if(o.setAttribute("id",s),o.setAttribute("d",e.toSVGPath()),o.setAttribute("vector-effect","non-scaling-stroke"),e.free){i.classList.add("free");let e=nV._svgFactory.createElement("mask");r.append(e),t=`mask_p${this.pageIndex}_${n}`,e.setAttribute("id",t),e.setAttribute("maskUnits","objectBoundingBox");let o=nV._svgFactory.createElement("rect");e.append(o),o.setAttribute("width","1"),o.setAttribute("height","1"),o.setAttribute("fill","white");let a=nV._svgFactory.createElement("use");e.append(a),a.setAttribute("href",`#${s}`),a.setAttribute("stroke","none"),a.setAttribute("fill","black"),a.setAttribute("fill-rule","nonzero"),a.classList.add("mask")}let a=nV._svgFactory.createElement("use");i.append(a),a.setAttribute("href",`#${s}`),t&&a.setAttribute("mask",`url(#${t})`);let l=a.cloneNode();return i.append(l),a.classList.add("mainOutline"),l.classList.add("secondaryOutline"),this.#oJ.set(n,i),n}finalizeLine(e,t){let n=this.#oQ.get(e);this.#oQ.delete(e),this.updateBox(e,t.box),n.setAttribute("d",t.toSVGPath())}updateLine(e,t){this.#oJ.get(e).firstChild.firstChild.setAttribute("d",t.toSVGPath())}removeFreeHighlight(e){this.remove(e),this.#oQ.delete(e)}updatePath(e,t){this.#oQ.get(e).setAttribute("d",t.toSVGPath())}updateBox(e,t){nV.#o0(this.#oJ.get(e),t)}show(e,t){this.#oJ.get(e).classList.toggle("hidden",!t)}rotate(e,t){this.#oJ.get(e).setAttribute("data-main-rotation",t)}changeColor(e,t){this.#oJ.get(e).setAttribute("fill",t)}changeOpacity(e,t){this.#oJ.get(e).setAttribute("fill-opacity",t)}addClass(e,t){this.#oJ.get(e).classList.add(t)}removeClass(e,t){this.#oJ.get(e).classList.remove(t)}remove(e){if(null!==this.#n2)this.#oJ.get(e).remove(),this.#oJ.delete(e)}destroy(){for(let e of(this.#n2=null,this.#oJ.values()))e.remove();this.#oJ.clear()}}var nU=o.AbortException,n$=o.AnnotationEditorLayer,nW=o.AnnotationEditorParamsType,nq=o.AnnotationEditorType,nG=o.AnnotationEditorUIManager,nK=o.AnnotationLayer,nZ=o.AnnotationMode,nY=o.CMapCompressionType,nX=o.ColorPicker,nJ=o.DOMSVGFactory,nQ=o.DrawLayer,n0=o.FeatureTest,n1=o.GlobalWorkerOptions,n2=o.ImageKind,n5=o.InvalidPDFException,n3=o.MissingPDFException,n4=o.OPS,n6=o.Outliner,n8=o.PDFDataRangeTransport,n7=o.PDFDateString,n9=o.PDFWorker,ie=o.PasswordResponses,it=o.PermissionFlag,ii=o.PixelsPerInch,ir=o.RenderingCancelledException,io=o.TextLayer,is=o.UnexpectedResponseException,ia=o.Util,il=o.VerbosityLevel,id=o.XfaLayer,ic=o.build,ih=o.createValidAbsoluteUrl,iu=o.fetchData,ip=o.getDocument,im=o.getFilenameFromUrl,ig=o.getPdfFilenameFromUrl,iv=o.getXfaPageViewport,ib=o.isDataScheme,iy=o.isPdfFile,ix=o.noContextMenu,iw=o.normalizeUnicode,i_=o.renderTextLayer,iS=o.setLayerDimensions,iC=o.shadow,iA=o.updateTextLayer,iE=o.version},132308:function(e,t,n){n.d(t,{$:function(){return d},h:function(){return l}});var i=n(896433),r=n(871738);let o="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),s="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function a(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function l(e){return new r.Sy({props:{handleKeyDown:d(e)}})}function d(e){let t=function(e){let t=Object.create(null);for(let n in e)t[function(e){let t,n,i,r,s=e.split(/-(?!$)/),a=s[s.length-1];"Space"==a&&(a=" ");for(let e=0;eH,NB:()=>S,p2:()=>c,Ts:()=>w,ZU:()=>F,e4:()=>d,vc:()=>l,PW:()=>Y,HY:()=>r,V_:()=>B}),i.prototype={constructor:i,find:function(e){for(var t=0;t>1}},i.from=function(e){if(e instanceof i)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new i(t)};class r{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;te&&!1!==n(a,i+s,r||null,o)&&a.content.size){let r=s+1;a.nodesBetween(Math.max(0,e-r),Math.min(a.content.size,t-r),n,i+r)}s=l}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let r="",o=!0;return this.nodesBetween(e,t,(s,a)=>{let l=s.isText?s.text.slice(Math.max(e,a)-a,t-a):s.isLeaf?i?"function"==typeof i?i(s):i:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(o?o=!1:r+=n),r+=l},0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),o=1);oe)for(let r=0,o=0;oe&&((ot)&&(s=s.isText?s.cut(Math.max(0,e-o),Math.min(s.text.length,t-o)):s.cut(Math.max(0,e-o-1),Math.min(s.content.size,t-o-1))),n.push(s),i+=s.nodeSize),o=a}return new r(n,i)}cutByIndex(e,t){return e==t?r.empty:0==e&&t==this.content.length?this:new r(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new r(i,o)}addToStart(e){return new r([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new r(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,i=0;;n++){let r=i+this.child(n).nodeSize;if(r>=e){if(r==e||t>0)return s(n+1,r);return s(n,i)}i=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return r.empty;if(!Array.isArray(t))throw RangeError("Invalid input for Fragment.fromJSON");return new r(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return r.empty;let t,n=0;for(let i=0;ithis.type.rank&&(!t&&(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(r)}}return!t&&(t=e.slice()),!n&&t.push(this),t}removeFromSet(e){for(let t=0;te.type.rank-t.type.rank),t}}l.none=[];class d extends Error{}class c{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=function e(t,n,i,r){let{index:o,offset:s}=t.findIndex(n),a=t.maybeChild(o);if(s==n||a.isText)return r&&!r.canReplace(o,o,i)?null:t.cut(0,n).append(i).append(t.cut(n));let l=e(a.content,n-s-1,i);return l&&t.replaceChild(o,a.copy(l))}(this.content,e+this.openStart,t);return n&&new c(n,this.openStart,this.openEnd)}removeBetween(e,t){return new c(function e(t,n,i){let{index:r,offset:o}=t.findIndex(n),s=t.maybeChild(r),{index:a,offset:l}=t.findIndex(i);if(o==n||s.isText){if(l!=i&&!t.child(a).isText)throw RangeError("Removing non-flat range");return t.cut(0,n).append(t.cut(i))}if(r!=a)throw RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(e(s.content,n-o-1,i-o-1)))}(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return c.empty;let n=t.openStart||0,i=t.openEnd||0;if("number"!=typeof n||"number"!=typeof i)throw RangeError("Invalid input for Slice.fromJSON");return new c(r.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)i++;return new c(e,n,i)}}c.empty=new c(r.empty,0,0);function h(e,t){if(!t.type.compatibleContent(e.type))throw new d("Cannot join "+t.type.name+" onto "+e.type.name)}function u(e,t,n){let i=e.node(n);return h(i,t.node(n)),i}function p(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function f(e,t,n,i){let r=(t||e).node(n),o=0,s=t?t.index(n):r.childCount;e&&(o=e.index(n),e.depth>n?o++:e.textOffset&&(p(e.nodeAfter,i),o++));for(let e=o;en&&p(m(u(e,t,n+1),g(e,t,n+1)),i),f(t,null,n,i),new r(i)}class v{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],i=0==t?0:this.path[3*t-1]+1;for(let t=0;t0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new w(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&t<=e.content.size))throw RangeError("Position "+t+" out of range");let n=[],i=0,r=t;for(let t=e;;){let{index:e,offset:o}=t.content.findIndex(r),s=r-o;if(n.push(t,e,i+o),!s||(t=t.child(e)).isText)break;r=s-1,i+=o+1}return new v(t,n,r)}static resolveCached(e,t){let n=x.get(e);if(n)for(let e=0;ee.depth)throw new d("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new d("Inconsistent open depths");return function e(t,n,i,o){let s=t.index(o),a=t.node(o);if(s==n.index(o)&&o=0;e--)i=t.node(e).copy(r.from(i));return{start:i.resolveNoCache(e.openStart+n),end:i.resolveNoCache(i.content.size-e.openEnd-n)}}(i,t);return m(a,function e(t,n,i,o,s){let a=t.depth>s&&u(t,n,s+1),l=o.depth>s&&u(i,o,s+1),d=[];return f(null,t,s,d),a&&l&&n.index(s)==i.index(s)?(h(a,l),p(m(a,e(t,n,i,o,s+1)),d)):(a&&p(m(a,g(t,n,s+1)),d),f(n,i,s,d),l&&p(m(l,g(i,o,s+1)),d)),f(o,null,s,d),new r(d)}(t,e,s,n,o))}else{let e=t.parent,r=e.content;return m(e,r.cut(0,t.parentOffset).append(i.content).append(r.cut(n.parentOffset)))}}(e,t,n,0)}(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(!(t=t.maybeChild(n)))return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(ne&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),A(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=r.empty,i=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,i,o),a=s&&s.matchFragment(this.content,t);if(!a||!a.validEnd)return!1;for(let e=i;ee.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){let n;if(!t)throw RangeError("Invalid input for Node.fromJSON");if(t.marks){if(!Array.isArray(t.marks))throw RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw RangeError("Invalid text node in JSON");return e.text(t.text,n)}let i=r.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,i,n);return o.type.checkAttrs(o.attrs),o}}S.prototype.text=void 0;class C extends S{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):A(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new C(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new C(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function A(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class E{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new k(e,t);if(null==n.next)return E.empty;let i=T(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return function n(i){let r=[];i.forEach(t=>{e[t].forEach(({term:t,to:n})=>{let i;if(t){for(let e=0;e{!i&&r.push([t,i=[]]),-1==i.indexOf(e)&&i.push(e)})}})});let o=t[i.join(",")]=new E(i.indexOf(e.length-1)>-1);for(let e=0;et.concat(e(n,o)),[]);if("seq"==t.type)for(let i=0;;i++){let s=e(t.exprs[i],o);if(i==t.exprs.length-1)return s;r(s,o=n())}else if("star"==t.type){let s=n();return i(o,s),r(e(t.expr,s),s),[i(s)]}else if("plus"==t.type){let s=n();return r(e(t.expr,o),s),r(e(t.expr,s),s),[i(s)]}else if("opt"==t.type)return[i(o)].concat(e(t.expr,o));else if("range"==t.type){let s=o;for(let i=0;ie.to=t)}}(i));return function(e,t){for(let n=0,i=[e];ne.createAndFill()));for(let e=0;e=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return!function t(n){e.push(n);for(let i=0;i{let i=n+(t.validEnd?"*":" ")+" ";for(let n=0;n"+e.indexOf(t.next[n].next);return i}).join("\n")}}E.empty=new E(!0);class k{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+" (in content expression '"+this.string+"')")}}function T(e){let t=[];do t.push(function(e){let t=[];do t.push(function(e){let t=function(e){if(e.eat("(")){let t=T(e);return!e.eat(")")&&e.err("Missing closing paren"),t}if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=(function(e,t){let n=e.nodeTypes,i=n[t];if(i)return[i];let r=[];for(let e in n){let i=n[e];i.isInGroup(t)&&r.push(i)}return 0==r.length&&e.err("No node type or group '"+t+"' found"),r})(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=function(e,t){let n=M(e),i=n;return e.eat(",")&&(i="}"!=e.next?M(e):-1),!e.eat("}")&&e.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:t}}(e,t);else break;return t}(e));while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}(e));while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function M(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function D(e,t){return t-e}function O(e,t){let n=[];return function t(i){let r=e[i];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(i);for(let e=0;e-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:N(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error("NodeType.create can't construct text nodes");return new S(this,this.computeAttrs(e),r.from(t),l.setFrom(n))}createChecked(e=null,t,n){return t=r.from(t),this.checkContent(t),new S(this,this.computeAttrs(e),t,l.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=r.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let i=this.contentMatch.matchFragment(t),o=i&&i.fillBefore(r.empty,!0);return o?new S(this,e,t.append(o),l.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;tn[e]=new L(e,t,i));let i=t.spec.topNode||"doc";if(!n[i])throw RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw RangeError("The text node type should not have attributes");return n}}class j{constructor(e,t,n){var i,r;let o;this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default;this.validate="string"==typeof n.validate?(i=e,r=t,o=n.validate.split("|"),e=>{let t=null===e?"null":typeof e;if(0>o.indexOf(t))throw RangeError(`Expected value of type ${o} for attribute ${r} on type ${i}, got ${t}`)}):n.validate}get isRequired(){return!this.hasDefault}}class F{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=R(e,i.attrs),this.excluded=null;let r=I(this.attrs);this.instance=r?new l(this,r):null}create(e=null){return!e&&this.instance?this.instance:new l(this,N(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((e,r)=>n[e]=new F(e,i++,t,r)),n}removeFromSet(e){for(var t=0;t-1}}class B{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=i.from(e.nodes),t.marks=i.from(e.marks||{}),this.nodes=L.compile(this.spec.nodes,this),this.marks=F.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],i=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=n[i]||(n[i]=E.parse(i,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?z(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:z(this,n.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if("string"==typeof e)e=this.nodeType(e);else if(e instanceof L){if(e.schema!=this)throw RangeError("Node type from different schema used ("+e.name+")")}else throw RangeError("Invalid node type: "+e);return e.createChecked(t,n,i)}text(e,t){let n=this.nodes.text;return new C(n,n.defaultAttrs,e,l.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return S.fromJSON(this,e)}markFromJSON(e){return l.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError("Unknown node type: "+e);return t}}function z(e,t){let n=[];for(let i=0;i-1)&&n.push(s=i)}if(!s)throw SyntaxError("Unknown mark type: '"+t[i]+"'")}return n}class H{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(null!=e.tag)this.tags.push(e);else if(null!=e.style){let t=/[^=]*/.exec(e.style)[0];0>n.indexOf(t)&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new G(this,t,!1);return n.addAll(e,l.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new G(this,t,!0);return n.addAll(e,l.none,t.from,t.to),c.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;ie.length)||61==o.charCodeAt(e.length)&&o.slice(e.length+1)==t)){if(i.getAttrs){let e=i.getAttrs(t);if(!1===e)continue;i.attrs=e||void 0}return i}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,i=0;for(;i{n(e=K(e)),!(e.mark||e.ignore||e.clearMark)&&(e.mark=t)})}for(let t in e.nodes){let i=e.nodes[t].spec.parseDOM;i&&i.forEach(e=>{n(e=K(e)),!(e.node||e.ignore||e.mark)&&(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new H(e,H.schemaRules(e)))}}let V={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},U={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},$={ol:!0,ul:!0};function W(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class q{constructor(e,t,n,i,r,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=l.none,this.match=r||(4&o?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(r.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e=this.content[this.content.length-1],t;e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))&&(e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=e.withText(e.text.slice(0,e.text.length-t[0].length)))}let t=r.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(r.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!V.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class G{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,r,o=W(null,t.preserveWhitespace,0)|(n?4:0);r=i?new q(i.type,i.attrs,l.none,!0,t.topMatch||i.type.contentMatch,o):n?new q(null,null,l.none,!0,null,o):new q(e.schema.topNodeType,null,l.none,!0,null,o),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,i=this.top,r=2&i.options?"full":this.localPreserveWS||(1&i.options)>0;if("full"===r||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=i.content[i.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),s;$.hasOwnProperty(o)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&$.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,n));n:if(a?a.ignore:U.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let n,i=this.needsBlock;if(V.hasOwnProperty(o))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,!r.type&&(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break n}let s=a&&a.skip?t:this.readStyles(e,t);s&&this.addAll(e,s),n&&this.sync(r),this.needsBlock=i}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,a,n,!1===a.consuming?s:void 0)}this.localPreserveWS=i}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"==e.nodeName&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1===n.consuming)e=n;else break}}return t}addElementByRule(e,t,n,i){let r,o;if(t.node){if((o=this.parser.schema.nodes[t.node]).isLeaf)!this.insertNode(o.create(t.attrs),n,"BR"==e.nodeName)&&this.leafFallback(e,n);else{let e=this.enter(o,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let i=e;"string"==typeof t.contentElement?i=e.querySelector(t.contentElement):"function"==typeof t.contentElement?i=t.contentElement(e):t.contentElement&&(i=t.contentElement),this.findAround(e,i,!0),this.addAll(i,n),this.findAround(e,i,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,i){let r=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=null==i?null:e.childNodes[i];o!=s;o=o.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(o,t);this.findAtPoint(e,r)}findPlace(e,t,n){let i,r;for(let t=this.open,o=0;t>=0;t--){let s=this.nodes[t],a=s.findWrapping(e);if(a&&(!i||i.length>a.length+o)&&(i=a,r=s,!a.length))break;if(s.solid){if(n)break;o+=2}}if(!i)return null;this.sync(r);for(let e=0;e(o.type?!o.type.allowsMarkType(t.type):!Z(t.type,e))||(a=t.addToSet(a),!1)),this.nodes.push(new q(e,t,a,i,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),r=-(n?n.depth+1:0)+(i?0:1),o=(e,s)=>{for(;e>=0;e--){let a=t[e];if(""==a){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(o(e-1,s))return!0;return!1}{let e=s>0||0==s&&i?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=a&&!e.isInGroup(a))return!1;s--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function K(e){let t={};for(let n in e)t[n]=e[n];return t}function Z(e,t){let n=t.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(e))continue;let o=[],s=e=>{o.push(e);for(let n=0;no.indexOf(r)&&s(r))return!0}};if(s(r.contentMatch))return!0}}class Y{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){!n&&(n=J(t).createDocumentFragment());let i=n,r=[];return e.forEach(e=>{if(r.length||e.marks.length){let n=0,o=0;for(;n=0;i--){let r=this.serializeMark(e.marks[i],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&ee(J(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return ee(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Y(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=X(e.nodes);return!t.text&&(t.text=e=>e.text),t}static marksFromSchema(e){return X(e.marks)}}function X(e){let t={};for(let n in e){let i=e[n].spec.toDOM;i&&(t[n]=i)}return t}function J(e){return e.document||window.document}let Q=new WeakMap;function ee(e,t,n,i){var r;let o,s;if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let a=t[0],l;if("string"!=typeof a)throw RangeError("Invalid array passed to renderSpec");if(i&&(r=i,void 0===(s=Q.get(r))&&Q.set(r,s=function(e){let t=null;return!function e(n){if(n&&"object"==typeof n){if(Array.isArray(n)){if("string"==typeof n[0])!t&&(t=[]),t.push(n);else for(let t=0;t-1)throw RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let d=a.indexOf(" ");d>0&&(n=a.slice(0,d),a=a.slice(d+1));let c=n?e.createElementNS(n,a):e.createElement(a),h=t[1],u=1;if(h&&"object"==typeof h&&null==h.nodeType&&!Array.isArray(h)){for(let e in u=2,h)if(null!=h[e]){let t=e.indexOf(" ");t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),h[e]):c.setAttribute(e,h[e])}}for(let r=u;ru)throw RangeError("Content hole must be the only child of its parent node");return{dom:c,contentDOM:c}}{let{dom:t,contentDOM:r}=ee(e,s,n,i);if(c.appendChild(t),r){if(o)throw RangeError("Multiple content holes");o=r}}}return{dom:c,contentDOM:o}}},871738:function(e,t,n){n.d(t,{Bs:function(){return c},C1:function(){return f},H$:function(){return k},Sy:function(){return C},Y1:function(){return s},qv:function(){return u},xm:function(){return a},yy:function(){return S}});var i=n(153737),r=n(240554);let o=Object.create(null);class s{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new a(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t=0;i--){let r=t<0?g(e.node(0),e.node(i),e.before(i+1),e.index(i),t,n):g(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new f(e.node(0))}static atStart(e){return g(e,e,0,0,1)||new f(e)}static atEnd(e){return g(e,e,e.content.size,e.childCount,-1)||new f(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError("Invalid input for Selection.fromJSON");let n=o[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in o)throw RangeError("Duplicate use of selection JSON ID "+e);return o[e]=t,t.prototype.jsonID=e,t}getBookmark(){return c.between(this.$anchor,this.$head).getBookmark()}}s.prototype.visible=!0;class a{constructor(e,t){this.$from=e,this.$to=t}}let l=!1;function d(e){!l&&!e.parent.inlineContent&&(l=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class c extends s{constructor(e,t=e){d(e),d(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return s.near(n);let i=e.resolve(t.map(this.anchor));return new c(i.parent.inlineContent?i:n,n)}replace(e,t=i.p2.empty){if(super.replace(e,t),t==i.p2.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof c&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new h(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw RangeError("Invalid input for TextSelection.fromJSON");return new c(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let e=s.findFrom(t,n,!0)||s.findFrom(t,-n,!0);if(!e)return s.near(t,n);t=e.$head}return!e.parent.inlineContent&&(0==i?e=t:(e=(s.findFrom(e,-n,!0)||s.findFrom(e,n,!0)).$anchor).posnew f(e)};function g(e,t,n,i,r,o=!1){if(t.inlineContent)return c.create(e,n);for(let s=i-(r>0?0:1);r>0?s=0;s+=r){let i=t.child(s);if(i.isAtom){if(!o&&u.isSelectable(i))return u.create(e,n-(r<0?i.nodeSize:0))}else{let t=g(e,i,n+r,r<0?i.childCount:0,r,o);if(t)return t}n+=i.nodeSize*r}return null}function v(e,t,n){let i,o=e.steps.length-1;if(o{null==i&&(i=r)}),e.setSelection(s.near(e.doc.resolve(i),n))}class b extends r.wx{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return!i.vc.sameSet(this.storedMarks||this.selection.$from.marks(),e)&&this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||i.vc.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,r)),!this.selection.empty&&this.setSelection(s.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function y(e,t){return t&&e?e.bind(t):e}class x{constructor(e,t,n){this.name=e,this.init=y(t.init,n),this.apply=y(t.apply,n)}}let w=[new x("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new x("selection",{init:(e,t)=>e.selection||s.atStart(t.doc),apply:e=>e.selection}),new x("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,i)=>i.selection.$cursor?e.storedMarks:null}),new x("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class _{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=w.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new x(e.key,e.spec.state,e))})}}class S{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;ne.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],r=i.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw RangeError("Required config field 'schema' missing");let r=new _(e.schema,e.plugins),o=new S(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=i.NB.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=s.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(t,i)){o[r.name]=a.fromJSON.call(s,e,t[i],o);return}}o[r.name]=r.init(e,o)}}),o}}class C{constructor(e){this.spec=e,this.props={},e.props&&!function e(t,n,i){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(n):"handleDOMEvents"==r&&(o=e(o,n,{})),i[r]=o}return i}(e.props,this,this.props),this.key=e.key?e.key.key:E("plugin")}getState(e){return e[this.key]}}let A=Object.create(null);function E(e){return e in A?e+"$"+ ++A[e]:(A[e]=0,e+"$")}class k{constructor(e="key"){this.key=E(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}},240554:function(e,t,n){n.d(t,{Ax:function(){return A},FC:function(){return v},GJ:function(){return T},Mn:function(){return E},Pu:function(){return g},dR:function(){return D},k9:function(){return x},nd:function(){return w},nj:function(){return M},vs:function(){return a},wx:function(){return H}});var i=n(153737);function r(e){return 65535&e}class o{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class s{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&s.empty)return s.empty}recover(e){var t;let n=0,i=65535&e;if(!this.inverted)for(let e=0;ee)break;let d=this.ranges[a+r],c=this.ranges[a+s],h=l+d;if(e<=h){let r=d?e==l?-1:e==h?1:t:t,s=l+i+(r<0?0:c);if(n)return s;let u=e==(t<0?l:h)?null:a/3+(e-l)*65536,p=e==l?2:e==h?1:4;return(t<0?e!=l:e!=h)&&(p|=8),new o(s,p,u)}i+=c-d}return n?e+i:new o(e+i,0,null)}touches(e,t){let n=0,i=65535&t,r=this.inverted?2:1,o=this.inverted?1:2;for(let t=0;te)break;let a=this.ranges[t+r];if(e<=s+a&&t==3*i)return!0;n+=this.ranges[t+o]-a}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,r=0;i=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=i&&i>t?n-i-1:void 0)}}invert(){let e=new a;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;nn&&te.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return c.fromReplace(e,this.from,this.to,o)}invert(){return new p(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new u(t.pos,n.pos,this.mark)}merge(e){return e instanceof u&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new u(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for AddMarkStep.fromJSON");return new u(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("addMark",u);class p extends d{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new i.p2(h(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return c.fromReplace(e,this.from,this.to,n)}invert(){return new u(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new p(t.pos,n.pos,this.mark)}merge(e){return e instanceof p&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new p(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw RangeError("Invalid input for RemoveMarkStep.fromJSON");return new p(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("removeMark",p);class f extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return c.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return c.fromReplace(e,this.pos,this.pos+1,new i.p2(i.HY.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;nn.pos?null:new v(t.pos,n.pos,i,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new v(t.from,t.to,t.gapFrom,t.gapTo,i.p2.fromJSON(e,t.slice),t.insert,!!t.structure)}}function b(e,t,n){let i=e.resolve(t),r=n-t,o=i.depth;for(;r>0&&o>0&&i.indexAfter(o)==i.node(o).childCount;)o--,r--;if(r>0){let e=i.node(o).maybeChild(i.indexAfter(o));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}d.jsonID("replaceAround",v);function y(e,t,n,r=n.contentMatch,o=!0){let s=e.doc.nodeAt(t),a=[],l=t+1;for(let t=0;t=0;t--)e.step(a[t])}function x(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let o=e.depth;;--o){var n,i,r;let s=e.$from.node(o),a=e.$from.index(o),l=e.$to.indexAfter(o);if(o{if(r.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(r.text);){let r=e.mapping.slice(i).map(n+1+o+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}})}function C(e,t,n,i){t.forEach((r,o)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(i).map(n+1+o);e.replaceWith(r,r+1,t.type.schema.text("\n"))}})}function A(e,t,n=1,i){let r=e.resolve(t),o=r.depth-n,s=i&&i[i.length-1]||r.parent;if(o<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>o;e--,t--){let n=r.node(e),o=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(o,n.childCount),a=i&&i[t+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=i&&i[t]||n;if(!n.canReplace(o+1,n.childCount)||!l.type.validContent(s))return!1}let a=r.indexAfter(o),l=i&&i[0];return r.node(o).canReplaceWith(a,a,l?l.type:r.node(o+1).type)}function E(e,t){let n=e.resolve(t),i=n.index();return k(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function k(e,t){return!!(e&&t&&!e.isLeaf&&function(e,t){!t.content.size&&e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:i}=e.type.schema;for(let r=0;r0?(r=i.node(e+1),s++,o=i.node(e).maybeChild(s)):(r=i.node(e).maybeChild(s-1),o=i.node(e+1)),r&&!r.isTextblock&&k(r,o)&&i.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?i.before(e):i.after(e)}}function M(e,t,n){let i=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e=0;t--){let n=t==i.depth?0:i.pos<=(i.start(t+1)+i.end(t+1))/2?-1:1,o=i.index(t)+(n>0?1:0),s=i.node(t),a=!1;if(1==e)a=s.canReplace(o,o,r);else{let e=s.contentMatchAt(o).findWrapping(r.firstChild.type);a=e&&s.canReplaceWith(o,o,e[0])}if(a)return 0==n?i.pos:n<0?i.before(t+1):i.after(t+1)}return null}function D(e,t,n=t,r=i.p2.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),s=e.resolve(n);return O(o,s,r)?new g(t,n,r):new I(o,s,r).fit()}function O(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}class I{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=i.HY.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=i.HY.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,s=n.depth,a=r.depth;for(;s&&a&&1==o.childCount;)o=o.firstChild.content,s--,a--;let l=new i.p2(o,s,a);return e>-1?new v(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new g(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n1&&(i=0),r.type.spec.isolating&&i<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null,o=(e=n?(r=R(this.unplaced.content,n-1).firstChild).content:this.unplaced.content).firstChild;for(let e=this.depth;e>=0;e--){let{type:s,match:a}=this.frontier[e],l,d=null;if(1==t&&(o?a.matchType(o.type)||(d=a.fillBefore(i.HY.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:d};if(2==t&&o&&(l=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:l};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=R(e,t);return!!r.childCount&&!r.firstChild.isLeaf&&(this.unplaced=new i.p2(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=R(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new i.p2(N(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new i.p2(N(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e1||0==l||e.content.size)&&(h=t,c.push(function e(t,n,r){if(n<=0)return t;let o=t.content;return n>1&&(o=o.replaceChild(0,e(o.firstChild,n-1,1==o.childCount?r-1:0))),n>0&&(o=t.type.contentMatch.fillBefore(o).append(o),r<=0&&(o=o.append(t.type.contentMatch.matchFragment(o).fillBefore(i.HY.empty,!0)))),t.copy(o)}(e.mark(u.allowedMarks(e.marks)),1==d?l:0,d==a.childCount?p:-1)))}let f=d==a.childCount;!f&&(p=-1),this.placed=P(this.placed,t,i.HY.from(c)),this.frontier[t].match=h,f&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=a;e1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){i:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],r=t=0;n--){let{match:t,type:i}=this.frontier[n],r=L(e,n,i,t,!0);if(!r||r.childCount)continue i}return{depth:t,fit:o,move:r?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=P(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),i=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,i)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=P(this.placed,this.depth,i.HY.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(i.HY.empty,!0);e.childCount&&(this.placed=P(this.placed,this.frontier.length,e))}}function N(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(N(e.firstChild.content,t-1,n)))}function P(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(P(e.lastChild.content,t-1,n)))}function R(e,t){for(let n=0;n=0;r--){let i=e.start(r);if(it.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(i==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==i-1)&&n.push(r)}return n}class F extends d{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return c.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return c.fromReplace(e,this.pos,this.pos+1,new i.p2(i.HY.from(r),0,t.isLeaf?0:1))}getMap(){return s.empty}invert(e){return new F(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new F(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw RangeError("Invalid input for AttrStep.fromJSON");return new F(t.pos,t.attr,t.value)}}d.jsonID("attr",F);class B extends d{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return c.ok(n)}getMap(){return s.empty}invert(e){return new B(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw RangeError("Invalid input for DocAttrStep.fromJSON");return new B(t.attr,t.value)}}d.jsonID("docAttr",B);let z=class extends Error{};(z=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n}).prototype=Object.create(Error.prototype),z.prototype.constructor=z,z.prototype.name="TransformError";class H{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new a}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new z(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return!t.failed&&this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=i.p2.empty){let r=D(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new i.p2(i.HY.from(n),0,0))}delete(e,t){return this.replace(e,t,i.p2.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return!function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),s=e.doc.resolve(n);if(O(o,s,r))return e.step(new g(t,n,r));let a=j(o,e.doc.resolve(n));0==a[a.length-1]&&a.pop();let l=-(o.depth+1);a.unshift(l);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;a.indexOf(e)>-1?l=e:o.before(e)==t&&a.splice(1,0,-e)}let d=a.indexOf(l),c=[],h=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){var u;let t=c[e],n=(u=t.type).spec.defining||u.spec.definingForContent;if(n&&!t.sameMarkup(o.node(Math.abs(l)-1)))h=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let l=(t+h+1)%(r.openStart+1),u=c[l];if(u)for(let t=0;to){let e=s.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(i.HY.empty,!0))}return t}(r.content,0,r.openStart,l),l,r.openEnd))}}let p=e.steps.length;for(let i=a.length-1;i>=0&&(e.replace(t,n,r),!(e.steps.length>p));i--){;let e=a[i];!(e<0)&&(t=o.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return!function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=function(e,t,n){let i=e.resolve(t);if(i.parent.canReplaceWith(i.index(),i.index(),n))return t;if(0==i.parentOffset)for(let e=i.depth-1;e>=0;e--){let t=i.index(e);if(i.node(e).canReplaceWith(t,t,n))return i.before(e+1);if(t>0)return null}if(i.parentOffset==i.parent.content.size)for(let e=i.depth-1;e>=0;e--){let t=i.indexAfter(e);if(i.node(e).canReplaceWith(t,t,n))return i.after(e+1);if(t0&&(s||i.node(n-1).canReplace(i.index(n-1),r.indexAfter(n-1))))return e.delete(i.before(n),r.after(n))}for(let o=1;o<=i.depth&&o<=r.depth;o++)if(t-i.start(o)==i.depth-o&&n>i.end(o)&&r.end(o)-n!=r.depth-o&&i.start(o-1)==r.start(o-1)&&i.node(o-1).canReplace(i.index(o-1),r.index(o-1)))return e.delete(i.before(o),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return!function(e,t,n){let{$from:r,$to:o,depth:s}=t,a=r.before(s+1),l=o.after(s+1),d=a,c=l,h=i.HY.empty,u=0;for(let e=s,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,h=i.HY.from(r.node(e).copy(h)),u++):d--;let p=i.HY.empty,f=0;for(let e=s,t=!1;e>n;e--)t||o.after(e+1)=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=i.HY.from(n[e].type.create(n[e].attrs,r))}let o=t.start,s=t.end;e.step(new v(o,s,o,s,new i.p2(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return!function(e,t,n,r,o){if(!r.isTextblock)throw RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let a="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,a)&&function(e,t,n){let i=e.resolve(t),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(s).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&C(e,t,n,s),y(e,e.mapping.slice(s).map(n,1),r,void 0,null===o);let l=e.mapping.slice(s),d=l.map(n,1),c=l.map(n+t.nodeSize,1);return e.step(new v(d,c,d+1,c-1,new i.p2(i.HY.from(r.create(a,null,t.marks)),0,0),1,!0)),!0===o&&S(e,t,n,s),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return!function(e,t,n,r,o){let s=e.doc.nodeAt(t);if(!s)throw RangeError("No node at given position");!n&&(n=s.type);let a=n.create(r,null,o||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,a);if(!n.validContent(s.content))throw RangeError("Invalid content for node type "+n.name);e.step(new v(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new i.p2(i.HY.from(a),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new F(e,t,n)),this}setDocAttribute(e,t){return this.step(new B(e,t)),this}addNodeMark(e,t){return this.step(new f(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError("No node at position "+e);if(t instanceof i.vc)t.isInSet(n.marks)&&this.step(new m(e,t));else{let i=n.marks,r,o=[];for(;r=t.isInSet(i);)o.push(new m(e,r)),i=r.removeFromSet(i);for(let e=o.length-1;e>=0;e--)this.step(o[e])}return this}split(e,t=1,n){return!function(e,t,n=1,r){let o=e.doc.resolve(t),s=i.HY.empty,a=i.HY.empty;for(let e=o.depth,t=o.depth-n,l=n-1;e>t;e--,l--){s=i.HY.from(o.node(e).copy(s));let t=r&&r[l];a=i.HY.from(t?t.type.create(t.attrs,a):o.node(e).copy(a))}e.step(new g(t,t,new i.p2(s.append(a),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){var i,r,o,s;let a,l,d,c;return i=this,r=e,o=t,s=n,d=[],c=[],i.doc.nodesBetween(r,o,(e,t,n)=>{if(!e.isInline)return;let i=e.marks;if(!s.isInSet(i)&&n.type.allowsMarkType(s.type)){let n=Math.max(t,r),h=Math.min(t+e.nodeSize,o),f=s.addToSet(i);for(let e=0;ei.step(e)),c.forEach(e=>i.step(e)),this}removeMark(e,t,n){var r,o,s,a;let l,d;return r=this,o=e,s=t,a=n,l=[],d=0,r.doc.nodesBetween(o,s,(e,t)=>{if(!e.isInline)return;d++;let n=null;if(a instanceof i.ZU){let t=e.marks,i;for(;i=a.isInSet(t);)(n||(n=[])).push(i),t=i.removeFromSet(t)}else a?a.isInSet(e.marks)&&(n=[a]):n=e.marks;if(n&&n.length){let i=Math.min(t+e.nodeSize,s);for(let e=0;er.step(new p(e.from,e.to,e.style))),this}clearIncompatible(e,t,n){return y(this,e,t,n),this}}},661763:function(e,t,n){n.d(t,{EH:function(){return tx},p:function(){return tv},tk:function(){return tU}});var i=n(871738),r=n(153737),o=n(240554);let s=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},a=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t},l=null,d=function(e,t,n){let i=l||(l=document.createRange());return i.setEnd(e,null==n?e.nodeValue.length:n),i.setStart(e,t||0),i},c=function(){l=null},h=function(e,t,n,i){return n&&(p(e,t,n,i,-1)||p(e,t,n,i,1))},u=/^(img|br|input|textarea|hr)$/i;function p(e,t,n,i,r){for(var o;;){if(e==n&&t==i)return!0;if(t==(r<0?0:f(e))){let n=e.parentNode;if(!n||1!=n.nodeType||m(e)||u.test(e.nodeName)||"false"==e.contentEditable)return!1;t=s(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(null===(o=n.pmViewDesc)||void 0===o||!o.ignoreForSelection)return!1;t+=r}else e=n,t=r<0?f(e):0}}}function f(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function m(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}let g=function(e){return e.focusNode&&h(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function v(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}let b="undefined"!=typeof navigator?navigator:null,y="undefined"!=typeof document?document:null,x=b&&b.userAgent||"",w=/Edge\/(\d+)/.exec(x),_=/MSIE \d/.exec(x),S=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(x),C=!!(_||S||w),A=_?document.documentMode:S?+S[1]:w?+w[1]:0,E=!C&&/gecko\/(\d+)/i.test(x);E&&(/Firefox\/(\d+)/.exec(x)||[0,0])[1];let k=!C&&/Chrome\/(\d+)/.exec(x),T=!!k,M=k?+k[1]:0,D=!C&&!!b&&/Apple Computer/.test(b.vendor),O=D&&(/Mobile\/\w+/.test(x)||!!b&&b.maxTouchPoints>2),I=O||!!b&&/Mac/.test(b.platform),N=!!b&&/Win/.test(b.platform),P=/Android \d/.test(x),R=!!y&&"webkitFontSmoothing"in y.documentElement.style,L=R?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function j(e,t){return"number"==typeof e?e:e[t]}function F(e,t,n){let i=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,o=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=a(s);continue}let e=s,n=e==o.body,l=n?function(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}(o):function(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,i=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*i}}(e),d=0,c=0;if(t.topl.bottom-j(i,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+j(r,"top")-l.top:t.bottom-l.bottom+j(r,"bottom")),t.leftl.right-j(i,"right")&&(d=t.right-l.right+j(r,"right")),d||c){if(n)o.defaultView.scrollBy(d,c);else{let n=e.scrollLeft,i=e.scrollTop;c&&(e.scrollTop+=c),d&&(e.scrollLeft+=d);let r=e.scrollLeft-n,o=e.scrollTop-i;t={left:t.left-r,top:t.top-o,right:t.right-r,bottom:t.bottom-o}}}let h=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s="absolute"==h?s.offsetParent:a(s)}}function B(e){let t=[],n=e.ownerDocument;for(let i=e;i&&(t.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),e!=n);i=a(i));return t}function z(e,t){for(let n=0;n=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function U(e){return e.top=0&&r==i.nodeValue.length?(e--,o=1):n<0?e--:t++,G($(d(i,e,t),o),o<0)}}if(!e.state.doc.resolve(t-(o||0)).parent.inlineContent){if(null==o&&r&&(n<0||r==f(i))){let e=i.childNodes[r-1];if(1==e.nodeType)return K(e.getBoundingClientRect(),!1)}if(null==o&&r=0)}if(null==o&&r&&(n<0||r==f(i))){let e=i.childNodes[r-1],t=3==e.nodeType?d(e,f(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return G($(t,1),!1)}if(null==o&&r=0)}function G(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function K(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Z(e,t,n){let i=e.state,r=e.root.activeElement;i!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{i!=t&&e.updateState(i),r!=e.dom&&r&&r.focus()}}let Y=/[\u0590-\u08ac]/,X=null,J=null,Q=!1;class ee{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;ts(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!1;break}if(t.previousSibling)break}if(null==i&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){i=!0;break}if(t.nextSibling)break}}return(null==i?n>0:i)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let r=this.getDesc(i),o;if(r&&(!t||r.node)){if(!n||!(o=r.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return r;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let r=this.getDesc(i);if(r)return r.localPosFromDOM(e,t,n)}return -1}descAt(e){for(let t=0,n=0;te||r instanceof ea){i=e-t;break}t=o}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof et&&e.side>=0;n--);if(t<=0){let e,i=!0;for(;(e=n?this.children[n-1]:null)&&e.dom.parentNode!=this.contentDOM;n--,i=!1);return e&&t&&i&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?s(e.dom)+1:0}}{let e,i=!0;for(;(e=n=r&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=o;for(let t=a;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){i=s(n.dom)+1;break}e-=n.size}-1==i&&(i=0)}if(i>-1&&(l>t||a==this.children.length-1)){t=l;for(let e=a+1;ea&&ot){let e=a;a=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(a.node,a.offset),d.removeAllRanges(),d.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i=n:en){let i=n+r.border,s=o-r.border;if(e>=i&&t<=s){this.dirty=e==n||t==o?2:1,e==i&&t==s&&(r.contentLost||r.dom.parentNode!=this.contentDOM)?r.dirty=3:r.markDirty(e-i,t-i);return}r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=o}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirtyr?r.parent?r.parent.posBeforeChild(r):void 0:i)),!t.type.spec.raw){if(1!=o.nodeType){let e=document.createElement("span");e.appendChild(o),o=e}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class en extends ee{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class ei extends ee{constructor(e,t,n,i,r){super(e,[],n,i),this.mark=t,this.spec=r}static create(e,t,n,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,n);return(!s||!s.dom)&&(s=r.PW.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ei(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty0&&(r=eb(r,0,e,n));for(let e=0;el?l.parent?l.parent.posBeforeChild(l):void 0:s,n,i),c=d&&d.dom,h=d&&d.contentDOM;if(t.isText){if(c){if(3!=c.nodeType)throw RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text)}else if(!c){let e=r.PW.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:h}=e)}!h&&!t.isText&&"BR"!=c.nodeName&&(!c.hasAttribute("contenteditable")&&(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let u=c;return(c=ep(c,n,t),d)?l=new el(e,t,n,i,c,h||null,u,d,o,s+1):t.isText?new es(e,t,n,i,c,u,o):new er(e,t,n,i,c,h||null,u,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM){if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}!e.contentElement&&(e.getContent=()=>r.HY.empty)}else e.contentElement=this.contentDOM}else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ef(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,a=o&&o.pos<0,l=new eg(this,s&&s.node,e);(function(e,t,n,i){let r=t.locals(e),o=0;if(0==r.length){for(let n=0;no;)a.push(r[s++]);let f=o+u.nodeSize;if(u.isText){let e=f;s!e.inline):a.slice();i(u,m,t.forChild(o,u),p),o=f}})(this.node,this.innerDeco,(t,o,s)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!s&&l.syncToMarks(o==this.node.childCount?r.vc.none:this.node.child(o).marks,n,e),l.placeWidget(t,e,i)},(t,r,s,d)=>{let c;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,r,s,d)||a&&e.state.selection.from>i&&e.state.selection.to-1&&l.updateNodeAt(t,r,s,c,e)||l.updateNextNode(t,r,s,e,d,i)||l.addNode(t,r,s,e,i),i+=t.nodeSize}),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),function e(t,n,i){let r=t.firstChild,o=!1;for(let s=0;st+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(!this.node.inlineContent)return{node:o,pos:-1,text:""};{let e=o.nodeValue,i=function(e,t,n,i){for(let r=0,o=0;r=n){if(o>=i&&l.slice(i-t.length-a,i-a)==t)return i-t.length;let e=a=0&&e+t.length+a>=n)return a+e;if(n==i&&l.length>=i+t.length-a&&l.slice(i-a,i-a+t.length)==t)return i}}return -1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let o=new en(this,r,t,i);e.input.compositionNodes.push(o),this.children=eb(this.children,n,n+i.length,e,o)}update(e,t,n,i){return!!(3!=this.dirty&&e.sameMarkup(this.node))&&(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ef(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=eu(this.dom,this.nodeDOM,eh(this.outerDeco,this.node,t),eh(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function eo(e,t,n,i,r){ep(i,t,e);let o=new er(void 0,e,t,n,i,i,i,r,0);return o.contentDOM&&o.updateChildren(r,0),o}class es extends er{constructor(e,t,n,i,r,o,s){super(e,t,n,i,r,null,o,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return!!(3!=this.dirty&&(0==this.dirty||this.inParent())&&e.sameMarkup(this.node))&&(this.updateOuterDeco(t),(0!=this.dirty||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let i=this.node.cut(e,t),r=document.createTextNode(i.text);return new es(this.parent,i,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(0==e||t==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ea extends ee{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class el extends er{constructor(e,t,n,i,r,o,s,a,l,d){super(e,t,n,i,r,o,s,l,d),this.spec=a}update(e,t,n,i){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,i),r}if(!this.contentDOM&&!e.isLeaf)return!1;return super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}let ed=function(e){e&&(this.nodeName=e)};ed.prototype=Object.create(null);let ec=[new ed];function eh(e,t,n){if(0==e.length)return ec;let i=n?ec[0]:new ed,r=[i];for(let o=0;o0;){let a;for(;;)if(i){let e=n.children[i-1];if(e instanceof ei)n=e,i=e.children.length;else{a=e,i--;break}}else if(n==t)break e;else i=n.parent.children.indexOf(n),n=n.parent;let l=a.node;if(!!l){if(l!=e.child(r-1))break;--r,o.set(a,r),s.push(a)}}return{index:r,matched:o,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n>1,o=Math.min(r,e.length);for(;i-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let i=ei.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,i),this.top=i,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,i){let r=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))r=this.top.children.indexOf(o,this.index);else for(let i=this.index,o=Math.min(this.top.children.length,i+5);i=n||c<=t?o.push(l):(dn&&o.push(l.slice(n-d,l.size,i)))}return o}function ey(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),a=o&&0==o.size,l=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let d=r.resolve(l),c,h;if(g(n)){for(c=l;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&i.qv.isSelectable(e)&&o.parent&&!(e.isInline&&function(e,t,n){for(let i=0==t,r=t==f(e);i||r;){if(e==n)return!0;let t=s(e);if(!(e=e.parentNode))return!1;i=i&&0==t,r=r&&t==f(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;h=new i.qv(l==e?d:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=l,i=l;for(let r=0;r{(n.anchorNode!=i||n.anchorOffset!=r)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!ex(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}let e_=D||T&&M<63;function eS(e,t){let{node:n,offset:i}=e.docView.domFromPos(t,0),r=ii(e,t,n))||i.Bs.between(t,n,r)}function eM(e){return(!e.editable||!!e.hasFocus())&&eD(e)}function eD(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function eO(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),s=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return s&&i.Y1.findFrom(s,t)}function eI(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function eN(e,t,n){let r=e.state.selection;if(r instanceof i.Bs){if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return eI(e,new i.Bs(r.$anchor,s))}if(!r.empty)return!1;else if(e.endOfTextblock(t>0?"forward":"backward")){let n=eO(e.state,t);return!!n&&n instanceof i.qv&&eI(e,n)}else if(!(I&&n.indexOf("m")>-1)){let n=r.$head,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,s;if(!o||o.isText)return!1;let a=t<0?n.pos-o.nodeSize:n.pos;return!!(o.isAtom||(s=e.docView.descAt(a))&&!s.contentDOM)&&(i.qv.isSelectable(o)?eI(e,new i.qv(t<0?e.state.doc.resolve(n.pos-o.nodeSize):n)):!!R&&eI(e,new i.Bs(e.state.doc.resolve(t<0?a:a+o.nodeSize))))}}else{if(r instanceof i.qv&&r.node.isInline)return eI(e,new i.Bs(t>0?r.$to:r.$from));let n=eO(e.state,t);return!!n&&eI(e,n)}}function eP(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function eR(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function eL(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,i=t.focusOffset;if(!n)return;let r,o,a=!1;for(E&&1==n.nodeType&&i0){if(1!=n.nodeType)break;{let e=n.childNodes[i-1];if(eR(e,-1))r=n,o=--i;else if(3==e.nodeType)i=(n=e).nodeValue.length;else break}}else if(ej(n))break;else{let t=n.previousSibling;for(;t&&eR(t,-1);)r=n.parentNode,o=s(t),t=t.previousSibling;if(t)i=eP(n=t);else{if((n=n.parentNode)==e.dom)break;i=0}}a?eF(e,n,i):r&&eF(e,r,o)}(e):function(e){let t,n,i=e.domSelectionRange(),r=i.focusNode,o=i.focusOffset;if(!r)return;let a=eP(r);for(;;)if(o{e.state==r&&ew(e)},50)}function eB(e,t){let n=e.state.doc.resolve(t);if(!(T||N)&&n.parent.inlineContent){let i=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>i.top&&r1)return n.lefti.top&&r1)return n.left>i.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function ez(e,t,n){let r=e.state.selection;if(r instanceof i.Bs&&!r.empty||n.indexOf("s")>-1||I&&n.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=eO(e.state,t);if(n&&n instanceof i.qv)return eI(e,n)}if(!o.parent.inlineContent){let n=t<0?o:s,a=r instanceof i.C1?i.Y1.near(n,t):i.Y1.findFrom(n,t);return!!a&&eI(e,a)}return!1}function eH(e,t){if(!(e.state.selection instanceof i.Bs))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let i=e.state.tr;return t<0?i.delete(n.pos-s.nodeSize,n.pos):i.delete(n.pos,n.pos+s.nodeSize),e.dispatch(i),!0}return!1}function eV(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function eU(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:i,openStart:o,openEnd:s}=t;for(;o>1&&s>1&&1==i.childCount&&1==i.firstChild.childCount;){o--,s--;let e=i.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),i=e.content}let a=e.someProp("clipboardSerializer")||r.PW.fromSchema(e.state.schema),l=eX(),d=l.createElement("div");d.appendChild(a.serializeFragment(i,{document:l}));let c=d.firstChild,h,u=0;for(;c&&1==c.nodeType&&(h=eZ[c.nodeName.toLowerCase()]);){for(let e=h.length-1;e>=0;e--){let t=l.createElement(h[e]);for(;d.firstChild;)t.appendChild(d.firstChild);d.appendChild(t),u++}c=d.firstChild}return c&&1==c.nodeType&&c.setAttribute("data-pm-slice",`${o} ${s}${u?` -${u}`:""} ${JSON.stringify(n)}`),{dom:d,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function e$(e,t,n,i,o){let s,a,l=o.parent.type.spec.code;if(!n&&!t)return null;let d=t&&(i||l||!n);if(d){if(e.someProp("transformPastedText",n=>{t=n(t,l||i,e)}),l)return t?new r.p2(r.HY.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0):r.p2.empty;let n=e.someProp("clipboardTextParser",n=>n(t,o,i,e));if(n)a=n;else{let n=o.marks(),{schema:i}=e.state,a=r.PW.fromSchema(i);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(a.serializeNode(i.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),s=function(e){var t;let n,i=/^(\s*]*>)*/.exec(e);i&&(e=e.slice(i[0].length));let r=eX().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(e),s;(s=o&&eZ[o[1].toLowerCase()])&&(e=s.map(e=>"<"+e+">").join("")+e+s.map(e=>"").reverse().join(""));if(r.innerHTML=(t=e,(n=window.trustedTypes)?(!eJ&&(eJ=n.defaultPolicy||n.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),eJ.createHTML(t)):t),s)for(let e=0;e0;e--){let e=s.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;s=e}if(!a&&(a=(e.someProp("clipboardParser")||e.someProp("domParser")||r.aw.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(d||h),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||eW.test(e.parentNode.nodeName)?null:{ignore:!0}})),h)a=function(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,i;try{i=JSON.parse(t)}catch(t){return e}let{content:o,openStart:s,openEnd:a}=e;for(let e=i.length-2;e>=0;e-=2){let t=n.nodes[i[e]];if(!t||t.hasRequiredAttrs())break;o=r.HY.from(t.create(i[e+1],o)),s++,a++}return new r.p2(o,s,a)}(eK(a,+h[1],+h[2]),h[4]);else if((a=r.p2.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let i=t.node(n).contentMatchAt(t.index(n)),o,s=[];if(e.forEach(e=>{if(!s)return;let t=i.findWrapping(e.type),n;if(!t)return s=null;if(n=s.length&&o.length&&function e(t,n,i,o,s){if(s{a=t(a,e)}),a}let eW=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function eq(e,t,n=0){for(let i=t.length-1;i>=n;i--)e=t[i].create(null,r.HY.from(e));return e}function eG(e,t,n,i,o,s){let a=t<0?e.firstChild:e.lastChild,l=a.content;return e.childCount>1&&(s=0),o=n&&(l=t<0?a.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(a.contentMatchAt(a.childCount).fillBefore(r.HY.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,a.copy(l))}function eK(e,t,n){return t{for(let n in t)!e.input.eventHandlers[n]&&e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>e4(e,t))})}function e4(e,t){return e.someProp("handleDOMEvents",n=>{let i=n[t.type];return!!i&&(i(e,t)||t.defaultPrevented)})}function e6(e){return{left:e.clientX,top:e.clientY}}e0.keydown=(e,t)=>{if(e.input.shiftKey=16==t.keyCode||t.shiftKey,!tn(e,t)){if(e.input.lastKeyCode=t.keyCode,e.input.lastKeyCodeTime=Date.now(),!P||!T||13!=t.keyCode){if(229!=t.keyCode&&e.domObserver.forceFlush(),!O||13!=t.keyCode||t.ctrlKey||t.altKey||t.metaKey)e.someProp("handleKeyDown",n=>n(e,t))||function(e,t){var n;let i;let r=t.keyCode,o=(i="",(n=t).ctrlKey&&(i+="c"),n.metaKey&&(i+="m"),n.altKey&&(i+="a"),n.shiftKey&&(i+="s"),i);if(8==r||I&&72==r&&"c"==o)return eH(e,-1)||eL(e,-1);if(46==r&&!t.shiftKey||I&&68==r&&"c"==o)return eH(e,1)||eL(e,1);if(13==r||27==r)return!0;else if(37==r||I&&66==r&&"c"==o){let t=37==r?"ltr"==eB(e,e.state.selection.from)?-1:1:-1;return eN(e,t,o)||eL(e,t)}else if(39==r||I&&70==r&&"c"==o){let t=39==r?"ltr"==eB(e,e.state.selection.from)?1:-1:1;return eN(e,t,o)||eL(e,t)}else if(38==r||I&&80==r&&"c"==o)return ez(e,-1,o)||eL(e,-1);else if(40==r||I&&78==r&&"c"==o)return function(e){if(!D||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;eV(e,n,"true"),setTimeout(()=>eV(e,n,"false"),20)}return!1}(e)||ez(e,1,o)||eL(e,1);else if(o==(I?"m":"c")&&(66==r||73==r||89==r||90==r))return!0;return!1}(e,t)?t.preventDefault():e5(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))),e.input.lastIOSEnter=0)},200)}}}},e0.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},e0.keypress=(e,t)=>{if(tn(e,t)||!t.charCode||t.ctrlKey&&!t.altKey||I&&t.metaKey)return;if(e.someProp("handleKeyPress",n=>n(e,t))){t.preventDefault();return}let n=e.state.selection;if(!(n instanceof i.Bs)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),r=()=>e.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!e.someProp("handleTextInput",t=>t(e,n.$from.pos,n.$to.pos,i,r))&&e.dispatch(r()),t.preventDefault()}};function e8(e,t,n,i,r){if(-1==i)return!1;let o=e.state.doc.resolve(i);for(let i=o.depth+1;i>0;i--)if(e.someProp(t,t=>i>o.depth?t(e,n,o.nodeAfter,o.before(i),r,!0):t(e,n,o.node(i),o.before(i),r,!1)))return!0;return!1}function e7(e,t,n){if(!e.focused&&e.focus(),e.state.selection.eq(t))return;let i=e.state.tr.setSelection(t);"pointer"==n&&i.setMeta("pointer",!0),e.dispatch(i)}function e9(e){return ts(e)}let te=I?"metaKey":"ctrlKey";eQ.mousedown=(e,t)=>{var n,r;let o,s;e.input.shiftKey=t.shiftKey;let a=ts(e),l=Date.now(),d="singleClick";if(l-e.input.lastClick.time<500&&(n=t,o=(r=e.input.lastClick).x-n.clientX,o*o+(s=r.y-n.clientY)*s<100)&&!t[te]&&e.input.lastClick.button==t.button)"singleClick"==e.input.lastClick.type?d="doubleClick":"doubleClick"==e.input.lastClick.type&&(d="tripleClick");e.input.lastClick={time:l,x:t.clientX,y:t.clientY,type:d,button:t.button};let c=e.posAtCoords(e6(t));c&&("singleClick"==d?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new tt(e,c,t,!!a)):("doubleClick"==d?function(e,t,n,i){return e8(e,"handleDoubleClickOn",t,n,i)||e.someProp("handleDoubleClick",n=>n(e,t,i))}:function(e,t,n,r){return e8(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=e.state.doc;if(-1==t)return!!r.inlineContent&&(e7(e,i.Bs.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(t);for(let t=o.depth+1;t>0;t--){let n=t>o.depth?o.nodeAfter:o.node(t),s=o.before(t);if(n.inlineContent)e7(e,i.Bs.create(r,s+1,s+1+n.content.size),"pointer");else{if(!i.qv.isSelectable(n))continue;e7(e,i.qv.create(r,s),"pointer")}return!0}}(e,n,r)})(e,c.pos,c.inside,t)?t.preventDefault():e5(e,"pointer"))};class tt{constructor(e,t,n,r){let o,s;if(this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[te],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,s=n.depth?n.before():0}let a=r?null:n.target,l=a?e.docView.nearestDesc(a,!0):null;this.target=l&&1==l.dom.nodeType?l.dom:null;let{selection:d}=e.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||d instanceof i.qv&&d.from<=s&&d.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&E&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),e5(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ew(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;if(this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(e6(e))),this.updateAllowDefault(e),this.allowDefault||!t)e5(this.view,"pointer");else{var n,r,o,s,a;if(n=this.view,r=t.pos,o=t.inside,s=e,a=this.selectNode,e8(n,"handleClickOn",r,o,s)||n.someProp("handleClick",e=>e(n,r,s))||(a?function(e,t){if(-1==t)return!1;let n=e.state.selection,r,o;n instanceof i.qv&&(r=n.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(i.qv.isSelectable(t)){o=r&&n.$from.depth>0&&e>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?s.before(n.$from.depth):s.before(e);break}}return null!=o&&(e7(e,i.qv.create(e.state.doc,o),"pointer"),!0)}(n,o):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&i.qv.isSelectable(r))&&(e7(e,new i.qv(n),"pointer"),!0)}(n,o)))e.preventDefault();else 0==e.button&&(this.flushed||D&&this.mightDrag&&!this.mightDrag.node.isAtom||T&&!this.view.state.selection.visible&&2>=Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to)))?(e7(this.view,i.Y1.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):e5(this.view,"pointer")}}move(e){this.updateAllowDefault(e),e5(this.view,"pointer"),0==e.buttons&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}function tn(e,t){return!!e.composing||!!(D&&500>Math.abs(t.timeStamp-e.input.compositionEndedAt))&&(e.input.compositionEndedAt=-2e8,!0)}eQ.touchstart=e=>{e.input.lastTouch=Date.now(),ts(e),e5(e,"pointer")},eQ.touchmove=e=>{e.input.lastTouch=Date.now(),e5(e,"pointer")},eQ.contextmenu=e=>ts(e);let ti=P?5e3:-1;function tr(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>ts(e),t))}function to(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}e0.compositionstart=e0.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof i.Bs&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)))e.markCursor=e.state.storedMarks||n.marks(),ts(e,!0),e.markCursor=null;else if(ts(e,!t.selection.empty),E&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,i=t.focusOffset;n&&1==n.nodeType&&0!=i;){let t=i<0?n.lastChild:n.childNodes[i-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,i=-1}}e.input.composing=!0}tr(e,ti)},e0.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,tr(e,20))};function ts(e,t=!1){if(!P||!(e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),to(e),t||e.docView&&e.docView.dirty){let n=ey(e),i=e.state.selection;return n&&!n.eq(i)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!i.$from.node(i.$from.sharedDepth(i.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}let ta=C&&A<15||O&&L<604;eQ.copy=e0.cut=(e,t)=>{let n=e.state.selection,i="cut"==t.type;if(n.empty)return;let r=ta?null:t.clipboardData,{dom:o,text:s}=eU(e,n.content());r?(t.preventDefault(),r.clearData(),r.setData("text/html",o.innerHTML),r.setData("text/plain",s)):!function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let i=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),i.removeAllRanges(),i.addRange(r),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tl(e,t,n,i,o){var s;let a=e$(e,t,n,i,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,a||r.p2.empty)))return!0;if(!a)return!1;let l=0==(s=a).openStart&&0==s.openEnd&&1==s.content.childCount?s.content.firstChild:null,d=l?e.state.tr.replaceSelectionWith(l,i):e.state.tr.replaceSelection(a);return e.dispatch(d.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function td(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}e0.paste=(e,t)=>{if(e.composing&&!P)return;let n=ta?null:t.clipboardData,i=e.input.shiftKey&&45!=e.input.lastKeyCode;n&&tl(e,td(n),n.getData("text/html"),i,t)?t.preventDefault():!function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,i=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));!n&&(i.contentEditable="true"),i.style.cssText="position: fixed; left: -10000px; top: 10px",i.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),i.parentNode&&i.parentNode.removeChild(i),n?tl(e,i.value,null,r,t):tl(e,i.textContent,i.innerHTML,r,t)},50)}(e,t)};class tc{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}let th=I?"altKey":"ctrlKey";function tu(e,t){let n=e.someProp("dragCopies",e=>!e(t));return null!=n?n:!t[th]}for(let e in eQ.dragstart=(e,t)=>{let n;let r=e.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=e.state.selection,s=o.empty?null:e.posAtCoords(e6(t));if(s&&s.pos>=o.from&&s.pos<=(o instanceof i.qv?o.to-1:o.to));else if(r&&r.mightDrag)n=i.qv.create(e.state.doc,r.mightDrag.pos);else if(t.target&&1==t.target.nodeType){let r=e.docView.nearestDesc(t.target,!0);r&&r.node.type.spec.draggable&&r!=e.docView&&(n=i.qv.create(e.state.doc,r.posBefore))}let a=(n||e.state.selection).content(),{dom:l,text:d,slice:c}=eU(e,a);(!t.dataTransfer.files.length||!T||M>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(ta?"Text":"text/html",l.innerHTML),t.dataTransfer.effectAllowed="copyMove",!ta&&t.dataTransfer.setData("text/plain",d),e.dragging=new tc(c,tu(e,t),n)},eQ.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},e0.dragover=e0.dragenter=(e,t)=>t.preventDefault(),e0.drop=(e,t)=>{let n=e.dragging;if(e.dragging=null,!t.dataTransfer)return;let s=e.posAtCoords(e6(t));if(!s)return;let a=e.state.doc.resolve(s.pos),l=n&&n.slice;l?e.someProp("transformPasted",t=>{l=t(l,e)}):l=e$(e,td(t.dataTransfer),ta?null:t.dataTransfer.getData("text/html"),!1,a);let d=!!(n&&tu(e,t));if(e.someProp("handleDrop",n=>n(e,t,l||r.p2.empty,d))){t.preventDefault();return}if(!l)return;t.preventDefault();let c=l?(0,o.nj)(e.state.doc,a.pos,l):a.pos;null==c&&(c=a.pos);let h=e.state.tr;if(d){let{node:e}=n;e?e.replace(h):h.deleteSelection()}let u=h.mapping.map(c),p=0==l.openStart&&0==l.openEnd&&1==l.content.childCount,f=h.doc;if(p?h.replaceRangeWith(u,u,l.content.firstChild):h.replaceRange(u,u,l),h.doc.eq(f))return;let m=h.doc.resolve(u);if(p&&i.qv.isSelectable(l.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(l.content.firstChild))h.setSelection(new i.qv(m));else{let t=h.mapping.map(c);h.mapping.maps[h.mapping.maps.length-1].forEach((e,n,i,r)=>t=r),h.setSelection(eT(e,m,h.doc.resolve(t)))}e.focus(),e.dispatch(h.setMeta("uiEvent","drop"))},eQ.focus=e=>{e.input.lastFocus=Date.now(),!e.focused&&(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&ew(e)},20))},eQ.blur=(e,t)=>{e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),t.relatedTarget&&e.dom.contains(t.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},eQ.beforeinput=(e,t)=>{if(T&&P&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,v(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}},e0)eQ[e]=e0[e];function tp(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class tf{constructor(e,t){this.toDOM=e,this.spec=t||ty,this.side=this.spec.side||0}map(e,t,n,i){let{pos:r,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new tv(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof tf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&tp(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class tm{constructor(e,t){this.attrs=e,this.spec=t||ty}map(e,t,n,i){let r=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return r>=o?null:new tv(r,o,this)}valid(e,t){return t.from=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+i,s.to+i))}for(let o=0;oe){let s=this.children[o]+1;this.children[o+2].findInner(e-s,t-s,n,i+s,r)}}map(e,t,n){return this==tw||0==e.maps.length?this:this.mapInner(e,t,0,0,n||ty)}mapInner(e,t,n,i,r){let o;for(let s=0;s{let s=o-r-(n-e);for(let r=0;ro+t-i)continue;let l=a[r]+t-i;n>=l?a[r+1]=e<=l?-2:-1:e>=t&&s&&(a[r]+=s,a[r+1]+=s)}i+=s}),t=n.maps[e].map(t,-1)}let l=!1;for(let t=0;t=i.content.size){l=!0;continue}let h=n.map(e[t+1]+o,-1)-r,{index:u,offset:p}=i.content.findIndex(c),f=i.maybeChild(u);if(f&&p==c&&p+f.nodeSize==h){let i=a[t+2].mapInner(n,f,d+1,e[t]+o+1,s);i!=tw?(a[t]=c,a[t+1]=h,a[t+2]=i):(a[t+1]=-2,l=!0)}else l=!0}if(l){let l=tE(function(e,t,n,i,r,o,s){for(let a=0;a{let s=o+n,a;if(a=tC(t,e,s)){for(!i&&(i=this.children.slice());ro&&n.to=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,o=r+t.content.size;for(let e=0;er&&t.type instanceof tm){let e=Math.max(r,t.from)-r,n=Math.min(o,t.to)-r;en.map(e,t,ty));return t_.from(n)}forChild(e,t){if(t.isLeaf)return tx.empty;let n=[];for(let i=0;ie instanceof tx)?e:e.reduce((e,t)=>e.concat(t instanceof tx?t:t.members),[]))}}forEachSet(e){for(let t=0;tn&&o.to{let a=tC(e,t,s+n);if(a){o=!0;let e=tE(a,t,n+s+1,i);e!=tw&&r.push(s,s+t.nodeSize,e)}});let s=tS(o?tA(e):e,-n).sort(tk);for(let e=0;e0;)t++;e.splice(t,0,n)}function tD(e){let t=[];return e.someProp("decorations",n=>{let i=n(e.state);i&&i!=tw&&t.push(i)}),e.cursorWrapper&&t.push(tx.create(e.state.doc,[e.cursorWrapper.deco])),t_.from(t)}let tO={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},tI=C&&A<=11;class tN{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class tP{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new tN,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(e=>{for(let t=0;t"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():this.flush()}),tI&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,tO)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;tthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(eM(this.view)){if(this.suppressingSelectionUpdates)return ew(this.view);if(C&&A<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&h(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=a(n))t.add(n);for(let i=e.anchorNode;i;i=a(i))if(t.has(i)){n=i;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:3==n.nodeType?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&eM(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,a=!1,l=[];if(e.editable)for(let e=0;e"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let i of t){let t=i.parentNode;t&&"LI"==t.nodeName&&(!n||function(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}(e,n)!=t)&&i.remove()}}}let d=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||r)&&(o>-1&&(e.docView.markDirty(o,s),function(e){if(!tR.has(e)&&(tR.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=E,!tL)console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),tL=!0}}(e)),this.handleDOMChange(o,s,a,l),e.docView&&e.docView.dirty?e.updateState(e.state):!this.currentSelection.eq(n)&&ew(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;nArray.prototype.indexOf.call(e.addedNodes,n))&&(i=n),(!o||0>Array.prototype.indexOf.call(e.addedNodes,o))&&(r=o)}let o=i&&i.parentNode==e.target?s(i)+1:0,a=n.localPosFromDOM(e.target,o,-1),l=r&&r.parentNode==e.target?s(r):e.target.childNodes.length;return{from:a,to:n.localPosFromDOM(e.target,l,1)}}if("attributes"==e.type)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let tR=new WeakMap,tL=!1;function tj(e,t){let n=t.startContainer,i=t.startOffset,r=t.endContainer,o=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return h(s.node,s.offset,r,o)&&([n,i,r,o]=[r,o,n,i]),{anchorNode:n,anchorOffset:i,focusNode:r,focusOffset:o}}function tF(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(D&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||D&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}let tB=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function tz(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:eT(e,t.resolve(n.anchor),t.resolve(n.head))}function tH(e,t,n){let i=e.depth,r=t?e.end():e.pos;for(;i>0&&(t||e.indexAfter(i)==e.node(i).childCount);)i--,r++,t=!1;if(n){let t=e.node(i).maybeChild(e.indexAfter(i));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function tV(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}class tU{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new e2,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(tK),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=tq(this),tW(this),this.nodeViews=tG(this),this.docView=eo(this.state.doc,t$(this),tD(this),this.dom,this),this.domObserver=new tP(this,(e,t,n,o)=>(function(e,t,n,o,s){let a,l,d,c,h=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ey(e,t);if(n&&!e.state.selection.eq(n)){if(T&&P&&13===e.input.lastKeyCode&&Date.now()-100t(e,v(13,"Enter"))))return;let i=e.state.tr.setSelection(n);"pointer"==t?i.setMeta("pointer",!0):"key"==t&&i.scrollIntoView(),h&&i.setMeta("composition",h),e.dispatch(i)}return}let u=e.state.doc.resolve(t),p=u.sharedDepth(n);t=u.before(p+1),n=e.state.doc.resolve(n).after(p+1);let f=e.state.selection,m=function(e,t,n){let i,{node:o,fromOffset:s,toOffset:a,from:l,to:d}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h=c.anchorNode;if(h&&e.dom.contains(1==h.nodeType?h:h.parentNode)&&(i=[{node:h,offset:c.anchorOffset}],!g(c)&&i.push({node:c.focusNode,offset:c.focusOffset})),T&&8===e.input.lastKeyCode)for(let e=a;e>s;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){a=e;break}if(!n||n.size)break}let u=e.state.doc,p=e.someProp("domParser")||r.aw.fromSchema(e.state.schema),f=u.resolve(l),m=null,v=p.parse(o,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:a,preserveWhitespace:"pre"!=f.parent.type.whitespace||"full",findPositions:i,ruleFromNode:tF,context:f});if(i&&null!=i[0].pos){let e=i[0].pos,t=i[1]&&i[1].pos;null==t&&(t=e),m={anchor:e+l,head:t+l}}return{doc:v,sel:m,from:l,to:d}}(e,t,n),b=e.state.doc,y=b.slice(m.from,m.to);8===e.input.lastKeyCode&&Date.now()-100=s?o-i:0;(o-=e)&&o=a?o-i:0;(o-=t)&&oDate.now()-225||P)&&s.some(e=>1==e.nodeType&&!tB.test(e.nodeName))&&(!x||x.endA>=x.endB)&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!x){if(o&&f instanceof i.Bs&&!f.empty&&f.$head.sameParent(f.$anchor)&&!e.composing&&!(m.sel&&m.sel.anchor!=m.sel.head))x={start:f.from,endA:f.to,endB:f.to};else{if(m.sel){let t=tz(e,e.state.doc,m.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);h&&n.setMeta("composition",h),e.dispatch(n)}}return}}e.state.selection.frome.state.selection.from&&x.start<=e.state.selection.from+2&&e.state.selection.from>=m.from?x.start=e.state.selection.from:x.endA=e.state.selection.to-2&&e.state.selection.to<=m.to&&(x.endB+=e.state.selection.to-x.endA,x.endA=e.state.selection.to)),C&&A<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>m.from&&" \xa0"==m.doc.textBetween(x.start-m.from-1,x.start-m.from+1)&&(x.start--,x.endA--,x.endB--);let w=m.doc.resolveNoCache(x.start-m.from),_=m.doc.resolveNoCache(x.endB-m.from),S=b.resolve(x.start),E=w.sameParent(_)&&w.parent.inlineContent&&S.end()>=x.endA;if((O&&e.input.lastIOSEnter>Date.now()-225&&(!E||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!E&&w.posw.pos)&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>x.start&&function(e,t,n,i,r){if(n-t<=r.pos-i.pos||tH(i,!0,!1)n||tH(s,!0,!1)t(e,v(8,"Backspace")))){P&&T&&e.domObserver.suppressSelectionUpdates();return}T&&x.endB==x.start&&(e.input.lastChromeDelete=Date.now()),P&&!E&&w.start()!=_.start()&&0==_.parentOffset&&w.depth==_.depth&&m.sel&&m.sel.anchor==m.sel.head&&m.sel.head==x.endA&&(x.endB-=2,_=m.doc.resolveNoCache(x.endB-m.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,v(13,"Enter"))})},20));let k=x.start,M=x.endA,D=t=>{let n=t||e.state.tr.replace(k,M,m.doc.slice(x.start-m.from,x.endB-m.from));if(m.sel){let t=tz(e,n.doc,m.sel);t&&!(T&&e.composing&&t.empty&&(x.start!=x.endB||e.input.lastChromeDeleteew(e),20));let t=D(e.state.tr.delete(k,M)),n=b.resolve(x.start).marksAcross(b.resolve(x.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(x.endA==x.endB&&(c=function(e,t){let n=e.firstChild.marks,i=t.firstChild.marks,o=n,s=i,a,l,d;for(let e=0;ee.mark(l.addToSet(e.marks));else{if(0!=o.length||1!=s.length)return null;l=s[0],a="remove",d=e=>e.mark(l.removeFromSet(e.marks))}let c=[];for(let e=0;eD(e.state.tr.insertText(t,k,M));!e.someProp("handleTextInput",i=>i(e,k,M,t,n))&&e.dispatch(n())}}else e.dispatch(D())})(this,e,t,n,o)),this.domObserver.start(),!function(e){for(let t in eQ){let n=eQ[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{(function(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0})(e,t)&&!e4(e,t)&&(e.editable||!(t.type in e0))&&n(e,t)},e1[t]?{passive:!0}:void 0)}D&&e.dom.addEventListener("input",()=>null),e3(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;for(let t in this._props={},e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&e3(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tK),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];for(let n in t.state=this.state,e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n,i;let r=this.state,o=!1,a=!1;e.storedMarks&&this.composing&&(to(this),a=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=tG(this);(function(e,t){let n=0,i=0;for(let i in e){if(e[i]!=t[i])return!0;n++}for(let e in t)i++;return n!=i})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&e3(this),this.editable=tq(this),tW(this);let d=tD(this),c=t$(this),u=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",p=o||!this.docView.matchesNode(e.doc,c,d);(p||!e.selection.eq(r.selection))&&(a=!0);let g="preserve"==u&&a&&null==this.dom.style.overflowAnchor&&function(e){let t,n,i=e.dom.getBoundingClientRect(),r=Math.max(0,i.top);for(let o=(i.left+i.right)/2,s=r+1;s=r-20){t=i,n=a.top;break}}return{refDOM:t,refTop:n,stack:B(e.dom)}}(this);if(a){;let t,n;this.domObserver.stop();let a=p&&(C||T)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(p){let t=T?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=f(e=e.childNodes[t-1])}else{if(!e.parentNode||m(e))return null;t=s(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),i=function(e,t){for(;;){if(3==e.nodeType&&te(this)));else if(this.state.selection instanceof i.qv){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&F(this,t.getBoundingClientRect(),e)}else F(this,this.coordsAtPos(this.state.selection.head,1),e)}else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new tc(e.slice,e.move,r<0?void 0:i.qv.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],i;if(null!=n&&(i=t?t(n):n))return i;for(let n=0;ne.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return function(e,t){var n,i;let r,o,s=e.dom.ownerDocument,l,c=0,h=function(e,t,n){if(e.caretPositionFromPoint)try{let i=e.caretPositionFromPoint(t,n);if(i)return{node:i.offsetNode,offset:Math.min(f(i.offsetNode),i.offset)}}catch(e){}if(e.caretRangeFromPoint){let i=e.caretRangeFromPoint(t,n);if(i)return{node:i.startContainer,offset:Math.min(f(i.startContainer),i.startOffset)}}}(s,t.left,t.top);h&&({node:l,offset:c}=h);let u=(e.root.elementFromPoint?e.root:s).elementFromPoint(t.left,t.top);if(!u||!e.dom.contains(1!=u.nodeType?u.parentNode:u)){let n=e.dom.getBoundingClientRect();if(!V(t,n)||!(u=function e(t,n,i){let r=t.childNodes.length;if(r&&i.topt.top&&c++}R&&c&&1==l.nodeType&&1==(n=l.childNodes[c-1]).nodeType&&"false"==n.contentEditable&&n.getBoundingClientRect().top>=t.top&&c--,l==e.dom&&c==l.childNodes.length-1&&1==l.lastChild.nodeType&&t.top>l.lastChild.getBoundingClientRect().bottom?o=e.state.doc.content.size:(0==c||1!=l.nodeType||"BR"!=l.childNodes[c-1].nodeName)&&(o=function(e,t,n,i){let r=-1;for(let n=t,o=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),s;if(!t)return null;if(1==t.dom.nodeType&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((s=t.dom.getBoundingClientRect()).width||s.height)&&(t.node.isBlock&&t.parent&&(!o&&s.left>i.left||s.top>i.top?r=t.posBefore:(!o&&s.right-1?r:e.docView.posFromDOM(t,n,-1)}(e,l,c,t))}null==o&&(o=function(e,t,n){let{node:i,offset:r}=function e(t,n){let i,r,o,s=2e8,a,l=0,c=n.top,h=n.top;for(let e=t.firstChild,u=0;e;e=e.nextSibling,u++){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=d(e).getClientRects()}for(let d=0;d=h){c=Math.max(p.bottom,c),h=Math.min(p.top,h);let t=p.left>n.left?p.left-n.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>n.top&&!i&&p.left<=n.left&&p.right>=n.left&&(i=e,r={left:Math.max(p.left,Math.min(p.right,n.left)),top:p.top});!o&&(n.left>=p.right&&n.top>=p.top||n.left>=p.left&&n.top>=p.bottom)&&(l=u+1)}}return(!o&&i&&(o=i,a=r,s=0),o&&3==o.nodeType)?function(e,t){let n=e.nodeValue.length,i=document.createRange();for(let r=0;r=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(o,a):!o||s&&1==o.nodeType?{node:t,offset:l}:e(o,a)}(t,n),o=-1;if(1==i.nodeType&&!i.firstChild){let e=i.getBoundingClientRect();o=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(i,r,o)}(e,u,t));let p=e.docView.nearestDesc(u,!0);return{pos:o,inside:p?p.posAtStart-p.border:-1}}(this,e)}coordsAtPos(e,t=1){return q(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(null==i)throw RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return function(e,t,n){var i,r,o;let s,a;if(X==t&&J==n)return Q;X=t,J=n;return Q="up"==n||"down"==n?(i=e,r=t,o=n,s=r.selection,a="up"==o?s.$from:s.$to,Z(i,r,()=>{let{node:e}=i.docView.domFromPos(a.pos,"up"==o?-1:1);for(;;){let t=i.docView.nearestDesc(e,!0);if(!t)break;if(t.node.isBlock){e=t.contentDOM||t.dom;break}e=t.dom.parentNode}let t=q(i,a.pos,1);for(let n=e.firstChild;n;n=n.nextSibling){let e;if(1==n.nodeType)e=n.getClientRects();else{if(3!=n.nodeType)continue;e=d(n,0,n.nodeValue.length).getClientRects()}for(let n=0;ni.top+1&&("up"==o?t.top-i.top>(i.bottom-t.top)*2:i.bottom-t.bottom>(t.bottom-i.top)*2))return!1}}return!0})):function(e,t,n){let{$head:i}=t.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,o=r==i.parent.content.size,s=e.domSelection();return s?Y.test(i.parent.textContent)&&s.modify?Z(e,t,()=>{let{focusNode:t,focusOffset:r,anchorNode:o,anchorOffset:a}=e.domSelectionRange(),l=s.caretBidiLevel;s.modify("move",n,"character");let d=i.depth?e.docView.domAfterPos(i.before()):e.dom,{focusNode:c,focusOffset:h}=e.domSelectionRange(),u=c&&!d.contains(1==c.nodeType?c:c.parentNode)||t==c&&r==h;try{s.collapse(o,a),t&&(t!=o||r!=a)&&s.extend&&s.extend(t,r)}catch(e){}return null!=l&&(s.caretBidiLevel=l),u}):"left"==n||"backward"==n?!r:o:i.pos==i.start()||i.pos==i.end()}(e,t,n)}(this,t||this.state,e)}pasteHTML(e,t){return tl(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return tl(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return eU(this,e)}destroy(){this.docView&&(!function(e){for(let t in e.domObserver.stop(),e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],tD(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,c())}get isDestroyed(){return null==this.docView}dispatchEvent(e){var t,n;return t=this,void(!e4(t,n=e)&&eQ[n.type]&&(t.editable||!(n.type in e0))&&eQ[n.type](t,n))}domSelectionRange(){let e=this.domSelection();return e?D&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){let n;if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return tj(e,n)}function i(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",i,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",i,!0),n?tj(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function t$(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:!t[e]&&"contenteditable"!=e&&"nodeName"!=e&&(t[e]=String(n[e]))}),!t.translate&&(t.translate="no"),[tv.node(0,e.state.doc.content.size,t)]}function tW(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:tv.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function tq(e){return!e.someProp("editable",t=>!1===t(e.state))}tU.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function tG(e){let t=Object.create(null);function n(e){for(let n in e)!Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function tK(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError("Plugins passed directly to the view must not have a state component")}},90265:function(e,t,n){n.d(t,{Z:()=>_});var i=n("151064"),r=n("455069"),o=n("213898"),s=n("59160"),a=n("711281"),l=n("642844"),d=n("733216"),c=n("734083"),h=n("262941"),u=n("647405"),p=n("856667");class f{constructor(){this.externalLinkEnabled=!0,this.externalLinkRel=void 0,this.externalLinkTarget=void 0,this.isInPresentationMode=!1,this.pdfDocument=void 0,this.pdfViewer=void 0}setDocument(e){this.pdfDocument=e}setViewer(e){this.pdfViewer=e}setExternalLinkRel(e){this.externalLinkRel=e}setExternalLinkTarget(e){this.externalLinkTarget=e}setHistory(){}get pagesCount(){return this.pdfDocument?this.pdfDocument.numPages:0}get page(){return(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber||0}set page(e){(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),this.pdfViewer.currentPageNumber=e}get rotation(){return 0}set rotation(e){}goToDestination(e){return new Promise(t=>{(0,l.Z)(this.pdfDocument,"PDF document not loaded."),(0,l.Z)(e,"Destination is not specified."),"string"==typeof e?this.pdfDocument.getDestination(e).then(t):Array.isArray(e)?t(e):e.then(t)}).then(e=>{(0,l.Z)(Array.isArray(e),`"${e}" is not a valid destination array.`);let t=e[0];new Promise(e=>{(0,l.Z)(this.pdfDocument,"PDF document not loaded."),t instanceof Object?this.pdfDocument.getPageIndex(t).then(t=>{e(t)}).catch(()=>{(0,l.Z)(!1,`"${t}" is not a valid page reference.`)}):"number"==typeof t?e(t):(0,l.Z)(!1,`"${t}" is not a valid destination reference.`)}).then(t=>{let n=t+1;(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),(0,l.Z)(n>=1&&n<=this.pagesCount,`"${n}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({dest:e,pageIndex:t,pageNumber:n})})})}navigateTo(e){this.goToDestination(e)}goToPage(e){(0,l.Z)(this.pdfViewer,"PDF viewer is not initialized."),(0,l.Z)(e>=1&&e<=this.pagesCount,`"${e}" is not a valid page number.`),this.pdfViewer.scrollPageIntoView({pageIndex:e-1,pageNumber:e})}addLinkAttributes(e,t,n){e.href=t,e.rel=this.externalLinkRel||"noopener noreferrer nofollow",e.target=n?"_blank":this.externalLinkTarget||""}getDestinationHash(){return"#"}getAnchorUrl(){return"#"}setHash(){}executeNamedAction(){}cachePageRef(){}isPageVisible(){return!0}isPageCached(){return!0}executeSetOCGState(){}}var m={NEED_PASSWORD:1,INCORRECT_PASSWORD:2},g=n("411757"),v=n("71331"),b=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);rt.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};let{PDFDataRangeTransport:y}=h,x=(e,t)=>{switch(t){case m.NEED_PASSWORD:e(prompt("Enter the password to open this PDF file."));break;case m.INCORRECT_PASSWORD:e(prompt("Invalid password. Please try again."))}};function w(e){return"object"==typeof e&&null!==e&&("data"in e||"range"in e||"url"in e)}var _=(0,r.forwardRef)(function(e,t){var{children:n,className:m,error:_="Failed to load PDF file.",externalLinkRel:S,externalLinkTarget:C,file:A,inputRef:E,imageResourcesPath:k,loading:T="Loading PDF…",noData:M="No PDF file specified.",onItemClick:D,onLoadError:O,onLoadProgress:I,onLoadSuccess:N,onPassword:P=x,onSourceError:R,onSourceSuccess:L,options:j,renderMode:F,rotate:B}=e,z=b(e,["children","className","error","externalLinkRel","externalLinkTarget","file","inputRef","imageResourcesPath","loading","noData","onItemClick","onLoadError","onLoadProgress","onLoadSuccess","onPassword","onSourceError","onSourceSuccess","options","renderMode","rotate"]);let[H,V]=(0,v.Z)(),{value:U,error:$}=H,[W,q]=(0,v.Z)(),{value:G,error:K}=W,Z=(0,r.useRef)(new f),Y=(0,r.useRef)([]),X=(0,r.useRef)(void 0),J=(0,r.useRef)(void 0);A&&A!==X.current&&w(A)&&(d(!(0,c.J)(A,X.current),'File prop passed to changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "file" prop.'),X.current=A),j&&j!==J.current&&(d(!(0,c.J)(j,J.current),'Options prop passed to changed, but it\'s equal to previous one. This might result in unnecessary reloads. Consider memoizing the value passed to "options" prop.'),J.current=j);let Q=(0,r.useRef)({scrollPageIntoView:e=>{let{dest:t,pageNumber:n,pageIndex:i=n-1}=e;if(D){D({dest:t,pageIndex:i,pageNumber:n});return}let r=Y.current[i];if(r){r.scrollIntoView();return}d(!1,`An internal link leading to page ${n} was clicked, but neither was provided with onItemClick nor it was able to find the page within itself. Either provide onItemClick to and handle navigating by yourself or ensure that all pages are rendered within .`)}});(0,r.useImperativeHandle)(t,()=>({linkService:Z,pages:Y,viewer:Q}),[]);(0,r.useEffect)(function(){V({type:"RESET"})},[A,V]);let ee=(0,r.useCallback)(()=>{var e,t,n,i;return e=this,t=void 0,n=void 0,i=function*(){if(!A)return null;if("string"==typeof A)return(0,g.gJ)(A)?{data:(0,g.us)(A)}:((0,g.tN)(),{url:A});if(A instanceof y)return{range:A};if((0,g.eP)(A))return{data:A};if(g.jU&&(0,g.Lj)(A))return{data:yield(0,g.eR)(A)};if((0,l.Z)("object"==typeof A,"Invalid parameter in file, need either Uint8Array, string or a parameter object"),(0,l.Z)(w(A),"Invalid parameter object: need either .data, .range or .url"),"url"in A&&"string"==typeof A.url){if((0,g.gJ)(A.url)){let{url:e}=A,t=b(A,["url"]);return Object.assign({data:(0,g.us)(e)},t)}(0,g.tN)()}return A},new(n||(n=Promise))(function(r,o){function s(e){try{l(i.next(e))}catch(e){o(e)}}function a(e){try{l(i.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):((t=e.value)instanceof n?t:new n(function(e){e(t)})).then(s,a)}l((i=i.apply(e,t||[])).next())})},[A]);(0,r.useEffect)(()=>{let e=(0,s.Z)(ee());return e.promise.then(e=>{V({type:"RESOLVE",value:e})}).catch(e=>{V({type:"REJECT",error:e})}),()=>{(0,g.LJ)(e)}},[ee,V]),(0,r.useEffect)(()=>{if(void 0!==U){if(!1===U){!function(){if(!!$)d(!1,$.toString()),R&&R($)}();return}L&&L()}},[U]);(0,r.useEffect)(function(){q({type:"RESET"})},[q,U]),(0,r.useEffect)(function(){if(!U)return;let e=j?Object.assign(Object.assign({},U),j):U,t=h.getDocument(e);I&&(t.onProgress=I),P&&(t.onPassword=P);let n=t.promise.then(e=>{q({type:"RESOLVE",value:e})}).catch(e=>{if(!t.destroyed)q({type:"REJECT",error:e})});return()=>{n.finally(()=>t.destroy())}},[j,q,U]),(0,r.useEffect)(()=>{if(void 0!==G){if(!1===G){!function(){if(!!K)d(!1,K.toString()),O&&O(K)}();return}!function(){if(!!G)N&&N(G),Y.current=Array(G.numPages),Z.current.setDocument(G)}()}},[G]),(0,r.useEffect)(function(){Z.current.setViewer(Q.current),Z.current.setExternalLinkRel(S),Z.current.setExternalLinkTarget(C)},[S,C]);let et=(0,r.useCallback)((e,t)=>{Y.current[e]=t},[]),en=(0,r.useCallback)(e=>{delete Y.current[e]},[]),ei=(0,r.useMemo)(()=>({imageResourcesPath:k,linkService:Z.current,onItemClick:D,pdf:G,registerPage:et,renderMode:F,rotate:B,unregisterPage:en}),[k,D,G,et,F,B,en]),er=(0,r.useMemo)(()=>(0,o.ZP)(z,()=>G),[z,G]);return(0,i.jsx)("div",Object.assign({className:(0,a.Z)("react-pdf__Document",m),ref:E,style:{"--scale-factor":"1"}},er,{children:A?null==G?(0,i.jsx)(p.Z,{type:"loading",children:"function"==typeof T?T():T}):!1===G?(0,i.jsx)(p.Z,{type:"error",children:"function"==typeof _?_():_}):(0,i.jsx)(u.Z.Provider,{value:ei,children:n}):(0,i.jsx)(p.Z,{type:"no-data",children:"function"==typeof M?M():M})}))})},647405:function(e,t,n){let i=(0,n(455069).createContext)(null);t.Z=i},856667:function(e,t,n){n.d(t,{Z:function(){return r}});var i=n(151064);function r({children:e,type:t}){return(0,i.jsx)("div",{className:`react-pdf__message react-pdf__message--${t}`,children:e})}},876945:function(e,t,n){n.d(t,{Z:()=>D});var i=n("151064"),r=n("455069"),o=n("59160"),s=n("213898"),a=n("711281");function l(){for(var e=[],t=0;t{var e;return(e=t)?Object.assign(Object.assign({},function(e){let t={};if(g(e)){let{role:n}=e,i=n.match(m);if(i)t.role="heading",t["aria-level"]=Number(i[1]);else if(n in f){let e=f[n];e&&(t.role=e)}}return t}(e)),function e(t){let n={};if(g(t)){if(void 0!==t.alt&&(n["aria-label"]=t.alt),void 0!==t.lang&&(n.lang=t.lang),v(t)){let[i]=t.children;if(i){let t=e(i);return Object.assign(Object.assign({},n),t)}}}else"id"in t&&(n["aria-owns"]=t.id);return n}(e)):null},[t]),o=(0,r.useMemo)(()=>!g(t)||v(t)?null:t.children.map((e,t)=>(0,i.jsx)(b,{node:e},t)),[t]);return(0,i.jsx)("span",Object.assign({className:e},n,{children:o}))}function y(){return(0,r.useContext)(h)}var x=n("71331"),w=n("411757");function _(){let e=y();(0,d.Z)(e,"Unable to find Page context.");let{onGetStructTreeError:t,onGetStructTreeSuccess:n}=e,[s,a]=(0,x.Z)(),{value:l,error:h}=s,{customTextRenderer:u,page:p}=e;return((0,r.useEffect)(function(){a({type:"RESET"})},[a,p]),(0,r.useEffect)(function(){if(u||!p)return;let e=(0,o.Z)(p.getStructTree());return e.promise.then(e=>{a({type:"RESOLVE",value:e})}).catch(e=>{a({type:"REJECT",error:e})}),()=>(0,w.LJ)(e)},[u,p,a]),(0,r.useEffect)(()=>{if(void 0!==l){if(!1===l){!function(){if(!!h)c(!1,h.toString()),t&&t(h)}();return}!function(){if(!!l)n&&n(l)}()}},[l]),l)?(0,i.jsx)(b,{className:"react-pdf__Page__structTree structTree",node:l}):null}let S=p.AnnotationMode;function C(e){let t=y();(0,d.Z)(t,"Unable to find Page context.");let{_className:n,canvasBackground:o,devicePixelRatio:s=(0,w.x_)(),onRenderError:a,onRenderSuccess:h,page:u,renderForms:p,renderTextLayer:f,rotate:m,scale:g}=Object.assign(Object.assign({},t),e),{canvasRef:v}=e;(0,d.Z)(u,"Attempted to render page canvas, but no page was specified.");let b=(0,r.useRef)(null);function x(e){if(!(0,w.DE)(e))c(!1,e.toString()),a&&a(e)}let C=(0,r.useMemo)(()=>u.getViewport({scale:g*s,rotation:m}),[s,u,m,g]),A=(0,r.useMemo)(()=>u.getViewport({scale:g,rotation:m}),[u,m,g]);(0,r.useEffect)(function(){if(!u)return;u.cleanup();let{current:e}=b;if(!e)return;e.width=C.width,e.height=C.height,e.style.width=`${Math.floor(A.width)}px`,e.style.height=`${Math.floor(A.height)}px`,e.style.visibility="hidden";let t={annotationMode:p?S.ENABLE_FORMS:S.ENABLE,canvasContext:e.getContext("2d",{alpha:!1}),viewport:C};o&&(t.background=o);let n=u.render(t);return n.promise.then(()=>{e.style.visibility="",!function(){if(!!u)h&&h((0,w.XZ)(u,g))}()}).catch(x),()=>(0,w.LJ)(n)},[o,u,p,C,A]);let E=(0,r.useCallback)(()=>{let{current:e}=b;e&&(e.width=0,e.height=0)},[]);return(0,r.useEffect)(()=>E,[E]),(0,i.jsx)("canvas",{className:`${n}__canvas`,dir:"ltr",ref:l(v,b),style:{display:"block",userSelect:"none"},children:f?(0,i.jsx)(_,{}):null})}function A(){let e=y();(0,d.Z)(e,"Unable to find Page context.");let{customTextRenderer:t,onGetTextError:n,onGetTextSuccess:s,onRenderTextLayerError:l,onRenderTextLayerSuccess:h,page:u,pageIndex:f,pageNumber:m,rotate:g,scale:v}=e;(0,d.Z)(u,"Attempted to load page text content, but no page was specified.");let[b,_]=(0,x.Z)(),{value:S,error:C}=b,A=(0,r.useRef)(null),E=(0,r.useRef)(void 0);c(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-text-layer"),10),"TextLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-text-layer");(0,r.useEffect)(function(){_({type:"RESET"})},[u,_]),(0,r.useEffect)(function(){if(!u)return;let e=(0,o.Z)(u.getTextContent());return e.promise.then(e=>{_({type:"RESOLVE",value:e})}).catch(e=>{_({type:"REJECT",error:e})}),()=>(0,w.LJ)(e)},[u,_]),(0,r.useEffect)(()=>{if(void 0!==S){if(!1===S){!function(){if(!!C)c(!1,C.toString()),n&&n(C)}();return}!function(){if(!!S)s&&s(S)}()}},[S]);let k=(0,r.useCallback)(()=>{h&&h()},[h]),T=(0,r.useCallback)(e=>{c(!1,e.toString()),l&&l(e)},[l]),M=(0,r.useMemo)(()=>u.getViewport({scale:v,rotation:g}),[u,g,v]);return(0,r.useLayoutEffect)(function(){if(!u||!S)return;let{current:e}=A;if(!e)return;e.innerHTML="";let n=u.streamTextContent({includeMarkedContent:!0}),i=new p.TextLayer({container:e,textContentSource:n,viewport:M});return i.render().then(()=>{let n=document.createElement("div");n.className="endOfContent",e.append(n),E.current=n;let i=e.querySelectorAll('[role="presentation"]');if(t){let e=0;S.items.forEach((n,r)=>{if(!("str"in n))return;let o=i[e];if(!o)return;let s=t(Object.assign({pageIndex:f,pageNumber:m,itemIndex:r},n));o.innerHTML=s,e+=n.str&&n.hasEOL?2:1})}k()}).catch(T),()=>(0,w.LJ)(i)},[t,T,k,u,f,m,S,M]),(0,i.jsx)("div",{className:(0,a.Z)("react-pdf__Page__textContent","textLayer"),onMouseUp:function(){let e=E.current;if(!!e)e.classList.remove("active")},onMouseDown:function(){let e=E.current;if(!!e)e.classList.add("active")},ref:A})}var E=n("647405");function k(){return(0,r.useContext)(E.Z)}function T(){let e=k(),t=y();(0,d.Z)(t,"Unable to find Page context.");let{imageResourcesPath:n,linkService:s,onGetAnnotationsError:l,onGetAnnotationsSuccess:h,onRenderAnnotationLayerError:u,onRenderAnnotationLayerSuccess:f,page:m,pdf:g,renderForms:v,rotate:b,scale:_=1}=Object.assign(Object.assign({},e),t);(0,d.Z)(g,"Attempted to load page annotations, but no document was specified. Wrap in a or pass explicit `pdf` prop."),(0,d.Z)(m,"Attempted to load page annotations, but no page was specified."),(0,d.Z)(s,"Attempted to load page annotations, but no linkService was specified.");let[S,C]=(0,x.Z)(),{value:A,error:E}=S,T=(0,r.useRef)(null);c(1===Number.parseInt(window.getComputedStyle(document.body).getPropertyValue("--react-pdf-annotation-layer"),10),"AnnotationLayer styles not found. Read more: https://github.com/wojtekmaj/react-pdf#support-for-annotations");(0,r.useEffect)(function(){C({type:"RESET"})},[C,m]),(0,r.useEffect)(function(){if(!m)return;let e=(0,o.Z)(m.getAnnotations());return e.promise.then(e=>{C({type:"RESOLVE",value:e})}).catch(e=>{C({type:"REJECT",error:e})}),()=>{(0,w.LJ)(e)}},[C,m]),(0,r.useEffect)(()=>{if(void 0!==A){if(!1===A){!function(){if(!!E)c(!1,E.toString()),l&&l(E)}();return}!function(){if(!!A)h&&h(A)}()}},[A]);let M=(0,r.useMemo)(()=>m.getViewport({scale:_,rotation:b}),[m,b,_]);return(0,r.useEffect)(function(){if(!g||!m||!s||!A)return;let{current:e}=T;if(!e)return;let t=M.clone({dontFlip:!0}),i={annotations:A,annotationStorage:g.annotationStorage,div:e,imageResourcesPath:n,linkService:s,page:m,renderForms:v,viewport:t};e.innerHTML="";try{new p.AnnotationLayer({accessibilityManager:null,annotationCanvasMap:null,annotationEditorUIManager:null,div:e,l10n:null,page:m,viewport:t}).render(i),f&&f()}catch(e){var r;r=e,c(!1,`${r}`),u&&u(r)}return()=>{}},[A,n,s,m,g,v,M]),(0,i.jsx)("div",{className:(0,a.Z)("react-pdf__Page__annotations","annotationLayer"),ref:T})}var M=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&0>t.indexOf(i)&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var r=0,i=Object.getOwnPropertySymbols(e);rt.indexOf(i[r])&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]]);return n};function D(e){let t=Object.assign(Object.assign({},k()),e),{_className:n="react-pdf__Page",_enableRegisterUnregisterPage:p=!0,canvasBackground:f,canvasRef:m,children:g,className:v,customRenderer:b,customTextRenderer:y,devicePixelRatio:_,error:S="Failed to load the page.",height:E,inputRef:D,loading:O="Loading page…",noData:I="No page specified.",onGetAnnotationsError:N,onGetAnnotationsSuccess:P,onGetStructTreeError:R,onGetStructTreeSuccess:L,onGetTextError:j,onGetTextSuccess:F,onLoadError:B,onLoadSuccess:z,onRenderAnnotationLayerError:H,onRenderAnnotationLayerSuccess:V,onRenderError:U,onRenderSuccess:$,onRenderTextLayerError:W,onRenderTextLayerSuccess:q,pageIndex:G,pageNumber:K,pdf:Z,registerPage:Y,renderAnnotationLayer:X=!0,renderForms:J=!1,renderMode:Q="canvas",renderTextLayer:ee=!0,rotate:et,scale:en=1,unregisterPage:ei,width:er}=t,eo=M(t,["_className","_enableRegisterUnregisterPage","canvasBackground","canvasRef","children","className","customRenderer","customTextRenderer","devicePixelRatio","error","height","inputRef","loading","noData","onGetAnnotationsError","onGetAnnotationsSuccess","onGetStructTreeError","onGetStructTreeSuccess","onGetTextError","onGetTextSuccess","onLoadError","onLoadSuccess","onRenderAnnotationLayerError","onRenderAnnotationLayerSuccess","onRenderError","onRenderSuccess","onRenderTextLayerError","onRenderTextLayerSuccess","pageIndex","pageNumber","pdf","registerPage","renderAnnotationLayer","renderForms","renderMode","renderTextLayer","rotate","scale","unregisterPage","width"]),[es,ea]=(0,x.Z)(),{value:el,error:ed}=es,ec=(0,r.useRef)(null);(0,d.Z)(Z,"Attempted to load a page, but no document was specified. Wrap in a or pass explicit `pdf` prop.");let eh=(0,w.T8)(K)?K-1:null!=G?G:null,eu=null!=K?K:(0,w.T8)(G)?G+1:null,ep=null!=et?et:el?el.rotate:null,ef=(0,r.useMemo)(()=>{if(!el)return null;let e=1,t=null!=en?en:1;if(er||E){let t=el.getViewport({scale:1,rotation:ep});er?e=er/t.width:E&&(e=E/t.height)}return t*e},[E,el,ep,en,er]);(0,r.useEffect)(function(){return()=>{if(!!(0,w.T8)(eh))p&&ei&&ei(eh)}},[p,Z,eh,ei]);(0,r.useEffect)(function(){ea({type:"RESET"})},[ea,Z,eh]),(0,r.useEffect)(function(){if(!Z||!eu)return;let e=(0,o.Z)(Z.getPage(eu));return e.promise.then(e=>{ea({type:"RESOLVE",value:e})}).catch(e=>{ea({type:"REJECT",error:e})}),()=>(0,w.LJ)(e)},[ea,Z,eu]),(0,r.useEffect)(()=>{if(void 0!==el){if(!1===el){!function(){if(!!ed)c(!1,ed.toString()),B&&B(ed)}();return}!function(){if(z){if(!el||!ef)return;z((0,w.XZ)(el,ef))}if(p&&Y){if(!(0,w.T8)(eh)||!ec.current)return;Y(eh,ec.current)}}()}},[el,ef]);let em=(0,r.useMemo)(()=>el&&(0,w.T8)(eh)&&eu&&(0,w.T8)(ep)&&(0,w.T8)(ef)?{_className:n,canvasBackground:f,customTextRenderer:y,devicePixelRatio:_,onGetAnnotationsError:N,onGetAnnotationsSuccess:P,onGetStructTreeError:R,onGetStructTreeSuccess:L,onGetTextError:j,onGetTextSuccess:F,onRenderAnnotationLayerError:H,onRenderAnnotationLayerSuccess:V,onRenderError:U,onRenderSuccess:$,onRenderTextLayerError:W,onRenderTextLayerSuccess:q,page:el,pageIndex:eh,pageNumber:eu,renderForms:J,renderTextLayer:ee,rotate:ep,scale:ef}:null,[n,f,y,_,N,P,R,L,j,F,H,V,U,$,W,q,el,eh,eu,J,ee,ep,ef]),eg=(0,r.useMemo)(()=>(0,s.ZP)(eo,()=>el?ef?(0,w.XZ)(el,ef):void 0:el),[eo,el,ef]),ev=`${eh}@${ef}/${ep}`;return(0,i.jsx)("div",Object.assign({className:(0,a.Z)(n,v),"data-page-number":eu,ref:l(D,ec),style:{"--scale-factor":`${ef}`,backgroundColor:f||"white",position:"relative",minWidth:"min-content",minHeight:"min-content"}},eg,{children:eu?null===Z||null==el?(0,i.jsx)(u.Z,{type:"loading",children:"function"==typeof O?O():O}):!1===Z||!1===el?(0,i.jsx)(u.Z,{type:"error",children:"function"==typeof S?S():S}):(0,i.jsxs)(h.Provider,{value:em,children:[function(){switch(Q){case"custom":return(0,d.Z)(b,'renderMode was set to "custom", but no customRenderer was passed.'),(0,i.jsx)(b,{},`${ev}_custom`);case"none":return null;default:return(0,i.jsx)(C,{canvasRef:m},`${ev}_canvas`)}}(),ee?(0,i.jsx)(A,{},`${ev}_text`):null,X?(0,i.jsx)(T,{},`${ev}_annotations`):null,g]}):(0,i.jsx)(u.Z,{type:"no-data",children:"function"==typeof I?I():I})}))}},71331:function(e,t,n){n.d(t,{Z:function(){return o}});var i=n(455069);function r(e,t){switch(t.type){case"RESOLVE":return{value:t.value,error:void 0};case"REJECT":return{value:!1,error:t.error};case"RESET":return{value:void 0,error:void 0};default:return e}}function o(){return(0,i.useReducer)(r,{value:void 0,error:void 0})}},411757:function(e,t,n){n.d(t,{DE:function(){return g},LJ:function(){return f},Lj:function(){return d},T8:function(){return a},XZ:function(){return m},eP:function(){return l},eR:function(){return v},gJ:function(){return c},jU:function(){return o},tN:function(){return p},us:function(){return h},x_:function(){return u}});var i=n(642844),r=n(733216);let o="undefined"!=typeof window,s=o&&"file:"===window.location.protocol;function a(e){return null!=e}function l(e){return e instanceof ArrayBuffer}function d(e){return(0,i.Z)(o,"isBlob can only be used in a browser environment"),e instanceof Blob}function c(e){return"string"==typeof e&&/^data:/.test(e)}function h(e){(0,i.Z)(c(e),"Invalid data URI.");let[t="",n=""]=e.split(",");return -1!==t.split(";").indexOf("base64")?atob(n):unescape(n)}function u(){return o&&window.devicePixelRatio||1}function p(){r(!s,"Loading PDF as base64 strings/URLs may not work on protocols other than HTTP/HTTPS. On Chromium based browsers, you can use --allow-file-access-from-files flag for debugging purposes.")}function f(e){(null==e?void 0:e.cancel)&&e.cancel()}function m(e,t){return Object.defineProperty(e,"width",{get(){return this.view[2]*t},configurable:!0}),Object.defineProperty(e,"height",{get(){return this.view[3]*t},configurable:!0}),Object.defineProperty(e,"originalWidth",{get(){return this.view[2]},configurable:!0}),Object.defineProperty(e,"originalHeight",{get(){return this.view[3]},configurable:!0}),e}function g(e){return"RenderingCancelledException"===e.name}function v(e){return new Promise((t,n)=>{let i=new FileReader;i.onload=()=>{if(!i.result)return n(Error("Error while reading a file."));t(i.result)},i.onerror=e=>{if(!e.target)return n(Error("Error while reading a file."));let{error:t}=e.target;if(!t)return n(Error("Error while reading a file."));switch(t.code){case t.NOT_FOUND_ERR:return n(Error("Error while reading a file: File not found."));case t.SECURITY_ERR:return n(Error("Error while reading a file: Security error."));case t.ABORT_ERR:return n(Error("Error while reading a file: Aborted."));default:return n(Error("Error while reading a file."))}},i.readAsArrayBuffer(e)})}},642844:function(e,t,n){n.d(t,{Z:function(){return r}});var i="Invariant failed";function r(e,t){var n;if(!e)throw Error(i)}},896433:function(e,t,n){n.d(t,{YG:function(){return d},uY:function(){return r},ue:function(){return i}});for(var i={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},r={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},o="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),s="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),a=0;a<10;a++)i[48+a]=i[96+a]=String(a);for(var a=1;a<=24;a++)i[a+111]="F"+a;for(var a=65;a<=90;a++)i[a]=String.fromCharCode(a+32),r[a]=String.fromCharCode(a);for(var l in i)!r.hasOwnProperty(l)&&(r[l]=i[l]);function d(e){var t=!(o&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||s&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?r:i)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}}}]); //# sourceMappingURL=1602.6561aab0.js.map