captide
Version:
Get hundreds of thousands of financial documents into your AI app 🚀
1 lines • 395 kB
JavaScript
import e,{createContext as t,useState as r,useRef as a,useEffect as n,useCallback as s,useContext as i}from"react";var o=function(){return o=Object.assign||function(e){for(var t,r=1,a=arguments.length;r<a;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},o.apply(this,arguments)};function c(e,t,r,a){return new(r||(r=Promise))((function(n,s){function i(e){try{c(a.next(e))}catch(e){s(e)}}function o(e){try{c(a.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,o)}c((a=a.apply(e,t||[])).next())}))}function l(e,t){var r,a,n,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=o(0),i.throw=o(1),i.return=o(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function o(o){return function(c){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,o[0]&&(s=0)),s;)try{if(r=1,a&&(n=2&o[0]?a.return:o[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,o[1])).done)return n;switch(a=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,a=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],a=0}finally{r=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,c])}}}function f(e,t,r){if(r||2===arguments.length)for(var a,n=0,s=t.length;n<s;n++)!a&&n in t||(a||(a=Array.prototype.slice.call(t,0,n)),a[n]=t[n]);return e.concat(a||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var h=["10-K","10-Q","8-K","transcript","DEF 14A","DEFM14A","DEF 14C","DEFM14C","20-F","40-F","6-K","S-1","ir"],u={document:null,highlightedElementId:null,isLoading:!1,isOpen:!1,tabs:[],zoomLevel:1},d=t(void 0);function p(e){try{var t=new URL(e).searchParams.get("sourceType");if(!t)return"ir";var r=t.toUpperCase();if(h.includes(t))return t;var a=h.find((function(e){return e.toUpperCase()===r}));return a||"ir"}catch(e){return"ir"}}function m(e){try{var t=new URL(e).searchParams.get("fileType");return"pdf"===t||"xlsx"===t?t:void 0}catch(e){return}}function g(e,t){if(void 0===t&&(t=null),!e||"object"!=typeof e)throw new Error("Invalid document provided to convertToInternalDocument");e.sourceType||(e.sourceType="ir"),e.sourceLink||(e.sourceLink="unknown");var r="ir";if(h.includes(e.sourceType))r=e.sourceType;else{var a=e.sourceType.toUpperCase(),n=h.find((function(e){return e.toUpperCase()===a}));n&&(r=n)}var s=o(o({},e),{sourceType:r});if(s.sasUrl){var i=s.sasUrl;return i&&i.includes("sig=")&&(i.includes("se=")||i.includes("sp=")),{sourceLink:s.sourceLink,sourceType:s.sourceType,date:s.date||null,htmlContent:"",ticker:s.ticker||"",fiscalPeriod:s.fiscalPeriod||null,companyName:s.companyName||"",highlightedElementId:t,fileType:s.fileType||((s.fileName||"").toLowerCase().endsWith(".pdf")?"pdf":"xlsx"),contentType:s.contentType||((s.fileName||"").toLowerCase().endsWith(".pdf")?"application/pdf":(s.fileName||"").toLowerCase().endsWith(".xlsx")?"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"application/octet-stream"),fileName:s.fileName,sasUrl:s.sasUrl,metadata:s.metadata||{}}}return o(o({},s),{highlightedElementId:t})}d.displayName="DocumentViewerContext";var v=function(t){var i=t.children,h=t.fetchDocumentFn,v=r(u),b=v[0],w=v[1],E=a(null);n((function(){h&&(E.current=h)}),[h]);var T=s((function(e){w((function(t){return o(o({},t),e)}))}),[]),y=s((function(e){T({document:e,isLoading:!1,highlightedElementId:(null==e?void 0:e.highlightedElementId)||null})}),[T]),k=s((function(e){if(e&&!e.startsWith("#"))throw new Error("Element ID must start with # - received: "+e);if(e&&8!==e.replace("#","").length)throw new Error("Element ID must be 8 characters long (excluding #) - received: "+e);T({highlightedElementId:e}),b.document&&y(o(o({},b.document),{highlightedElementId:e}))}),[T,y,b.document]),x=s((function(e){E.current=e}),[]),A=s((function(){T({isOpen:!0,tabs:[]})}),[T]),S=s((function(){T({isOpen:!1,document:null,highlightedElementId:null,tabs:[]})}),[T]),C=s((function(e,t){return c(void 0,void 0,void 0,(function(){var r,a,n,s,i,c,u,d,v,w,k,x,S;return l(this,(function(l){switch(l.label){case 0:if(!e||"string"!=typeof e||""===e.trim())throw new Error("Invalid sourceLink: sourceLink must be a non-empty string.");if(!(r=E.current||h))throw new Error("No fetchDocumentFn provided. Use setFetchDocumentFn to set a function for fetching documents or provide it to the DocumentViewerProvider.");if(b.isOpen||A(),b.document&&b.document.sourceLink===e)return T({highlightedElementId:t||null}),b.document&&y(o(o({},b.document),{highlightedElementId:t||null})),[2];a=b.tabs.findIndex((function(t){return t.sourceLink===e})),n=f([],b.tabs,!0);try{s=p(e)}catch(t){s=e.includes("transcript")?"transcript":"10-K"}if("ir"===s&&m(e),-1===a)try{i={sourceLink:e,sourceType:s,ticker:null,fiscalPeriod:null,isLoading:!0},n.unshift(i)}catch(t){c=e.includes("transcript")?"transcript":"10-K",u={sourceLink:e,sourceType:c,ticker:"Unknown",fiscalPeriod:"",isLoading:!0},n.unshift(u)}else n=n.map((function(t){return t.sourceLink===e?o(o({},t),{isLoading:!0}):t})),d=n[a],n.splice(a,1),n.unshift(d);T({tabs:n,isLoading:!0,document:null}),l.label=1;case 1:return l.trys.push([1,3,,4]),[4,r(e)];case 2:return v=l.sent(),w=g(v,t||null),k=n.map((function(t){return t.sourceLink===e?o(o({},t),{sourceType:w.sourceType,ticker:w.ticker,fiscalPeriod:w.fiscalPeriod,isLoading:!1}):t})),T({document:w,tabs:k,isLoading:!1,highlightedElementId:t||null}),[3,4];case 3:throw x=l.sent(),S=n.map((function(t){return t.sourceLink===e?o(o({},t),{isLoading:!1}):t})),T({isLoading:!1,document:null,highlightedElementId:null,tabs:S}),x;case 4:return[2]}}))}))}),[b.tabs,b.isOpen,b.document,T,A,y]),_=s((function(e){if(!e||"string"!=typeof e||""===e.trim())throw new Error("Cannot select tab: sourceLink must be a non-empty string");var t,r=f([],b.tabs,!0),a=r.findIndex((function(t){return t.sourceLink===e}));try{t=p(e)}catch(r){t=e.includes("transcript")?"transcript":"10-K"}if("ir"===t&&m(e),-1===a)try{var n={sourceLink:e,sourceType:t,ticker:null,fiscalPeriod:null,isLoading:!0};if(r.unshift(n),T({tabs:r,isLoading:!0}),!(c=E.current||h))throw T({isLoading:!1}),new Error("No fetchDocumentFn provided. Cannot load document for the new tab.");c(e).then((function(t){var a=g(t);y(a);var n=r.map((function(t){return t.sourceLink===e?o(o({},t),{sourceType:a.sourceType,ticker:a.ticker,fiscalPeriod:a.fiscalPeriod,isLoading:!1}):t}));T({tabs:n,isLoading:!1})})).catch((function(t){var a=r.map((function(t){return t.sourceLink===e?o(o({},t),{isLoading:!1}):t}));T({isLoading:!1,tabs:a})}))}catch(t){var s=e.includes("transcript")?"transcript":"10-K",i={sourceLink:e,sourceType:s,ticker:"ERROR",fiscalPeriod:"Failed to parse URL",isLoading:!1};throw r.unshift(i),T({tabs:r}),new Error("Failed to select tab: ".concat(t instanceof Error?t.message:String(t)))}else{if(b.document&&b.document.sourceLink===e)return;var c;if(T({isLoading:!0}),!(c=E.current||h))throw T({isLoading:!1}),new Error("No fetchDocumentFn provided. Cannot load document for the selected tab.");c(e).then((function(t){var a=g(t);y(a);var n=r.map((function(t){return t.sourceLink===e?o(o({},t),{sourceType:a.sourceType,ticker:a.ticker,fiscalPeriod:a.fiscalPeriod,isLoading:!1}):t}));T({tabs:n,isLoading:!1})})).catch((function(e){T({isLoading:!1})}))}}),[b.tabs,b.document,T,y]),O=s((function(e){var t=f([],b.tabs,!0).filter((function(t){return t.sourceLink!==e}));if(b.document&&b.document.sourceLink===e)if(0===t.length)S();else{var r=t[0];T({tabs:t,isLoading:!0});var a=E.current||h;if(!a)throw T({isLoading:!1}),new Error("No fetchDocumentFn provided. Cannot load document for the next tab.");a(r.sourceLink).then((function(e){var r=g(e);T({document:r,tabs:t,isLoading:!1,highlightedElementId:null})})).catch((function(e){T({isLoading:!1,tabs:t})}))}else T({tabs:t})}),[b.tabs,b.document,T,S,h]),R=s((function(e){var t=Math.max(.25,Math.min(2,e));T({zoomLevel:t})}),[T]),I=s((function(){var e=Math.min(2,b.zoomLevel+.1);T({zoomLevel:e})}),[T,b.zoomLevel]),N=s((function(){var e=Math.max(.25,b.zoomLevel-.1);T({zoomLevel:e})}),[T,b.zoomLevel]),L=s((function(){T({zoomLevel:1})}),[T]),D=o(o({},b),{updateDocumentViewer:T,setDocument:y,highlightElement:k,loadDocument:C,setFetchDocumentFn:x,openViewer:A,closeViewer:S,selectTab:_,closeTab:O,setZoomLevel:R,zoomIn:I,zoomOut:N,resetZoom:L});return e.createElement(d.Provider,{value:D},i)},b=function(){var e=i(d);if(void 0===e)throw new Error("useDocumentViewer must be used within a DocumentViewerProvider. Make sure you have wrapped your application or component with <DocumentViewerProvider>.</DocumentViewerProvider>");return e},w="undefined"!=typeof process&&void 0!==process.env&&"undefined"!=typeof require,E=function(t,r){void 0===r&&(r={ssr:!0});var a=r.ssr,n=void 0===a||a,s=r.loading;if(w)try{return(0,require("next/dynamic").default)(t,{ssr:n,loading:s?function(){return e.createElement(s)}:void 0})}catch(e){}return e.lazy(t)};function T(e,t,r,a){void 0===r&&(r=window.location.origin),void 0===a&&(a="/document-viewer"),r.endsWith("/")&&(r=r.slice(0,-1)),a.startsWith("/")||(a="/"+a);var n=new URL("".concat(r).concat(a));return n.searchParams.append("sourceLink",encodeURIComponent(e)),t&&n.searchParams.append("elementId",t),n.toString()}function y(e){void 0===e&&(e=window.location.href);try{var t=new URL(e),r=t.searchParams.get("sourceLink"),a=t.searchParams.get("elementId");return{sourceLink:r?decodeURIComponent(r):null,elementId:a||null}}catch(e){return console.error("Failed to parse document viewer URL:",e),{sourceLink:null,elementId:null}}}var k=function(t){var a=t.isVisible,n=t.position,s=t.sourceLink,i=t.elementId,o=t.baseUrl,f=t.onClose,h=t.buttonColor,u=void 0===h?"#2563eb":h,d=t.viewerRoutePath,p=void 0===d?"document-viewer":d,m=r(!1),g=m[0],v=m[1],b=T(s,i,o,p);if(!a)return null;var w;w=u.replace("#",""),parseInt(w.substring(0,2),16),parseInt(w.substring(2,4),16),parseInt(w.substring(4,6),16);return e.createElement("div",{className:"absolute z-50 bg-white rounded-lg shadow-xl border border-gray-200 p-3 w-80 shareable-link-tooltip-container",style:{left:"".concat(n.x,"px"),top:"".concat(n.y,"px"),transform:"translateX(-25%)"}},e.createElement("div",{className:"absolute w-4 h-4 bg-white border-t border-l border-gray-200 transform rotate-45",style:{top:"-2px",left:"25%",marginLeft:"-2px"}}),e.createElement("div",{className:"flex items-center justify-between mb-2"},e.createElement("div",{className:"flex items-center"},e.createElement("svg",{className:"w-4 h-4 mr-2",style:{color:u},xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e.createElement("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})),e.createElement("span",{className:"text-sm font-medium"},"Share this highlight")),e.createElement("button",{className:"text-gray-400 hover:text-gray-600 transition-colors",onClick:f,"aria-label":"Close"},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})))),e.createElement("div",{className:"text-xs text-gray-500 mb-2"},"Anyone with this link can view this highlighted section:"),e.createElement("div",{className:"flex items-center"},e.createElement("input",{type:"text",value:b,readOnly:!0,className:"flex-1 p-2 text-sm border rounded-l-md bg-gray-50 text-gray-700 overflow-hidden text-ellipsis focus:outline-none"}),e.createElement("button",{onClick:function(){return c(void 0,void 0,void 0,(function(){return l(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,navigator.clipboard.writeText(b)];case 1:return e.sent(),v(!0),setTimeout((function(){v(!1)}),2e3),[3,3];case 2:return e.sent(),[3,3];case 3:return[2]}}))}))},className:"px-3 py-2 rounded-r-md text-sm font-medium ".concat("text-white"," transition-colors"),style:{backgroundColor:g?"#10B981":u}},g?e.createElement("div",{className:"flex items-center"},e.createElement("svg",{className:"w-4 h-4 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("polyline",{points:"20 6 9 17 4 12"})),e.createElement("span",null,"Copied")):e.createElement("div",{className:"flex items-center"},e.createElement("svg",{className:"w-4 h-4 mr-1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),e.createElement("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})),e.createElement("span",null,"Copy")))))},x=function(e){var t=(new DOMParser).parseFromString(e,"text/html"),r=Array.from(t.querySelectorAll('div[style*="padding-top:2em"]'));if(0===r.length)return e;var a="<html><head><style>";return a+="\n .page-container {\n margin-bottom: 20px;\n padding: 10px;\n border: 1px solid #ddd;\n background-color: white;\n position: relative;\n }\n .page-highlighted {\n outline: 4px solid yellow;\n outline-offset: -4px;\n }\n .page-number {\n position: absolute;\n top: 5px;\n right: 5px;\n background-color: rgba(0,0,0,0.1);\n padding: 2px 8px;\n border-radius: 10px;\n font-size: 12px;\n z-index: 1000;\n }\n ",a+='</style></head><body><div id="document-pages-wrapper">',r.forEach((function(e,t){a+='<div class="page-container" data-page="'.concat(t,'">'),a+='<div class="page-number">'.concat(t+1,"</div>"),a+=e.outerHTML,a+="</div>"})),a+="</div></body></html>"},A=function(e){var t=e.toUpperCase();return"20-F"===t||"40-F"===t||"6-K"===t||"S-1"===t},S=function(e,t,r,a,n){if(n&&e.current&&e.current.contentDocument){var s=e.current.contentDocument,i=e.current.contentWindow;if(s&&i){s.querySelectorAll(".shareable-link-button").forEach((function(e){return e.remove()}));var o=s.getElementById("shareable-link-button-styles");o||((o=s.createElement("style")).id="shareable-link-button-styles",s.head.appendChild(o)),o.textContent="\n .shareable-link-button {\n position: absolute !important;\n top: -10px !important;\n left: 5px !important;\n width: 28px !important;\n height: 28px !important;\n min-width: 28px !important;\n min-height: 28px !important;\n background-color: ".concat(t," !important;\n color: white !important;\n border-radius: 50% !important;\n display: flex !important;\n align-items: center !important;\n justify-content: center !important;\n cursor: pointer !important;\n border: 2px solid white !important;\n z-index: 100000 !important;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3) !important;\n transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease, background-color 0.2s ease !important;\n pointer-events: auto !important;\n opacity: 0 !important;\n visibility: hidden !important;\n }\n \n /* Show the button when hovering over ANY highlighted element */\n .highlighted:hover ~ .shareable-link-button,\n .highlighted:hover .shareable-link-button,\n .page-highlighted:hover .shareable-link-button {\n opacity: 0.9 !important;\n visibility: visible !important;\n background-color: ").concat(t," !important;\n }\n \n .shareable-link-button:hover {\n background-color: ").concat("#2563eb"===t?"#1d4ed8":t," !important;\n transform: scale(1.1) !important;\n opacity: 1 !important;\n }\n\n .highlighted {\n position: relative !important;\n padding-left: 5px !important;\n }\n \n .first-highlighted {\n margin-top: 12px !important;\n }\n ");var f=function(e,a,n){void 0===n&&(n=!1),e.style.position="relative";var i=s.createElement("button");i.className="shareable-link-button",i.title=n?"Click to copy link to this page":"Click to copy link to this highlight",i.setAttribute("data-share-id",a),i.style.position="absolute",i.style.top="-10px",i.style.left="5px",i.style.width="24px",i.style.height="24px",i.style.minWidth="24px",i.style.minHeight="24px",i.style.backgroundColor=t,i.style.color="white",i.style.borderRadius="50%",i.style.display="flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.cursor="pointer",i.style.border="2px solid white",i.style.zIndex="100000",i.style.boxShadow="0 2px 4px rgba(0, 0, 0, 0.3)",i.style.opacity="0",i.style.visibility="hidden",i.addEventListener("mouseenter",(function(){i.style.transform="scale(1.1)",i.style.opacity="1",i.style.backgroundColor="#2563eb"===t?"#1d4ed8":t})),i.addEventListener("mouseleave",(function(){i.style.transform="scale(1)",i.style.backgroundColor=t,i.style.opacity="0.9"}));var o=function(e){void 0===e&&(e=!1),i.innerHTML=e?'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="width: 16px; height: 16px;">\n <polyline points="20 6 9 17 4 12"></polyline>\n </svg>':'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="white" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" style="width: 16px; height: 16px;">\n <path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>\n <path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>\n </svg>'};o(),i.addEventListener("click",(function(e){return c(void 0,void 0,void 0,(function(){return l(this,(function(n){switch(n.label){case 0:return e.stopPropagation(),e.preventDefault(),r?[4,C(r.sourceLink,a)]:[3,2];case 1:n.sent()&&(o(!0),i.style.backgroundColor=t,setTimeout((function(){o(!1),i.style.backgroundColor=t}),2e3)),n.label=2;case 2:return[2]}}))}))})),e.appendChild(i)};if("8-K"!==(null==r?void 0:r.sourceType)){var h=s.querySelectorAll(".highlighted");if(h.length>0){var u=Array.from(h);u.sort((function(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}));var d=u[0];d.classList.add("first-highlighted");var p=d.getAttribute("unique_id")||d.getAttribute("unique-id")||d.getAttribute("id"),m=p?"#".concat(p.replace(/[#\[\]]/g,"")):a;m&&(f(d,m),h.forEach((function(e){e.addEventListener("mouseenter",(function(){var e=d.querySelector(".shareable-link-button");e&&(e.style.visibility="visible",e.style.opacity="0.9")})),e.addEventListener("mouseleave",(function(){var e=d.querySelector(".shareable-link-button");e&&(e.matches(":hover")||(e.style.visibility="hidden",e.style.opacity="0"))}))})))}}else if("8-K"===(null==r?void 0:r.sourceType)){s.querySelectorAll(".page-container.page-highlighted").forEach((function(e){var t=e.getAttribute("data-page");if(null!==t){var r="#f234".concat(t.padStart(4,"0"));f(e,r,!0)}}))}}}},C=function(e,t,r,a){return void 0===a&&(a="document-viewer"),c(void 0,void 0,void 0,(function(){var n;return l(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),n=T(e,t,r,a),[4,navigator.clipboard.writeText(n)];case 1:return s.sent(),[2,!0];case 2:return s.sent(),[2,!1];case 3:return[2]}}))}))},_=function(e){return"\n <html>\n <head>\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <style>\n html, body { \n margin: 0; \n padding: 0;\n width: 100%;\n height: auto;\n background-color: white;\n }\n \n /* Highlighted elements basic styling */\n .highlighted {\n background-color: yellow !important;\n }\n .highlighted * {\n background-color: transparent !important;\n }\n </style>\n <script>\n // Add resize handler to recalculate document height\n window.addEventListener('resize', function() {\n // Force reflow calculation\n document.body.style.height = 'auto';\n // Inform parent of new height if needed\n if (window.parent && window.parent !== window) {\n const height = document.body.scrollHeight;\n window.parent.postMessage({ type: 'resize', height: height }, '*');\n }\n });\n \n // Initialize height after content is loaded\n document.addEventListener('DOMContentLoaded', function() {\n if (window.parent && window.parent !== window) {\n setTimeout(function() {\n const height = document.body.scrollHeight;\n window.parent.postMessage({ type: 'resize', height: height }, '*');\n }, 200);\n }\n });\n <\/script>\n <base target=\"_blank\">\n </head>\n <body>".concat(e,"</body>\n </html>\n")},O=function(e){if(!e)return null;var t=e.replace("#","");if(8!==t.length)return null;var r=t.slice(-4);return parseInt(r,10)},R=function(e){var t=e.toUpperCase();return["DEF 14A","DEFM14A","DEF 14C","DEFM14C"].includes(t)},I=function(e,t,r,a,n){var s=e.contentDocument;if(s&&(s.querySelectorAll(".highlighted").forEach((function(e){e.classList.remove("highlighted")})),r)){var i=r.replace("#","");setTimeout((function(){var e=s.querySelectorAll('[unique_id*="'.concat(i,'"], [unique-id*="').concat(i,'"], [unique-id*="#').concat(i,'"], [id*="[#').concat(i,']"]'));if(e.length>0){e.forEach((function(e){e.classList.add("highlighted")}));var t=e[0];t&&t.scrollIntoView({behavior:a?"auto":"smooth",block:"center"})}}),a?500:0)}},N=function(t){var s=t.document,i=t.highlightedElementId,c=t.zoomLevel,l=t.className,f=void 0===l?"w-full h-full":l,h=t.style,u=t.enableShareableLinks,d=void 0===u||u,p=t.shareableLinkBaseUrl,m=t.shareableLinkButtonColor,g=void 0===m?"#2563eb":m,v=t.viewerRoutePath,b=void 0===v?"document-viewer":v,w=!!p&&!1!==d,E=a(null),T=a(null),y=a(null);a(1);var C=r(!1),N=C[0],L=C[1],D=r({x:0,y:0}),F=D[0];D[1];var P=r(null),M=P[0];P[1];var U=r(!0),B=U[0],W=U[1];n((function(){var e=E.current;if(e&&s){W(!0);var t,r,a,n=function(){var t=e.contentDocument;if(t){if(A(s.sourceType)){var r=t.createElement("style");if(r.textContent="\n .highlighted {\n background-color: yellow !important;\n }\n .highlighted * {\n background-color: transparent !important;\n }\n .first-highlighted {\n margin-top: 12px !important;\n }\n \n /* Ensure white background */\n html, body {\n background-color: white !important;\n }\n ",t.head.appendChild(r),1!==c){var a=t.createElement("style");a.textContent="\n body {\n transform-origin: top left;\n transform: scale(".concat(c,");\n width: ").concat(100/c,"%;\n }\n "),t.head.appendChild(a)}return function(e,t){var r,a,n,s=e.contentDocument,i=e.contentWindow;if(s&&i&&t){for(var o,c=t.replace("#",""),l=8===c.length&&c.substring(0,4)===c.substring(4,8),f=c.substring(0,4),h=l?f:c.length>=8?c.substring(4,8):f,u=[],d=s.createNodeIterator(s.body,NodeFilter.SHOW_COMMENT,{acceptNode:function(){return NodeFilter.FILTER_ACCEPT}});o=d.nextNode();){var p=null===(r=o.nodeValue)||void 0===r?void 0:r.trim();p&&p.startsWith("[[#")&&p.endsWith("]]")&&u.push({node:o,id:p.substring(3,7)})}if(s.querySelectorAll(".highlighted").forEach((function(e){e.classList.remove("highlighted")})),c.length,f===h||l){var m=u.filter((function(e){return e.id===f}));if(m.length>=2)for(var g=l?2:1,v=0;v<m.length-1;v+=g){var b=m[v],w=v+1<m.length?m[v+1]:null;if(w){for(var E=[],T=b.node.nextSibling;T&&T!==w.node;){if(T.nodeType===Node.ELEMENT_NODE)E.push(T);else if(T.nodeType===Node.TEXT_NODE&&(null===(a=T.textContent)||void 0===a?void 0:a.trim())){var y=s.createElement("span");y.classList.add("highlighted"),null===(n=T.parentNode)||void 0===n||n.insertBefore(y,T),y.appendChild(T),E.push(y),T=y}T=T.nextSibling}if(E.forEach((function(e){e.classList.add("highlighted")})),E.length>0){E[0].scrollIntoView({behavior:"smooth",block:"start"});break}}}}else{var k=u.findIndex((function(e){return e.id===f})),x=u.findIndex((function(e){return e.id===h}));if(-1!==k&&-1!==x){var A=[];u[k].node,u[x].node;var S=function(e){for(var t,r=s.createTreeWalker(e,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT,null),a=[];t=r.nextNode();)a.push(t);return a}(s.body),C=S.findIndex((function(e){var t;return e.nodeType===Node.COMMENT_NODE&&(null===(t=e.nodeValue)||void 0===t?void 0:t.trim())==="[[#".concat(f,"]]")})),_=S.findIndex((function(e){var t;return e.nodeType===Node.COMMENT_NODE&&(null===(t=e.nodeValue)||void 0===t?void 0:t.trim())==="[[#".concat(h,"]]")}));if(-1!==C&&-1!==_)for(v=C+1;v<=_;v++){var O=S[v];O&&O.nodeType===Node.ELEMENT_NODE&&A.push(O)}if(A.forEach((function(e){e.nodeType===Node.ELEMENT_NODE&&e.classList.add("highlighted")})),A.length>0){var R=A.find((function(e){return e.nodeType===Node.ELEMENT_NODE}));R&&R.scrollIntoView({behavior:"smooth",block:"start"})}}}}}(e,i),S(E,g,s,i,w),void W(!1)}if("8-k"===s.sourceType||(o=s.sourceType,"DEF 14A"===(l=o.toUpperCase())||"DEFM14A"===l||"DEF 14C"===l||"DEFM14C"===l)){var n=t.createElement("style");return n.textContent=function(e){return"\n /* Base container styles with consistent padding */\n html, body {\n transform-origin: top left;\n transform: scale(".concat(e,");\n width: ").concat(100/e,"%;\n overflow-x: hidden;\n margin: 0;\n padding: 0;\n background-color: white;\n }\n \n /* Apply consistent width and padding to pages */\n .page-container, .captide-page {\n width: 100% !important;\n max-width: 100%;\n margin-left: auto !important;\n margin-right: auto !important;\n margin-bottom: 10px;\n padding: 16px !important;\n box-sizing: border-box !important;\n background-color: white;\n border: 1px solid #ddd;\n }\n \n .page-highlighted {\n outline: 4px solid yellow;\n outline-offset: -4px;\n }\n \n /* Styles for proxy statement documents with captide-page markers */\n .captide-page-highlighted {\n outline: 4px solid yellow;\n outline-offset: -4px;\n }\n \n /* Improve table rendering */\n table {\n max-width: 100%;\n table-layout: auto;\n margin-left: auto !important;\n margin-right: auto !important;\n }\n \n /* Highlighted elements */\n .highlighted {\n background-color: yellow !important;\n }\n \n .highlighted * {\n background-color: transparent !important;\n }\n")}(c),t.head.appendChild(n),function(e,t,r){var a=e.contentDocument,n=e.contentWindow;if(a&&n&&("8-K"===t.sourceType.toUpperCase()||R(t.sourceType))&&r){var s=O(r);if(null===s)return;if(R(t.sourceType)){var i=s+1;return void setTimeout((function(){if("function"==typeof n.highlightCaptidePage)n.highlightCaptidePage(i);else{var e=a.querySelectorAll('.captide-page[data-page-number="'.concat(i,'"]'));e.length>0&&(a.querySelectorAll(".captide-page-highlighted").forEach((function(e){e.classList.remove("captide-page-highlighted")})),e[0].classList.add("captide-page-highlighted"),e[0].scrollIntoView({behavior:"smooth",block:"start"}))}}),200)}var o=a.querySelectorAll(".page-container");if(o&&o.length>0){a.querySelectorAll(".page-highlighted").forEach((function(e){e.classList.remove("page-highlighted")}));var c=null,l=Math.min(s,o.length-1);(c=o[l])&&(c.classList.add("page-highlighted"),setTimeout((function(){c&&c.scrollIntoView({behavior:"smooth",block:"start"})}),100))}}}(e,s,i),void W(!1)}var o,l;if("10-k"===s.sourceType.toLowerCase()||"10-q"===s.sourceType.toLowerCase()){var f=t.createElement("style");return f.textContent=function(e){return"\n /* Base container styles */\n html, body {\n transform-origin: top left;\n transform: scale(".concat(e,");\n width: ").concat(100/e,'%;\n overflow-x: hidden;\n margin: 0;\n padding: 0;\n background-color: white;\n }\n \n /* Apply consistent width to direct children of body */\n body > * {\n width: 100% !important;\n max-width: 100%;\n margin-left: auto !important;\n margin-right: auto !important;\n padding-left: 16px !important;\n padding-right: 16px !important;\n box-sizing: border-box !important;\n }\n \n /* Ensure tables are displayed properly */\n table {\n max-width: 100%;\n table-layout: auto;\n margin-left: auto !important;\n margin-right: auto !important;\n }\n \n /* Financial tables should be handled specially */\n .financial-table, \n .ix_hidden, \n .previewer-table,\n table[class*="table"],\n div[class*="table"] {\n width: auto !important;\n max-width: 100%;\n overflow-x: auto;\n }\n \n /* For numeric data columns, preserve formatting */\n td[align="right"], th[align="right"] {\n white-space: nowrap;\n text-align: right;\n }\n \n /* Highlighted elements */\n .highlighted {\n background-color: yellow !important;\n }\n \n .highlighted * {\n background-color: transparent !important;\n }\n \n /* Remove any unwanted margins/padding */\n body p, body div, body section, body article {\n max-width: 100%;\n }\n')}(c),t.head.appendChild(f),I(e,0,i,T.current!==s.sourceLink||y.current!==s.sourceType),S(E,g,s,i,w),void W(!1)}I(e,0,i,T.current!==s.sourceLink||y.current!==s.sourceType);var h=t.createElement("style");h.textContent=function(e){return"\n /* Base container styles */\n html, body {\n transform-origin: top left;\n transform: scale(".concat(e,");\n width: ").concat(100/e,'%;\n max-width: 100%;\n overflow-x: hidden;\n margin: 0;\n padding: 0;\n background-color: white;\n }\n \n /* Apply consistent width to direct children of body */\n body > * {\n width: 100% !important;\n max-width: 100%;\n margin-left: auto !important;\n margin-right: auto !important;\n padding-left: 24px !important;\n padding-right: 24px !important;\n box-sizing: border-box !important;\n }\n \n /* Allow natural wrapping while preventing horizontal overflow */\n body * {\n max-width: 100%;\n box-sizing: border-box;\n font-size: 1.025em; /* Slightly increase text size */\n }\n \n /* Handle tables more naturally */\n table {\n max-width: 100%;\n table-layout: auto;\n width: auto;\n margin-left: auto !important;\n margin-right: auto !important;\n }\n \n /* Allow tables to wrap - less aggressive approach */\n table, thead, tbody, th, td {\n max-width: 100%;\n overflow-wrap: break-word;\n }\n \n /* Financial document tables often need special handling */\n .ix_hidden, .previewer-table, .financial-table {\n max-width: 100%;\n width: auto !important;\n }\n \n /* For numeric data columns, preserve as much as possible */\n td[align="right"], th[align="right"] {\n white-space: nowrap;\n text-align: right;\n }\n \n /* Make images responsive */\n img {\n max-width: 100%;\n height: auto;\n }\n \n /* Highlighted elements */\n .highlighted {\n background-color: yellow !important;\n }\n .highlighted * {\n background-color: transparent !important;\n }\n \n /* Make links visible */\n a {\n color: #2563eb;\n text-decoration: underline;\n }\n')}(c),t.head.appendChild(h);var u=t.createElement("style");u.textContent="\n html, body { \n background-color: white !important;\n }\n ",t.head.appendChild(u),setTimeout((function(){S(E,g,s,i,w),W(!1)}),500)}};return t=s.htmlContent||"",r=s.sourceLink,"8-k"===s.sourceType&&(t=function(e){if(/ex(hibit)?[-_]?99/i.test(e)&&(e.includes(".jpg")||e.includes(".png"))&&e.includes("padding-top:2em;"))return x(e);var t=[/<hr[^>]*style=['"]page-break-after:always['"][^>]*>/gi,/<hr[^>]*style=['"][^"']*page-break[^"']*['"][^>]*>/gi],r=0;t.forEach((function(t){var a=e.match(t)||[];r+=a.length}));var a=e;t.forEach((function(e){a=a.replace(e,"\x3c!-- PAGE_BREAK --\x3e")})),r<2&&[/<div[^>]*class=['"]BRPFPageBreak['"][^>]*>/gi,/<div[^>]*style=['"][^"']*page-break-before:always['"][^>]*>/gi,/<div[^>]*style=['"][^"']*page-break-after:always['"][^>]*>/gi,/<div[^>]*style=['"]min-height:42\.75pt;[^"']*['"][^>]*><div><[^>]*><br><\/[^>]*><\/div><\/div>/gi,/<hr[^>]*noshade[^>]*>/gi].forEach((function(e){(a.match(e)||[]).length>0&&(a=a.replace(e,"\x3c!-- PAGE_BREAK --\x3e"))})),a.includes("\x3c!-- PAGE_BREAK --\x3e")||(a=a.replace(/<hr[^>]*>/gi,"\x3c!-- PAGE_BREAK --\x3e"));var n=a.split("\x3c!-- PAGE_BREAK --\x3e").filter((function(e){return e.trim().length>0})),s="<html><head><style>";return s+="\n .page-container {\n margin-bottom: 20px;\n padding: 10px;\n border: 1px solid #ddd;\n background-color: white;\n position: relative;\n }\n .page-highlighted {\n outline: 4px solid yellow;\n outline-offset: -4px;\n }\n .page-number {\n position: absolute;\n top: 5px;\n right: 5px;\n background-color: rgba(0,0,0,0.1);\n padding: 2px 8px;\n border-radius: 10px;\n font-size: 12px;\n z-index: 1000;\n }\n ",s+='</style></head><body><div id="document-pages-wrapper">',n.forEach((function(e,t){s+='<div class="page-container" data-page="'.concat(t,'">'),s+='<div class="page-number">'.concat(t+1,"</div>"),s+=e,s+="</div>"})),s+="</div></body></html>"}(t)),a=A(s.sourceType)?"\n <!DOCTYPE html>\n <html>\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <base target=\"_blank\">\n <script>\n // Simple resize handler\n window.addEventListener('resize', function() {\n if (window.parent) {\n window.parent.postMessage({ type: 'resize', height: document.body.scrollHeight }, '*');\n }\n });\n \n // Report document height after load\n window.addEventListener('load', function() {\n setTimeout(function() {\n if (window.parent) {\n window.parent.postMessage({ type: 'resize', height: document.body.scrollHeight }, '*');\n }\n }, 100);\n });\n <\/script>\n </head>\n <body>".concat(t,"</body>\n </html>\n "):_(t),T.current!==r||y.current!==s.sourceType?(e.srcdoc=a,T.current=r,y.current=s.sourceType):n(),e.addEventListener("load",n),function(){return e.removeEventListener("load",n)}}}),[s,i,c,w,g]),n((function(){var e=setTimeout((function(){S(E,g,s,i,w)}),1e3);return function(){return clearTimeout(e)}}),[i,s,w,g]);var z=function(){L(!1)};n((function(){var e=function(e){if(N){var t=window.document.querySelector(".shareable-link-tooltip-container");t&&!t.contains(e.target)&&z()}};return window.document.addEventListener("click",e),function(){window.document.removeEventListener("click",e)}}),[N]),n((function(){var e,t=function(e){e.data&&e.data.type};window.addEventListener("message",t);var r=null===(e=E.current)||void 0===e?void 0:e.parentElement;if(r&&window.ResizeObserver){var a=new ResizeObserver((function(){E.current&&E.current.contentWindow&&E.current.contentWindow.dispatchEvent(new Event("resize"))}));return a.observe(r),function(){window.removeEventListener("message",t),a.disconnect()}}return function(){window.removeEventListener("message",t)}}),[]);var H=s?"captide-source-".concat(s.sourceType.toLowerCase().replace(/\s/g,"-")):"",V=s&&s.htmlContent?_(s.htmlContent):"";return e.createElement("div",{className:"relative w-full h-full",style:{background:"white"}},e.createElement("iframe",{ref:E,srcDoc:V,className:"".concat(f," ").concat(H),style:o(o({},h),{border:"none",opacity:B?0:1,width:"100%",height:"100%",overflow:"auto",background:"white",display:"block",maxWidth:"100%",transition:"opacity 0.3s ease"}),title:"Document Viewer"}),B&&e.createElement("div",{className:"absolute inset-0 flex flex-col items-center justify-center",style:{zIndex:10,backgroundColor:"white"}},e.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #475569",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"20px"}}),e.createElement("style",null,"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "),e.createElement("div",{className:"text-gray-600 font-medium text-lg mb-2"},"Loading document..."),e.createElement("div",{className:"text-gray-400 text-sm"},"Preparing content")),w&&p&&e.createElement(k,{isVisible:N,position:F,sourceLink:null==s?void 0:s.sourceLink,elementId:M,baseUrl:p,onClose:z,buttonColor:g,viewerRoutePath:b}))},L=E((function(){return Promise.resolve().then((function(){return W}))}),{ssr:!1}),D=E((function(){return Promise.resolve().then((function(){return fl}))}),{ssr:!1}),F=function(t){var r=t.zoomIn,a=t.zoomOut;return e.createElement("div",{className:"bg-white flex items-center",style:{padding:"1px",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",border:"1px solid #cbd5e1",borderRadius:"4px",position:"absolute",bottom:"15px",right:"14px",zIndex:10,height:"32px"}},e.createElement("button",{onClick:a,"aria-label":"Zoom out",style:{fontSize:"12px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"3px",cursor:"pointer",padding:"4px",backgroundColor:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1",height:"26px",width:"26px",minWidth:"26px",margin:"2px"}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}))),e.createElement("button",{onClick:r,"aria-label":"Zoom in",style:{fontSize:"12px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"3px",cursor:"pointer",padding:"4px",backgroundColor:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1",height:"26px",width:"26px",minWidth:"26px",margin:"2px"}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.createElement("line",{x1:"5",y1:"12",x2:"19",y2:"12"}))))},P=function(t){var r=t.className,s=void 0===r?"w-full h-full":r,i=t.style,o=t.showZoomControls,c=void 0===o||o,l=t.enableShareableLinks,f=void 0===l||l,h=t.shareableLinkBaseUrl,u=t.shareableLinkButtonColor,d=void 0===u?"#2563eb":u,p=t.viewerRoutePath,m=void 0===p?"document-viewer":p,g=b(),v=g.document,w=g.highlightedElementId,E=g.isLoading,T=g.zoomLevel,y=g.zoomIn,k=g.zoomOut;g.resetZoom;var x=a(null);n((function(){var e=x.current;if(e){var t=function(e){e.ctrlKey&&(e.preventDefault(),e.deltaY<0?y():k())};return e.addEventListener("wheel",t,{passive:!1}),function(){e.removeEventListener("wheel",t)}}}),[y,k]),e.createElement("div",{className:"w-full h-full flex items-center justify-center",style:{backgroundColor:"white"}},e.createElement("div",{className:"text-lg font-medium text-gray-500"},"Loading viewer component..."));return e.createElement("div",{ref:x,className:"relative",style:{width:"100%",height:"100%",overflow:"hidden",backgroundColor:"white"},onWheel:function(e){e.ctrlKey&&(e.preventDefault(),e.deltaY<0?y():k())}},!v||E?e.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center",style:{backgroundColor:"white",transition:"opacity 0.3s ease"}},E&&e.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #475569",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"20px"}}),e.createElement("style",null,"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "),e.createElement("div",{className:"text-gray-600 font-medium text-lg mb-2"},E?"Loading document...":"No document loaded"),E&&e.createElement("div",{className:"text-gray-400 text-sm"},"Please wait while we prepare your document")):("pdf"===v.fileType||"application/pdf"===v.contentType||v.fileName&&v.fileName.toLowerCase().endsWith(".pdf"))&&v.sasUrl?e.createElement(e.Suspense,{fallback:e.createElement("div",{className:"w-full h-full flex flex-col items-center justify-center p-4",style:{backgroundColor:"white"}},e.createElement("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mb-4"}),e.createElement("div",{className:"text-lg font-medium text-gray-500"},"Loading PDF viewer..."),e.createElement("div",{className:"text-sm text-gray-400 mt-2"},"This may take a moment"))},e.createElement(L,{sasUrl:v.sasUrl,className:s,style:i,zoomLevel:T,highlightedElementId:w,key:"pdf-".concat(v.sasUrl)})):("xlsx"===v.fileType||"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"===v.contentType||v.fileName&&(v.fileName.toLowerCase().endsWith(".xlsx")||v.fileName.toLowerCase().endsWith(".csv")||v.fileName.toLowerCase().endsWith(".xls")))&&v.sasUrl?e.createElement(e.Suspense,{fallback:e.createElement("div",{className:"w-full h-full flex items-center justify-center",style:{backgroundColor:"white"}},e.createElement("div",{className:"text-lg font-medium text-gray-500"},"Loading spreadsheet viewer..."))},e.createElement(D,{sasUrl:v.sasUrl,className:s,style:i,zoomLevel:T,document:v})):e.createElement(N,{document:v,highlightedElementId:w,zoomLevel:T,className:s,style:i,enableShareableLinks:f,shareableLinkBaseUrl:h,shareableLinkButtonColor:d,viewerRoutePath:m}),c&&e.createElement(F,{zoomIn:y,zoomOut:k}))},M=function(t){var r=t.onClick,a=t.label,n=void 0===a?"Download":a,s=t.style,i=void 0===s?{}:s,c=t.className,l=void 0===c?"":c,f=t.primary,h=void 0!==f&&f,u=o({padding:"6px 12px",borderRadius:"4px",cursor:"pointer",fontWeight:"bold",display:"flex",alignItems:"center",gap:"4px",boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",transition:"background-color 0.2s ease",fontSize:"12px"},i),d=o(o({},u),{backgroundColor:"#475569",color:"#ffffff",border:"1px solid #475569"}),p=o(o({},u),{backgroundColor:"#f1f5f9",color:"#475569",border:"1px solid #cbd5e1"}),m=h?d:p;return e.createElement("button",{onClick:r,style:m,className:l,onMouseOver:function(e){e.currentTarget.style.backgroundColor=h?"#3f4a5c":"#e2e8f0"},onMouseOut:function(e){e.currentTarget.style.backgroundColor=h?"#475569":"#f1f5f9"},title:"Download ".concat(n)},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.createElement("polyline",{points:"7 10 12 15 17 10"}),e.createElement("line",{x1:"12",y1:"15",x2:"12",y2:"3"})),n)},U=function(t){var r=t.currentPage,a=t.totalPages,n=t.style,s=void 0===n?{}:n,i=t.className,c=void 0===i?"":i,l=o({padding:"6px 12px",backgroundColor:"white",color:"#475569",border:"1px solid #cbd5e1",borderRadius:"4px",fontSize:"12px",fontWeight:500,boxShadow:"0 1px 2px rgba(0, 0, 0, 0.05)",display:"inline-flex",alignItems:"center"},s);return e.createElement("div",{style:l,className:c},"Page ",r," of ",a)},B=function(t){var r=t.className,a=void 0===r?"w-full h-full":r,n=t.style;return e.createElement("div",{className:a,style:o(o({},n),{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",background:"#f5f5f5",color:"#666"})},"PDF viewer loading...")},W=Object.freeze({__proto__:null,default:function(t){var s=t.sasUrl,i=t.className,o=void 0===i?"w-full h-full":i,f=t.style,h=t.zoomLevel,u=void 0===h?1:h,d=t.highlightedElementId,p=void 0===d?null:d,m=a(null),g=r(!0),v=g[0],b=g[1],w=r(null),E=w[0],T=w[1],y=r(0),k=y[0],x=y[1],A=r(1),S=A[0],C=A[1],_=r(!1),R=_[0],I=_[1],N=r(null),L=N[0],D=N[1],F="undefined"!=typeof window,P=function(){s&&fetch(s).then((function(e){if(!e.ok)throw new Error("Network response was not ok");return e.blob()})).then((function(e){var t=window.URL.createObjectURL(e),r=document.createElement("a");r.href=t;var a="document.pdf";try{var n=new URL(s).pathname.split("/"),i=n[n.length-1];i&&i.includes(".pdf")&&(a=decodeURIComponent(i.split("?")[0]))}catch(e){}r.download=a,document.body.appendChild(r),r.click(),window.URL.revokeObjectURL(t),document.body.removeChild(r)})).catch((function(e){window.open(s,"_blank")}))};return n((function(){if(F){var e=!0;return c(void 0,void 0,void 0,(function(){var t,r,a,n,s,i,o;return l(this,(function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),[4,import("pdfjs-dist")];case 1:return t=c.sent(),[4,import("pdfjs-dist")];case 2:r=c.sent().GlobalWorkerOptions,a="https://cdn.jsdelivr.net/npm/pdfjs-dist@".concat(t.version,"/build/pdf.worker.min.mjs"),r.workerSrc=a;try{(n=document.createElement("link")).rel="preload",n.as="script",n.href=a,document.head.appendChild(n)}catch(e){}return document.getElementById("pdfjs-viewer-styles")||((s=document.createElement("link")).id="pdfjs-viewer-styles",s.rel="stylesheet",s.href="https://cdn.jsdelivr.net/npm/pdfjs-dist@".concat(t.version,"/web/pdf_viewer.css"),document.head.appendChild(s),(i=document.createElement("style")).id="pdf-custom-styles",i.textContent="\n .pdf-container {\n position: absolute;\n width: 100%;\n height: 100%;\n overflow: auto;\n background-color: #f8f9fa;\n }\n .pdfViewer .page {\n margin: 15px auto;\n box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);\n }\n .pdfViewer .page.highlighted {\n box-shadow: 0 0 15px 5px rgba(255, 235, 59, 0.5);\n }\n ",document.head.appendChild(i)),e&&I(!0),[3,4];case 3:return o=c.sent(),e&&(T("Failed to load PDF.js: ".concat(o instanceof Error?o.message:String(o))),b(!1)),[3,4];case 4:return[2]}}))})),function(){e=!1}}}),[F]),n((function(){if(F&&s&&R&&m.current){var e=!0,t=null,r=null,a=null;return c(void 0,void 0,void 0,(function(){var n,i,o,c,f,h,d,g,v;return l(this,(function(l){switch(l.label){case 0:return l.trys.push([0,4,,5]),b(!0),T(null),[4,import("pdfjs-dist")];case 1:return n=l.sent(),[4,import("pdfjs-dist/web/pdf_viewer.mjs")];case 2:return i=l.sent(),e&&m.current?(m.current.innerHTML="",(o=document.createElement("div")).className="pdf-container",(c=document.createElement("div")).className="pdfViewer",o.appendChild(c),m.current.appendChild(o),a=new i.EventBus,f=new i.PDFLinkService({eventBus:a}),t=new i.PDFViewer({container:o,viewer:c,eventBus:a,linkService:f,textLayerMode:2,removePageBorders:!1}),f.setViewer(t),a.on("pagesinit",(function(){t&&(t.currentScaleValue=u)})),a.on("pagechanging",(function(t){e&&C(t.pageNumber||1)})),(h=n.getDocument({url:s,withCredentials:!1,cMapUrl:"https://cdn.jsdelivr.net/npm/pdfjs-dist@".concat(n.version,"/cmaps/"),cMapPacked:!0})).onProgress=function(e){},[4,h.promise]):[2];case 3:return r=l.sent(),e&&t?(t.setDocument(r),f.setDocument(r),x(r.numPages),D(t),p&&null!==(d=O(p))&&(g=d+1,setTimeout((function(){t&&e&&(t.currentPageNumber=g,setTimeout((function(){var r;if(e&&t){var a=null===(r=t.getPageView(d))||void 0===r?void 0:r.div;a&&a.classList.add("highlighted")}}),100))}),100)),e&&b(!1),[3,5]):[2];case 4:return v=l.sent(),e&&(T("Failed to load or render PDF: ".concat(v instanceof Error?v.message:String(v))),b(!1)),[3,5];case 5:return[2]}}))})),function(){e=!1,a&&(a.off("pagesinit"),a.off("pagechanging")),r&&r.destroy()}}}),[s,R,u,p,F]),n((function(){L&&"number"==typeof u&&(L.currentScaleValue=u)}),[L,u]),F?e.createElement("div",{className:"relative ".concat(o),style:f},e.createElement("div",{ref:m,className:"w-full h-full",style:{opacity:v?0:1,transition:"opacity 0.3s ease"}}),v&&e.createElement("div",{className:"absolute inset-0 flex flex-col items-center justify-center",style:{backgroundColor:"white"}},e.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #475569",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"20px"}}),e.createElement("style",null,"\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n "),e.createElement("div",{className:"text-gray-600 font-medium text-lg mb-2"},"Loading PDF..."),e.createElement("div",{className:"text-gray-400 text-sm"},0===k?"Preparing document...":"Loading ".concat(k," pages..."))),E&&!v&&e.createElement("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-4",style:{backgroundColor:"white"}},e.createElement("div",{style:{marginBottom:"20px",color:"#dc2626"}},e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"64",height:"64",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},e.createElement("circle",{cx:"12",cy:"12",r:"10"}),e.createElement("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),e.createElement("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"}))),e.createElement("h2",{style:{margin:"0 0 10px",fontS